@@ -780,7 +780,7 @@ Uniforms
780780Passing values to shaders is possible. These are global to the whole shader and
781781are called *uniforms *. When a shader is later assigned to a material, the
782782uniforms will appear as editable parameters in it. Uniforms can't be written
783- from within the shader.
783+ from within the shader. Any GLSL type except for `` void `` can be a uniform.
784784
785785.. code-block :: glsl
786786
@@ -803,9 +803,12 @@ GDScript:
803803 in the shader. It must match *exactly * to the name of the uniform in
804804 the shader or else it will not be recognized.
805805
806- Any GLSL type except for *void * can be a uniform. Additionally, Godot provides
807- optional shader hints to make the compiler understand for what the uniform is
808- used, and how the editor should allow users to modify it.
806+
807+ Uniform hints
808+ ~~~~~~~~~~~~~
809+
810+ Godot provides optional uniform hints to make the compiler understand what the
811+ uniform is used for, and how the editor should allow users to modify it.
809812
810813.. code-block :: glsl
811814
@@ -816,20 +819,26 @@ used, and how the editor should allow users to modify it.
816819 uniform vec4 other_color : source_color = vec4(1.0); // Default values go after the hint.
817820 uniform sampler2D image : source_color;
818821
819- It's important to understand that textures *that are supplied as color * require
820- hints for proper sRGB -> linear conversion (i.e. ``source_color ``), as Godot's
821- 3D engine renders in linear color space. If this is not done, the texture will
822- appear washed out.
822+ .. admonition :: Source Color
823823
824- .. note ::
824+ Any texture which contains *sRGB color data * requires a ``source_color `` hint
825+ in order to be correctly sampled. This is because Godot renders in linear
826+ color space, but some textures contain sRGB color data. If this hint is not
827+ used, the texture will appear washed out.
828+
829+ Albedo and color textures should typically have a ``source_color `` hint. Normal,
830+ roughness, metallic, and height textures typically do not need a ``source_color ``
831+ hint.
832+
833+ Using ``source_color `` hint is required in the Forward+ and Mobile renderers,
834+ and in ``canvas_item `` shaders when :ref: `HDR 2D<class_ProjectSettings_property_rendering/viewport/hdr_2d> `
835+ is enabled. The ``source_color `` hint is optional for the Compatibility renderer,
836+ and for ``canvas_item `` shaders if ``HDR 2D `` is disabled. However, it is
837+ recommended to always use the ``source_color `` hint, because it works even
838+ if you change renderers or disable ``HDR 2D ``.
825839
826- The 2D renderer also renders in linear color space if the
827- **Rendering > Viewport > HDR 2D ** project setting is enabled, so
828- ``source_color `` must also be used in ``canvas_item `` shaders. If 2D HDR is
829- disabled, ``source_color `` will keep working correctly in ``canvas_item ``
830- shaders, so it's recommend to use it either way.
831840
832- Full list of hints below:
841+ Full list of uniform hints below:
833842
834843+----------------------+--------------------------------------------------+-----------------------------------------------------------------------------+
835844| Type | Hint | Description |
0 commit comments