Few more fixes/enchancements to shaders

This commit is contained in:
Yuri Roubinsky
2021-12-12 20:03:38 +03:00
parent 9cdf87f7f2
commit 58bc70ff28
5 changed files with 253 additions and 230 deletions

View File

@@ -64,7 +64,7 @@ Global built-ins are available everywhere, including custom functions.
| | An equivalent of ``PI * 2`` and amount of radians in full turn. |
+-------------------+----------------------------------------------------------------------------------------+
| in float **E** | A ``E`` constant (``2.718281``). |
| | Euler's number and a base of natural logarithm. |
| | Euler's number and a base of the natural logarithm. |
+-------------------+----------------------------------------------------------------------------------------+
Vertex built-ins

View File

@@ -26,15 +26,15 @@ data they have calculated once they draw to the frame buffer.
Render modes
^^^^^^^^^^^^
+---------------------------------+----------------------------------------------------------------------+
| Render mode | Description |
+=================================+======================================================================+
| **keep_data** | Do not clear previous data on restart. |
+---------------------------------+----------------------------------------------------------------------+
| **disable_force** | Disable attractor force. |
+---------------------------------+----------------------------------------------------------------------+
| **disable_velocity** | Ignore **VELOCITY** value. |
+---------------------------------+----------------------------------------------------------------------+
+-----------------------+----------------------------------------+
| Render mode | Description |
+=======================+========================================+
| **keep_data** | Do not clear previous data on restart. |
+-----------------------+----------------------------------------+
| **disable_force** | Disable attractor force. |
+-----------------------+----------------------------------------+
| **disable_velocity** | Ignore **VELOCITY** value. |
+-----------------------+----------------------------------------+
Built-ins
^^^^^^^^^
@@ -50,7 +50,7 @@ Global built-ins
Global built-ins are available everywhere, including custom functions.
+-------------------+----------------------------------------------------------------------------------------+
| Built-in | Description |
| Built-in | Description |
+===================+========================================================================================+
| in float **TIME** | Global time, in seconds. |
+-------------------+----------------------------------------------------------------------------------------+
@@ -60,7 +60,7 @@ Global built-ins are available everywhere, including custom functions.
| in float **TAU** | A ``TAU`` constant (``6.283185``). |
| | An equivalent of ``PI * 2`` and amount of radians in full turn. |
+-------------------+----------------------------------------------------------------------------------------+
| in float **E** | A ``E`` constant (``2.718281``). Euler's number and a base of natural logarithm. |
| in float **E** | A ``E`` constant (``2.718281``). Euler's number and a base of the natural logarithm. |
+-------------------+----------------------------------------------------------------------------------------+
Start and Process built-ins

View File

