0.2.0-dev Download ZIP
71 lines ·2.9 KB Raw
| 1 | <?xml version="1.0" encoding="UTF-8" ?> |
| 2 | <class name="VisualShaderNodeColorFunc" inherits="VisualShaderNode" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd"> |
| 3 | <brief_description> |
| 4 | A [Color] function to be used within the visual shader graph. |
| 5 | </brief_description> |
| 6 | <description> |
| 7 | Accept a [Color] to the input port and transform it according to [member function]. |
| 8 | </description> |
| 9 | <tutorials> |
| 10 | </tutorials> |
| 11 | <members> |
| 12 | <member name="function" type="int" setter="set_function" getter="get_function" enum="VisualShaderNodeColorFunc.Function" default="0"> |
| 13 | A function to be applied to the input color. |
| 14 | </member> |
| 15 | </members> |
| 16 | <constants> |
| 17 | <constant name="FUNC_GRAYSCALE" value="0" enum="Function"> |
| 18 | Converts the color to grayscale using the following formula: |
| 19 | [codeblock] |
| 20 | vec3 c = input; |
| 21 | float max1 = max(c.r, c.g); |
| 22 | float max2 = max(max1, c.b); |
| 23 | float max3 = max(max1, max2); |
| 24 | return vec3(max3, max3, max3); |
| 25 | [/codeblock] |
| 26 | </constant> |
| 27 | <constant name="FUNC_HSV2RGB" value="1" enum="Function"> |
| 28 | Converts HSV vector to RGB equivalent. |
| 29 | </constant> |
| 30 | <constant name="FUNC_RGB2HSV" value="2" enum="Function"> |
| 31 | Converts RGB vector to HSV equivalent. |
| 32 | </constant> |
| 33 | <constant name="FUNC_SEPIA" value="3" enum="Function"> |
| 34 | Applies sepia tone effect using the following formula: |
| 35 | [codeblock] |
| 36 | vec3 c = input; |
| 37 | float r = (c.r * 0.393) + (c.g * 0.769) + (c.b * 0.189); |
| 38 | float g = (c.r * 0.349) + (c.g * 0.686) + (c.b * 0.168); |
| 39 | float b = (c.r * 0.272) + (c.g * 0.534) + (c.b * 0.131); |
| 40 | return vec3(r, g, b); |
| 41 | [/codeblock] |
| 42 | </constant> |
| 43 | <constant name="FUNC_LINEAR_TO_SRGB" value="4" enum="Function"> |
| 44 | Converts color from linear encoding to nonlinear sRGB encoding using the following formula: |
| 45 | [codeblock] |
| 46 | const vec3 a = vec3(0.055f); |
| 47 | 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))); |
| 48 | [/codeblock] |
| 49 | The Compatibility renderer uses a simpler formula that may produce undefined behavior with negative input values: |
| 50 | [codeblock] |
| 51 | vec3 c = input; |
| 52 | return max(vec3(1.055) * pow(c, vec3(0.416666667)) - vec3(0.055), vec3(0.0)); |
| 53 | [/codeblock] |
| 54 | </constant> |
| 55 | <constant name="FUNC_SRGB_TO_LINEAR" value="5" enum="Function"> |
| 56 | Converts color from nonlinear sRGB encoding to linear encoding using the following formula: |
| 57 | [codeblock] |
| 58 | vec3 c = input; |
| 59 | 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))); |
| 60 | [/codeblock] |
| 61 | The Compatibility renderer uses a simpler formula that behaves poorly with negative input values: |
| 62 | [codeblock] |
| 63 | vec3 c = input; |
| 64 | return c * (c * (c * 0.305306011 + 0.682171111) + 0.012522878); |
| 65 | [/codeblock] |
| 66 | </constant> |
| 67 | <constant name="FUNC_MAX" value="6" enum="Function"> |
| 68 | Represents the size of the [enum Function] enum. |
| 69 | </constant> |
| 70 | </constants> |
| 71 | </class> |