Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
VisualShaderNodeColorFunc
继承: VisualShaderNode < Resource < RefCounted < Object
Color 函数,在可视化着色器图中使用。
描述
属性
|
枚举
enum Function: 🔗
Function FUNC_GRAYSCALE = 0
使用以下公式将颜色转换为灰度。
vec3 c = input;
float max1 = max(c.r, c.g);
float max2 = max(max1, c.b);
float max3 = max(max1, max2);
return vec3(max3, max3, max3);
Function FUNC_HSV2RGB = 1
将 HSV 向量转换为等效的 RGB 向量。
Function FUNC_RGB2HSV = 2
将 RGB 向量转换为等效的 HSV 向量。
Function FUNC_SEPIA = 3
使用以下公式应用棕褐色调效果。
vec3 c = input;
float r = (c.r * 0.393) + (c.g * 0.769) + (c.b * 0.189);
float g = (c.r * 0.349) + (c.g * 0.686) + (c.b * 0.168);
float b = (c.r * 0.272) + (c.g * 0.534) + (c.b * 0.131);
return vec3(r, g, b);
Function FUNC_LINEAR_TO_SRGB = 4
使用以下公式,将颜色从线性编码转换为非线性 sRGB 编码:
const vec3 a = vec3(0.055f);
return mix((vec3(1.0f) + a) * pow(c.rgb, vec3(1.0f / 2.4f)) - a, 12.92f * c.rgb, lessThan(c.rgb, vec3(0.0031308f)));
兼容渲染器使用了一种更简单的公式,该公式在输入负数值时可能会产生未定义的行为:
vec3 c = input;
return max(vec3(1.055) * pow(c, vec3(0.416666667)) - vec3(0.055), vec3(0.0));
Function FUNC_SRGB_TO_LINEAR = 5
使用以下公式,将颜色从非线性 sRGB 编码转换为线性编码:
vec3 c = input;
return mix(pow((c.rgb + vec3(0.055)) * (1.0 / (1.0 + 0.055)), vec3(2.4)), c.rgb * (1.0 / 12.92), lessThan(c.rgb, vec3(0.04045)));
兼容渲染器使用了一种更简单的公式,该公式在处理负数输入值时表现不佳:
vec3 c = input;
return c * (c * (c * 0.305306011 + 0.682171111) + 0.012522878);
Function FUNC_MAX = 6
代表 Function 枚举的大小。
属性说明
要应用于输入颜色的函数。