CanvasTexture

继承: Texture2D < Texture < Resource < RefCounted < Object

Texture with optional normal and specular maps for use in 2D rendering.

描述

CanvasTexture is an alternative to ImageTexture for 2D rendering. It allows using normal maps and specular maps in any node that inherits from CanvasItem. CanvasTexture also allows overriding the texture's filter and repeat mode independently of the node's properties (or the project settings).

Note: CanvasTexture cannot be used in 3D. It will not display correctly when applied to any VisualInstance3D, such as Sprite3D or Decal. For physically-based materials in 3D, use BaseMaterial3D instead.

属性


属性说明

Texture2D diffuse_texture

The diffuse (color) texture to use. This is the main texture you want to set in most cases.


Texture2D normal_texture

The normal map texture to use. Only has a visible effect if Light2D s are affecting this CanvasTexture.

Note: Godot expects the normal map to use X+, Y+, and Z+ coordinates. See this page for a comparison of normal map coordinates expected by popular engines.


Color specular_color = Color(1, 1, 1, 1)

  • void set_specular_color ( value: Color )
  • Color get_specular_color ( )

The multiplier for specular reflection colors. The Light2D's color is also taken into account when determining the reflection color. Only has a visible effect if Light2D s are affecting this CanvasTexture.


float specular_shininess = 1.0

  • void set_specular_shininess ( value: float )
  • float get_specular_shininess ( )

The specular exponent for Light2D specular reflections. Higher values result in a more glossy/"wet" look, with reflections becoming more localized and less visible overall. The default value of 1.0 disables specular reflections entirely. Only has a visible effect if Light2D s are affecting this CanvasTexture.


Texture2D specular_texture

The specular map to use for Light2D specular reflections. This should be a grayscale or colored texture, with brighter areas resulting in a higher specular_shininess value. Using a colored specular_texture allows controlling specular shininess on a per-channel basis. Only has a visible effect if Light2D s are affecting this CanvasTexture.


TextureFilter texture_filter = 0

The texture filtering mode to use when drawing this CanvasTexture.


TextureRepeat texture_repeat = 0

The texture repeat mode to use when drawing this CanvasTexture.

1

本方法通常需要用户覆盖才能生效。

2

本方法无副作用,不会修改该实例的任何成员变量。

3

本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。

4

本方法用于构造某个类型。

5

调用本方法无需实例,可直接使用类名进行调用。

6

本方法描述的是使用本类型作为左操作数的有效运算符。

7

这个值是由下列位标志构成位掩码的整数。

8

无返回值。