@@ -337,6 +337,23 @@ accessible outside of the shader.
const float PI = 3.14159265358979323846;
Constants of the ``float`` type must be initialized using ``.`` notation after the
decimal part or by using the scientific notation. The optional ``f`` post-suffix is
also supported.
.. code-block:: glsl
float a = 1.0;
float b = 1.0f; // same, using suffix for clarity
float c = 1e-1; // gives 0.1 by using the scientific notation
Constants of the ``uint`` (unsigned int) type must have a ``u`` suffix to differentiate them from signed integers.
Alternatively, this can be done by using the ``uint(x)`` built-in conversion function.
.. code-block:: glsl
uint a = 1u;
uint b = uint(1);
Structs
-------
@@ -735,25 +752,31 @@ engine renders in linear color space.
Full list of hints below:
+----------------+------------------------------+-------------------------------------+
| Type | Hint | Description |
+================+==============================+=====================================+
| **vec4** | hint_color | Used as color |
+----------------+------------------------------+-------------------------------------+
| **int, float** | hint_range(min, max[, step]) | Used as range (with min/max/step) |
+----------------+------------------------------+-------------------------------------+
| **sampler2D** | hint_albedo | Used as albedo color, default white |
+----------------+------------------------------+-------------------------------------+
| **sampler2D** | hint_black_albedo | Used as albedo color, default black |
+----------------+------------------------------+-------------------------------------+
| **sampler2D** | hint_normal | Used as normalmap |
+----------------+------------------------------+-------------------------------------+
| **sampler2D** | hint_white | As value, default to white. |
+----------------+------------------------------+-------------------------------------+
| **sampler2D** | hint_black | As value, default to black |
+----------------+------------------------------+-------------------------------------+
| **sampler2D** | hint_aniso | As flowmap, default to right. |
+----------------+------------------------------+-------------------------------------+
+----------------------+------------------------------------------------+--------------------------------------+
| Type | Hint | Description |
+======================+================================================+======================================+
| **vec4** | hint_color | Used as color. |
+----------------------+------------------------------------------------+--------------------------------------+
| **int, float** | hint_range(min, max[, step]) | Used as range (with min/max/step). |
+----------------------+------------------------------------------------+--------------------------------------+
| **sampler2D** | hint_albedo | Used as albedo color, default white. |
+----------------------+------------------------------------------------+--------------------------------------+
| **sampler2D** | hint_black_albedo | Used as albedo color, default black. |
+----------------------+------------------------------------------------+--------------------------------------+
| **sampler2D** | hint_normal | Used as normalmap. |
+----------------------+------------------------------------------------+--------------------------------------+
| **sampler2D** | hint_white | As value, default to white. |
+----------------------+------------------------------------------------+--------------------------------------+
| **sampler2D** | hint_black | As value, default to black. |
+----------------------+------------------------------------------------+--------------------------------------+
| **sampler2D** | hint_anisotropy | As flowmap, default to right. |
+----------------------+------------------------------------------------+--------------------------------------+
| **sampler2D** | hint_roughness[_r, _g, _b, _a, _normal, _gray] | |
+----------------------+------------------------------------------------+--------------------------------------+
| **sampler2D** | filter[_nearest, _linear][_mipmap][_aniso] | Enabled specified texture filtering. |
+----------------------+------------------------------------------------+--------------------------------------+
| **sampler2D** | repeat_[enable, disable] | Enabled texture repeating. |
+----------------------+------------------------------------------------+--------------------------------------+
GDScript uses different variable types than GLSL does, so when passing variables
from GDScript to shaders, Godot converts the type automatically. Below is a

View File

@@ -89,15 +89,15 @@ a lower resolution than the rest of the sky:
}
}
+---------------------------------+----------------------------------------------------------------------+
| Render mode | Description |
+=================================+======================================================================+
| **use_half_res_pass** | Allows the shader to write to and access the half resolution pass. |
+---------------------------------+----------------------------------------------------------------------+
| **use_quarter_res_pass** | Allows the shader to write to and access the quarter resolution pass.|
+---------------------------------+----------------------------------------------------------------------+
| **disable_fog** | If used, fog will not affect the sky. |
+---------------------------------+----------------------------------------------------------------------+
+--------------------------+-----------------------------------------------------------------------+
| Render mode | Description |
+==========================+=======================================================================+
| **use_half_res_pass** | Allows the shader to write to and access the half resolution pass. |
+--------------------------+-----------------------------------------------------------------------+
| **use_quarter_res_pass** | Allows the shader to write to and access the quarter resolution pass. |
+--------------------------+-----------------------------------------------------------------------+
| **disable_fog** | If used, fog will not affect the sky. |
+--------------------------+-----------------------------------------------------------------------+
Built-ins
^^^^^^^^^
@@ -147,7 +147,7 @@ There are 4 ``LIGHTX`` lights, accessed as ``LIGHT0``, ``LIGHT1``, ``LIGHT2``, a
| | An equivalent of ``PI * 2`` and amount of radians in full turn. |
+---------------------------------+--------------------------------------------------------------------------------------------------------------------------+
| in float **E** | A ``E`` constant (``2.718281``). |
| | Euler's number and a base of natural logarithm. |
| | Euler's number and a base of the natural logarithm. |
+---------------------------------+--------------------------------------------------------------------------------------------------------------------------+
Sky built-ins

View File

@@ -11,79 +11,79 @@ write vertex, fragment, and light processor functions to affect how objects are
Render modes
^^^^^^^^^^^^
+---------------------------------+-----------------------------------------------------------------------+
| Render mode | Description |
+=================================+=======================================================================+
| **blend_mix** | Mix blend mode (alpha is transparency), default. |
+---------------------------------+-----------------------------------------------------------------------+
| **blend_add** | Additive blend mode. |
+---------------------------------+-----------------------------------------------------------------------+
| **blend_sub** | Subtractive blend mode. |
+---------------------------------+-----------------------------------------------------------------------+
| **blend_mul** | Multiplicative blend mode. |
+---------------------------------+-----------------------------------------------------------------------+
| **depth_draw_opaque** | Only draw depth for opaque geometry (not transparent). |
+---------------------------------+-----------------------------------------------------------------------+
| **depth_draw_always** | Always draw depth (opaque and transparent). |
+---------------------------------+-----------------------------------------------------------------------+
| **depth_draw_never** | Never draw depth. |
+---------------------------------+-----------------------------------------------------------------------+
| **depth_prepass_alpha** | Do opaque depth pre-pass for transparent geometry. |
+---------------------------------+-----------------------------------------------------------------------+
| **depth_test_disabled** | Disable depth testing. |
+---------------------------------+-----------------------------------------------------------------------+
| **sss_mode_skin** | |
+---------------------------------+-----------------------------------------------------------------------+
| **cull_back** | Cull back-faces (default). |
+---------------------------------+-----------------------------------------------------------------------+
| **cull_front** | Cull front-faces. |
+---------------------------------+-----------------------------------------------------------------------+
| **cull_disabled** | Culling disabled (double sided). |
+---------------------------------+-----------------------------------------------------------------------+
| **unshaded** | Result is just albedo. No lighting/shading happens in material. |
+---------------------------------+-----------------------------------------------------------------------+
| **wireframe** | Geometry draws using lines. |
+---------------------------------+-----------------------------------------------------------------------+
| **diffuse_lambert** | Lambert shading for diffuse (default). |
+---------------------------------+-----------------------------------------------------------------------+
| **diffuse_lambert_wrap** | Lambert wrapping (roughness dependent) for diffuse. |
+---------------------------------+-----------------------------------------------------------------------+
| **diffuse_burley** | Burley (Disney PBS) for diffuse. |
+---------------------------------+-----------------------------------------------------------------------+
| **diffuse_toon** | Toon shading for diffuse. |
+---------------------------------+-----------------------------------------------------------------------+
| **specular_schlick_ggx** | Schlick-GGX for specular (default). |
+---------------------------------+-----------------------------------------------------------------------+
| **specular_blinn** | Blinn for specular (compatibility). |
+---------------------------------+-----------------------------------------------------------------------+
| **specular_phong** | Phong for specular (compatibility). |
+---------------------------------+-----------------------------------------------------------------------+
| **specular_toon** | Toon for specular. |
+---------------------------------+-----------------------------------------------------------------------+
| **specular_disabled** | Disable specular. |
+---------------------------------+-----------------------------------------------------------------------+
| **skip_vertex_transform** | VERTEX/NORMAL/etc. need to be transformed manually in vertex function.|
+---------------------------------+-----------------------------------------------------------------------+
| **world_vertex_coords** | VERTEX/NORMAL/etc. are modified in world coordinates instead of local.|
+---------------------------------+-----------------------------------------------------------------------+
| **ensure_correct_normals** | Use when non-uniform scale is applied to mesh. |
+---------------------------------+-----------------------------------------------------------------------+
| **shadows_disabled** | Disable computing shadows in shader. |
+---------------------------------+-----------------------------------------------------------------------+
| **ambient_light_disabled** | Disable contribution from ambient light and radiance map. |
+---------------------------------+-----------------------------------------------------------------------+
| **shadow_to_opacity** | Lighting modifies the alpha so shadowed areas are opaque and |
| | non-shadowed areas are transparent. Useful for overlaying shadows onto|
| | a camera feed in AR. |
+---------------------------------+-----------------------------------------------------------------------+
| **vertex_lighting** | Use vertex-based lighting. |
+---------------------------------+-----------------------------------------------------------------------+
| **particle_trails** | Enables the trails when used on particles geometry. |
+---------------------------------+-----------------------------------------------------------------------+
| **alpha_to_coverage** | |
+---------------------------------+-----------------------------------------------------------------------+
| **alpha_to_coverage_and_one** | |
+---------------------------------+-----------------------------------------------------------------------+
+-------------------------------+------------------------------------------------------------------------+
| Render mode | Description |
+===============================+========================================================================+
| **blend_mix** | Mix blend mode (alpha is transparency), default. |
+-------------------------------+------------------------------------------------------------------------+
| **blend_add** | Additive blend mode. |
+-------------------------------+------------------------------------------------------------------------+
| **blend_sub** | Subtractive blend mode. |
+-------------------------------+------------------------------------------------------------------------+
| **blend_mul** | Multiplicative blend mode. |
+-------------------------------+------------------------------------------------------------------------+
| **depth_draw_opaque** | Only draw depth for opaque geometry (not transparent). |
+-------------------------------+------------------------------------------------------------------------+
| **depth_draw_always** | Always draw depth (opaque and transparent). |
+-------------------------------+------------------------------------------------------------------------+
| **depth_draw_never** | Never draw depth. |
+-------------------------------+------------------------------------------------------------------------+
| **depth_prepass_alpha** | Do opaque depth pre-pass for transparent geometry. |
+-------------------------------+------------------------------------------------------------------------+
| **depth_test_disabled** | Disable depth testing. |
+-------------------------------+------------------------------------------------------------------------+
| **sss_mode_skin** | |
+-------------------------------+------------------------------------------------------------------------+
| **cull_back** | Cull back-faces (default). |
+-------------------------------+------------------------------------------------------------------------+
| **cull_front** | Cull front-faces. |
+-------------------------------+------------------------------------------------------------------------+
| **cull_disabled** | Culling disabled (double sided). |
+-------------------------------+------------------------------------------------------------------------+
| **unshaded** | Result is just albedo. No lighting/shading happens in material. |
+-------------------------------+------------------------------------------------------------------------+
| **wireframe** | Geometry draws using lines. |
+-------------------------------+------------------------------------------------------------------------+
| **diffuse_lambert** | Lambert shading for diffuse (default). |
+-------------------------------+------------------------------------------------------------------------+
| **diffuse_lambert_wrap** | Lambert wrapping (roughness dependent) for diffuse. |
+-------------------------------+------------------------------------------------------------------------+
| **diffuse_burley** | Burley (Disney PBS) for diffuse. |
+-------------------------------+------------------------------------------------------------------------+
| **diffuse_toon** | Toon shading for diffuse. |
+-------------------------------+------------------------------------------------------------------------+
| **specular_schlick_ggx** | Schlick-GGX for specular (default). |
+-------------------------------+------------------------------------------------------------------------+
| **specular_blinn** | Blinn for specular (compatibility). |
+-------------------------------+------------------------------------------------------------------------+
| **specular_phong** | Phong for specular (compatibility). |
+-------------------------------+------------------------------------------------------------------------+
| **specular_toon** | Toon for specular. |
+-------------------------------+------------------------------------------------------------------------+
| **specular_disabled** | Disable specular. |
+-------------------------------+------------------------------------------------------------------------+
| **skip_vertex_transform** | VERTEX/NORMAL/etc. need to be transformed manually in vertex function. |
+-------------------------------+------------------------------------------------------------------------+
| **world_vertex_coords** | VERTEX/NORMAL/etc. are modified in world coordinates instead of local. |
+-------------------------------+------------------------------------------------------------------------+
| **ensure_correct_normals** | Use when non-uniform scale is applied to mesh. |
+-------------------------------+------------------------------------------------------------------------+
| **shadows_disabled** | Disable computing shadows in shader. |
+-------------------------------+------------------------------------------------------------------------+
| **ambient_light_disabled** | Disable contribution from ambient light and radiance map. |
+-------------------------------+------------------------------------------------------------------------+
| **shadow_to_opacity** | Lighting modifies the alpha so shadowed areas are opaque and |
| | non-shadowed areas are transparent. Useful for overlaying shadows onto |
| | a camera feed in AR. |
+-------------------------------+------------------------------------------------------------------------+
| **vertex_lighting** | Use vertex-based lighting. |
+-------------------------------+------------------------------------------------------------------------+
| **particle_trails** | Enables the trails when used on particles geometry. |
+-------------------------------+------------------------------------------------------------------------+
| **alpha_to_coverage** | |
+-------------------------------+------------------------------------------------------------------------+
| **alpha_to_coverage_and_one** | |
+-------------------------------+------------------------------------------------------------------------+
Built-ins
^^^^^^^^^
@@ -99,7 +99,7 @@ Global built-ins
Global built-ins are available everywhere, including custom functions.
+-------------------+----------------------------------------------------------------------------------------+
| Built-in | Description |
| Built-in | Description |
+===================+========================================================================================+
| in float **TIME** | Global time, in seconds. |
+-------------------+----------------------------------------------------------------------------------------+
@@ -109,7 +109,7 @@ Global built-ins are available everywhere, including custom functions.
| in float **TAU** | A ``TAU`` constant (``6.283185``). |
| | An equivalent of ``PI * 2`` and amount of radians in full turn. |
+-------------------+----------------------------------------------------------------------------------------+
| in float **E** | A ``E`` constant (``2.718281``). Euler's number and a base of natural logarithm. |
| in float **E** | A ``E`` constant (``2.718281``). Euler's number and a base of the natural logarithm. |
+-------------------+----------------------------------------------------------------------------------------+
Vertex built-ins
@@ -225,120 +225,120 @@ The default use of a Godot fragment processor function is to set up the material
and to let the built-in renderer handle the final shading. However, you are not required to use all
these properties, and if you don't write to them, Godot will optimize away the corresponding functionality.
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| Built-in | Description |
+===========================================+==================================================================================================+
| in vec2 **VIEWPORT_SIZE** | Size of viewport (in pixels). |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| in vec4 **FRAGCOORD** | Coordinate of pixel center in screen space. ``xy`` specifies position in window, ``z`` |
| | specifies fragment depth if ``DEPTH`` is not used. Origin is lower-left. |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| in bool **FRONT_FACING** | ``true`` if current face if front face. |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| in vec3 **VIEW** | Vector from camera to fragment position (in view space). |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| in vec2 **UV** | UV that comes from vertex function. |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| in vec2 **UV2** | UV2 that comes from vertex function. |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| in vec4 **COLOR** | COLOR that comes from vertex function. |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| in vec2 **POINT_COORD** | Point Coordinate for drawing points with POINT_SIZE. |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| in bool **OUTPUT_IS_SRGB** | ``true`` when calculations happen in sRGB color space (``true`` in GLES2, ``false`` in GLES3). |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| in mat4 **WORLD_MATRIX** | Model space to world space transform. |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| in mat3 **WORLD_NORMAL_MATRIX** | |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| in mat4 **INV_CAMERA_MATRIX** | World space to view space transform. |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| in mat4 **CAMERA_MATRIX** | View space to world space transform. |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| in mat4 **PROJECTION_MATRIX** | View space to clip space transform. |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| in mat4 **INV_PROJECTION_MATRIX** | Clip space to view space transform. |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| in vec3 **VERTEX** | Vertex that comes from vertex function (default, in view space). |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| in int **VIEW_INDEX** | |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| in int **VIEW_MONO_LEFT** | |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| in int **VIEW_RIGHT** | |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| sampler2D **SCREEN_TEXTURE** | Built-in Texture for reading from the screen. Mipmaps contain increasingly blurred copies. |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| in vec2 **SCREEN_UV** | Screen UV coordinate for current pixel. |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| sampler2D **NORMAL_ROUGHNESS_TEXTURE** | |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| sampler2D **DEPTH_TEXTURE** | Built-in Texture for reading depth from the screen. Must convert to linear using INV_PROJECTION. |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **DEPTH** | Custom depth value (0..1). |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| inout vec3 **NORMAL** | Normal that comes from vertex function (default, in view space). |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| inout vec3 **TANGENT** | Tangent that comes from vertex function. |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| inout vec3 **BINORMAL** | Binormal that comes from vertex function. |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| out vec3 **NORMAL_MAP** | Set normal here if reading normal from a texture instead of NORMAL. |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **NORMAL_MAP_DEPTH** | Depth from variable above. Defaults to 1.0. |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| out vec3 **ALBEDO** | Albedo (default white). |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **ALPHA** | Alpha (0..1); if written to, the material will go to the transparent pipeline. |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **ALPHA_SCISSOR_THRESHOLD** | If written to, values below a certain amount of alpha are discarded. |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **ALPHA_HASH_SCALE** | |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **ALPHA_ANTIALIASING_EDGE** | |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| out vec2 **ALPHA_TEXTURE_COORDINATE** | |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **METALLIC** | Metallic (0..1). |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **SPECULAR** | Specular. Defaults to 0.5, best not to modify unless you want to change IOR. |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **ROUGHNESS** | Roughness (0..1). |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **RIM** | Rim (0..1). If used, Godot calculates rim lighting. |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **RIM_TINT** | Rim Tint, goes from 0 (white) to 1 (albedo). If used, Godot calculates rim lighting. |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **CLEARCOAT** | Small added specular blob. If used, Godot calculates Clearcoat. |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **CLEARCOAT_GLOSS** | Gloss of Clearcoat. If used, Godot calculates Clearcoat. |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **ANISOTROPY** | For distorting the specular blob according to tangent space. |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| out vec2 **ANISOTROPY_FLOW** | Distortion direction, use with flowmaps. |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **SSS_STRENGTH** | Strength of Subsurface Scattering. If used, Subsurface Scattering will be applied to object. |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| out vec4 **SSS_TRANSMITTANCE_COLOR** | |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **SSS_TRANSMITTANCE_DEPTH** | |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **SSS_TRANSMITTANCE_BOOST** | |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| inout vec3 **BACKLIGHT** | |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **AO** | Strength of Ambient Occlusion. For use with pre-baked AO. |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **AO_LIGHT_AFFECT** | How much AO affects lights (0..1; default 0). |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| out vec3 **EMISSION** | Emission color (can go over 1,1,1 for HDR). |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| out vec4 **FOG** | If written to, blends final pixel color with FOG.rgb based on FOG.a. |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| out vec4 **RADIANCE** | If written to, blends environment map radiance with RADIANCE.rgb based on RADIANCE.a. |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
| out vec4 **IRRADIANCE** | If written to, blends environment map IRRADIANCE with IRRADIANCE.rgb based on IRRADIANCE.a. |
+-------------------------------------------+--------------------------------------------------------------------------------------------------+
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| Built-in | Description |
+========================================+==================================================================================================+
| in vec2 **VIEWPORT_SIZE** | Size of viewport (in pixels). |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| in vec4 **FRAGCOORD** | Coordinate of pixel center in screen space. ``xy`` specifies position in window, ``z`` |
| | specifies fragment depth if ``DEPTH`` is not used. Origin is lower-left. |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| in bool **FRONT_FACING** | ``true`` if current face if front face. |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| in vec3 **VIEW** | Vector from camera to fragment position (in view space). |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| in vec2 **UV** | UV that comes from vertex function. |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| in vec2 **UV2** | UV2 that comes from vertex function. |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| in vec4 **COLOR** | COLOR that comes from vertex function. |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| in vec2 **POINT_COORD** | Point Coordinate for drawing points with POINT_SIZE. |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| in bool **OUTPUT_IS_SRGB** | ``true`` when calculations happen in sRGB color space (``true`` in GLES2, ``false`` in GLES3). |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| in mat4 **WORLD_MATRIX** | Model space to world space transform. |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| in mat3 **WORLD_NORMAL_MATRIX** | |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| in mat4 **INV_CAMERA_MATRIX** | World space to view space transform. |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| in mat4 **CAMERA_MATRIX** | View space to world space transform. |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| in mat4 **PROJECTION_MATRIX** | View space to clip space transform. |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| in mat4 **INV_PROJECTION_MATRIX** | Clip space to view space transform. |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| in vec3 **VERTEX** | Vertex that comes from vertex function (default, in view space). |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| in int **VIEW_INDEX** | |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| in int **VIEW_MONO_LEFT** | |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| in int **VIEW_RIGHT** | |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| sampler2D **SCREEN_TEXTURE** | Built-in Texture for reading from the screen. Mipmaps contain increasingly blurred copies. |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| in vec2 **SCREEN_UV** | Screen UV coordinate for current pixel. |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| sampler2D **NORMAL_ROUGHNESS_TEXTURE** | |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| sampler2D **DEPTH_TEXTURE** | Built-in Texture for reading depth from the screen. Must convert to linear using INV_PROJECTION. |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **DEPTH** | Custom depth value (0..1). |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| inout vec3 **NORMAL** | Normal that comes from vertex function (default, in view space). |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| inout vec3 **TANGENT** | Tangent that comes from vertex function. |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| inout vec3 **BINORMAL** | Binormal that comes from vertex function. |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| out vec3 **NORMAL_MAP** | Set normal here if reading normal from a texture instead of NORMAL. |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **NORMAL_MAP_DEPTH** | Depth from variable above. Defaults to 1.0. |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| out vec3 **ALBEDO** | Albedo (default white). |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **ALPHA** | Alpha (0..1); if written to, the material will go to the transparent pipeline. |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **ALPHA_SCISSOR_THRESHOLD** | If written to, values below a certain amount of alpha are discarded. |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **ALPHA_HASH_SCALE** | |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **ALPHA_ANTIALIASING_EDGE** | |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| out vec2 **ALPHA_TEXTURE_COORDINATE** | |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **METALLIC** | Metallic (0..1). |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **SPECULAR** | Specular. Defaults to 0.5, best not to modify unless you want to change IOR. |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **ROUGHNESS** | Roughness (0..1). |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **RIM** | Rim (0..1). If used, Godot calculates rim lighting. |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **RIM_TINT** | Rim Tint, goes from 0 (white) to 1 (albedo). If used, Godot calculates rim lighting. |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **CLEARCOAT** | Small added specular blob. If used, Godot calculates Clearcoat. |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **CLEARCOAT_GLOSS** | Gloss of Clearcoat. If used, Godot calculates Clearcoat. |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **ANISOTROPY** | For distorting the specular blob according to tangent space. |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| out vec2 **ANISOTROPY_FLOW** | Distortion direction, use with flowmaps. |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **SSS_STRENGTH** | Strength of Subsurface Scattering. If used, Subsurface Scattering will be applied to object. |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| out vec4 **SSS_TRANSMITTANCE_COLOR** | |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **SSS_TRANSMITTANCE_DEPTH** | |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **SSS_TRANSMITTANCE_BOOST** | |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| inout vec3 **BACKLIGHT** | |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **AO** | Strength of Ambient Occlusion. For use with pre-baked AO. |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| out float **AO_LIGHT_AFFECT** | How much AO affects lights (0..1; default 0). |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| out vec3 **EMISSION** | Emission color (can go over 1,1,1 for HDR). |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| out vec4 **FOG** | If written to, blends final pixel color with FOG.rgb based on FOG.a. |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| out vec4 **RADIANCE** | If written to, blends environment map radiance with RADIANCE.rgb based on RADIANCE.a. |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
| out vec4 **IRRADIANCE** | If written to, blends environment map IRRADIANCE with IRRADIANCE.rgb based on IRRADIANCE.a. |
+----------------------------------------+--------------------------------------------------------------------------------------------------+
Light built-ins
^^^^^^^^^^^^^^^