Browse Source

Merge pull request #4930 from Chaosus/shader_fixes

Yuri Roubinsky 4 years ago
parent
commit
c7cae7e050

+ 110 - 104
tutorials/shaders/shader_reference/canvas_item_shader.rst

@@ -109,31 +109,31 @@ is usually:
 * **y**: Phase during lifetime (0 to 1).
 * **y**: Phase during lifetime (0 to 1).
 * **z**: Animation frame.
 * **z**: Animation frame.
 
 
-+--------------------------------+----------------------------------------------------------------+
-| Built-in                       | Description                                                    |
-+================================+================================================================+
-| in mat4 **WORLD_MATRIX**       | Image space to view space transform.                           |
-+--------------------------------+----------------------------------------------------------------+
-| in mat4 **EXTRA_MATRIX**       | Extra transform.                                               |
-+--------------------------------+----------------------------------------------------------------+
-| in mat4 **PROJECTION_MATRIX**  | View space to clip space transform.                            |
-+--------------------------------+----------------------------------------------------------------+
-| in vec4 **INSTANCE_CUSTOM**    | Instance custom data.                                          |
-+--------------------------------+----------------------------------------------------------------+
-| in bool **AT_LIGHT_PASS**      | ``true`` if this is a light pass.                              |
-+--------------------------------+----------------------------------------------------------------+
-| inout vec2 **VERTEX**          | Vertex, in image space.                                        |
-+--------------------------------+----------------------------------------------------------------+
-| in vec2 **TEXTURE_PIXEL_SIZE** | Normalized pixel size of default 2D texture.                   |
-|                                | For a Sprite with a texture of size 64x32px,                   |
-|                                | **TEXTURE_PIXEL_SIZE** = :code:`vec2(1/64, 1/32)`              |
-+--------------------------------+----------------------------------------------------------------+
-| inout vec2 **UV**              | Texture coordinates.                                           |
-+--------------------------------+----------------------------------------------------------------+
-| inout vec4 **COLOR**           | Color from vertex primitive.                                   |
-+--------------------------------+----------------------------------------------------------------+
-| inout float **POINT_SIZE**     | Point size for point drawing.                                  |
-+--------------------------------+----------------------------------------------------------------+
++--------------------------------+---------------------------------------------------+
+| Built-in                       | Description                                       |
++--------------------------------+---------------------------------------------------+
+| in mat4 **WORLD_MATRIX**       | Image space to view space transform.              |
++--------------------------------+---------------------------------------------------+
+| in mat4 **CANVAS_MATRIX**      |                                                   |
++--------------------------------+---------------------------------------------------+
+| in mat4 **SCREEN_MATRIX**      |                                                   |
++--------------------------------+---------------------------------------------------+
+| in vec4 **INSTANCE_CUSTOM**    | Instance custom data.                             |
++--------------------------------+---------------------------------------------------+
+| in bool **AT_LIGHT_PASS**      | ``true`` if this is a light pass.                 |
++--------------------------------+---------------------------------------------------+
+| in vec2 **TEXTURE_PIXEL_SIZE** | Normalized pixel size of default 2D texture.      |
+|                                | For a Sprite with a texture of size 64x32px,      |
+|                                | **TEXTURE_PIXEL_SIZE** = :code:`vec2(1/64, 1/32)` |
++--------------------------------+---------------------------------------------------+
+| inout vec2 **VERTEX**          | Vertex, in image space.                           |
++--------------------------------+---------------------------------------------------+
+| inout vec2 **UV**              | Texture coordinates.                              |
++--------------------------------+---------------------------------------------------+
+| inout vec4 **COLOR**           | Color from vertex primitive.                      |
++--------------------------------+---------------------------------------------------+
+| inout float **POINT_SIZE**     | Point size for point drawing.                     |
++--------------------------------+---------------------------------------------------+
 
 
 Fragment built-ins
 Fragment built-ins
 ^^^^^^^^^^^^^^^^^^
 ^^^^^^^^^^^^^^^^^^
@@ -156,43 +156,53 @@ it to the ``NORMALMAP`` property. Godot will handle converting it for use in 2D
 
 
   NORMALMAP = texture(NORMAL_TEXTURE, UV).rgb;
   NORMALMAP = texture(NORMAL_TEXTURE, UV).rgb;
 
 
-+----------------------------------+----------------------------------------------------------------+
-| Built-in                         | Description                                                    |
-+==================================+================================================================+
-| 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.                   |
-+----------------------------------+----------------------------------------------------------------+
-| inout vec3 **NORMAL**            | Normal read from **NORMAL_TEXTURE**. Writable.                 |
-+----------------------------------+----------------------------------------------------------------+
-| out vec3 **NORMALMAP**           | Configures normal maps meant for 3D for use in 2D. If used,    |
-|                                  | overwrites **NORMAL**.                                         |
-+----------------------------------+----------------------------------------------------------------+
-| inout float **NORMALMAP_DEPTH**  | Normalmap depth for scaling.                                   |
-+----------------------------------+----------------------------------------------------------------+
-| in vec2 **UV**                   | UV from vertex function.                                       |
-+----------------------------------+----------------------------------------------------------------+
-| inout vec4 **COLOR**             | Color from vertex function and output fragment color. If       |
-|                                  | unused, will be set to **TEXTURE** color.                      |
-+----------------------------------+----------------------------------------------------------------+
-| in sampler2D **TEXTURE**         | Default 2D texture.                                            |
-+----------------------------------+----------------------------------------------------------------+
-| in sampler2D **NORMAL_TEXTURE**  | Default 2D normal texture.                                     |
-+----------------------------------+----------------------------------------------------------------+
-| in vec2 **TEXTURE_PIXEL_SIZE**   | Normalized pixel size of default 2D texture.                   |
-|                                  | For a Sprite with a texture of size 64x32px,                   |
-|                                  | **TEXTURE_PIXEL_SIZE** = :code:`vec2(1/64, 1/32)`              |
-+----------------------------------+----------------------------------------------------------------+
-| in vec2 **SCREEN_UV**            | Screen UV for use with **SCREEN_TEXTURE**.                     |
-+----------------------------------+----------------------------------------------------------------+
-| in vec2 **SCREEN_PIXEL_SIZE**    | Size of individual pixels. Equal to inverse of resolution.     |
-+----------------------------------+----------------------------------------------------------------+
-| in vec2 **POINT_COORD**          | Coordinate for drawing points.                                 |
-+----------------------------------+----------------------------------------------------------------+
-| in bool **AT_LIGHT_PASS**        | ``true`` if this is a light pass.                              |
-+----------------------------------+----------------------------------------------------------------+
-| in sampler2D **SCREEN_TEXTURE**  | Screen texture, mipmaps contain gaussian blurred versions.     |
-+----------------------------------+----------------------------------------------------------------+
++---------------------------------------------+---------------------------------------------------------------+
+| Built-in                                    | Description                                                   |
++---------------------------------------------+---------------------------------------------------------------+
+| 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 vec2 **UV**                              | UV from vertex function.                                      |
++---------------------------------------------+---------------------------------------------------------------+
+| in vec2 **SCREEN_UV**                       | Screen UV for use with **SCREEN_TEXTURE**.                    |
++---------------------------------------------+---------------------------------------------------------------+
+| in vec2 **SCREEN_PIXEL_SIZE**               | Size of individual pixels. Equal to inverse of resolution.    |
++---------------------------------------------+---------------------------------------------------------------+
+| in vec2 **POINT_COORD**                     | Coordinate for drawing points.                                |
++---------------------------------------------+---------------------------------------------------------------+
+| in bool **AT_LIGHT_PASS**                   | ``true`` if this is a light pass.                             |
++---------------------------------------------+---------------------------------------------------------------+
+| in sampler2D **TEXTURE**                    | Default 2D texture.                                           |
++---------------------------------------------+---------------------------------------------------------------+
+| in vec2 **TEXTURE_PIXEL_SIZE**              | Normalized pixel size of default 2D texture.                  |
+|                                             | For a Sprite with a texture of size 64x32px,                  |
+|                                             | **TEXTURE_PIXEL_SIZE** = :code`vec2(1/64, 1/32)`              |
++---------------------------------------------+---------------------------------------------------------------+
+| in sampler2D **SPECULAR_SHININESS_TEXTURE** |                                                               |
++---------------------------------------------+---------------------------------------------------------------+
+| in vec4 **SPECULAR_SHININESS**              |                                                               |
++---------------------------------------------+---------------------------------------------------------------+
+| in sampler2D **SCREEN_TEXTURE**             | Screen texture, mipmaps contain gaussian blurred versions.    |
++---------------------------------------------+---------------------------------------------------------------+
+| in sampler2D **NORMAL_TEXTURE**             | Default 2D normal texture.                                    |
++---------------------------------------------+---------------------------------------------------------------+
+| inout vec3 **NORMAL**                       | Normal read from **NORMAL_TEXTURE**. Writable.                |
++---------------------------------------------+---------------------------------------------------------------+
+| inout vec3 **NORMAL_MAP**                   | Configures normal maps meant for 3D for use in 2D. If used,   |
+|                                             | overrides **NORMAL**.                                         |
++---------------------------------------------+---------------------------------------------------------------+
+| inout float **NORMAL_MAP_DEPTH**            | Normalmap depth for scaling.                                  |
++---------------------------------------------+---------------------------------------------------------------+
+| inout vec2 **VERTEX**                       |                                                               |
++---------------------------------------------+---------------------------------------------------------------+
+| inout vec2 **SHADOW_VERTEX**                |                                                               |
++---------------------------------------------+---------------------------------------------------------------+
+| inout vec3 **LIGHT_VERTEX**                 |                                                               |
++---------------------------------------------+---------------------------------------------------------------+
+| inout vec4 **COLOR**                        | Color from vertex function and output fragment color. If      |
+|                                             | unused, will be set to **TEXTURE** color.                     |
++---------------------------------------------+---------------------------------------------------------------+
 
 
 Light built-ins
 Light built-ins
 ^^^^^^^^^^^^^^^
 ^^^^^^^^^^^^^^^
@@ -205,45 +215,41 @@ that object; this can be useful when you only want the object visible where it i
 
 
 When the shader is on a light pass, the ``AT_LIGHT_PASS`` variable will be ``true``.
 When the shader is on a light pass, the ``AT_LIGHT_PASS`` variable will be ``true``.
 
 
-+-------------------------------------+-------------------------------------------------------------------------------+
-| Built-in                            | Description                                                                   |
-+=====================================+===============================================================================+
-| 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 vec3 **NORMAL**                  | Input Normal. Although this value is passed in,                               |
-|                                     | **normal calculation still happens outside of this function**.                |
-+-------------------------------------+-------------------------------------------------------------------------------+
-| in vec2 **UV**                      | UV from vertex function, equivalent to the UV in the fragment function.       |
-+-------------------------------------+-------------------------------------------------------------------------------+
-| in vec4 **COLOR**                   | Input Color.                                                                  |
-|                                     | This is the output of the fragment function with final modulation applied.    |
-+-------------------------------------+-------------------------------------------------------------------------------+
-| sampler2D **TEXTURE**               | Current texture in use for CanvasItem.                                        |
-+-------------------------------------+-------------------------------------------------------------------------------+
-| in vec2 **TEXTURE_PIXEL_SIZE**      | Normalized pixel size of default 2D texture.                                  |
-|                                     | For a Sprite with a texture of size 64x32px,                                  |
-|                                     | **TEXTURE_PIXEL_SIZE** = :code:`vec2(1/64, 1/32)`                             |
-+-------------------------------------+-------------------------------------------------------------------------------+
-| in vec2 **SCREEN_UV**               | **SCREEN_TEXTURE** Coordinate (for using with screen texture).                |
-+-------------------------------------+-------------------------------------------------------------------------------+
-| in vec2 **POINT_COORD**             | UV for Point Sprite.                                                          |
-+-------------------------------------+-------------------------------------------------------------------------------+
-| inout vec2 **LIGHT_VEC**            | Vector from light to fragment in local coordinates. It can be modified to     |
-|                                     | alter illumination direction when normal maps are used.                       |
-+-------------------------------------+-------------------------------------------------------------------------------+
-| inout vec2 **SHADOW_VEC**           | Vector from light to fragment in local coordinates. It can be modified to     |
-|                                     | alter shadow computation.                                                     |
-+-------------------------------------+-------------------------------------------------------------------------------+
-| inout float **LIGHT_HEIGHT**        | Height of Light. Only effective when normals are used.                        |
-+-------------------------------------+-------------------------------------------------------------------------------+
-| inout vec4 **LIGHT_COLOR**          | Color of Light.                                                               |
-+-------------------------------------+-------------------------------------------------------------------------------+
-| in vec2 **LIGHT_UV**                | UV for Light texture.                                                         |
-+-------------------------------------+-------------------------------------------------------------------------------+
-| out vec4 **SHADOW_COLOR**           | Shadow Color of Light.                                                        |
-+-------------------------------------+-------------------------------------------------------------------------------+
-| inout vec4 **LIGHT**                | Value from the Light texture and output color. Can be modified. If not used,  |
-|                                     | the light function is ignored.                                                |
-+-------------------------------------+-------------------------------------------------------------------------------+
++--------------------------------+------------------------------------------------------------------------------+
+| Built-in                       | Description                                                                  |
++--------------------------------+------------------------------------------------------------------------------+
+| 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 vec3 **NORMAL**             | Input Normal. Although this value is passed in,                              |
+|                                | **normal calculation still happens outside of this function**.               |
++--------------------------------+------------------------------------------------------------------------------+
+| in vec4 **COLOR**              | Input Color.                                                                 |
+|                                | This is the output of the fragment function with final modulation applied.   |
++--------------------------------+------------------------------------------------------------------------------+
+| in vec2 **UV**                 | UV from vertex function, equivalent to the UV in the fragment function.      |
++--------------------------------+------------------------------------------------------------------------------+
+| in vec4 **SPECULAR_SHININESS** |                                                                              |
++--------------------------------+------------------------------------------------------------------------------+
+| in sampler2D **TEXTURE**       | Current texture in use for CanvasItem.                                       |
++--------------------------------+------------------------------------------------------------------------------+
+| in vec2 **TEXTURE_PIXEL_SIZE** | Normalized pixel size of default 2D texture.                                 |
+|                                | For a Sprite with a texture of size 64x32px,                                 |
+|                                | **TEXTURE_PIXEL_SIZE** = :code:`vec2(1/64, 1/32)`                            |
++--------------------------------+------------------------------------------------------------------------------+
+| in vec2 **SCREEN_UV**          | **SCREEN_TEXTURE** Coordinate (for using with screen texture).               |
++--------------------------------+------------------------------------------------------------------------------+
+| in vec2 **POINT_COORD**        | UV for Point Sprite.                                                         |
++--------------------------------+------------------------------------------------------------------------------+
+| in vec4 **LIGHT_COLOR**        | Color of Light.                                                              |
++--------------------------------+------------------------------------------------------------------------------+
+| in vec3 **LIGHT_POSITION**     | Position of Light.                                                           |
++--------------------------------+------------------------------------------------------------------------------+
+| in vec3 **LIGHT_VERTEX**       |                                                                              |
++--------------------------------+------------------------------------------------------------------------------+
+| inout vec4 **LIGHT**           | Value from the Light texture and output color. Can be modified. If not used, |
+|                                | the light function is ignored.                                               |
++--------------------------------+------------------------------------------------------------------------------+
+| inout vec4 **SHADOW_MODULATE** |                                                                              |
++--------------------------------+------------------------------------------------------------------------------+

+ 92 - 31
tutorials/shaders/shader_reference/particle_shader.rst

@@ -55,38 +55,99 @@ Global built-ins are available everywhere, including custom functions.
 | in float **TIME** | Global time, in seconds. |
 | in float **TIME** | Global time, in seconds. |
 +-------------------+--------------------------+
 +-------------------+--------------------------+
 
 
-Vertex built-ins
-^^^^^^^^^^^^^^^^
+Start built-ins
+^^^^^^^^^^^^^^^
 
 
 In order to use the ``COLOR`` variable in a StandardMaterial3D, set ``use_vertex_as_albedo``
 In order to use the ``COLOR`` variable in a StandardMaterial3D, set ``use_vertex_as_albedo``
 to ``true``. In a ShaderMaterial, access it with the ``COLOR`` variable.
 to ``true``. In a ShaderMaterial, access it with the ``COLOR`` variable.
 
 
-+---------------------------------+-------------------------------------------------------------------------------------+
-| Built-in                        | Description                                                                         |
-+=================================+=====================================================================================+
-| inout vec4 **COLOR**            | Particle color, can be written to and accessed in mesh's vertex function.           |
-+---------------------------------+-------------------------------------------------------------------------------------+
-| inout vec3 **VELOCITY**         | Particle velocity, can be modified.                                                 |
-+---------------------------------+-------------------------------------------------------------------------------------+
-| out float **MASS**              | Particle mass, use for attractors (not implemented in 3.1).                         |
-+---------------------------------+-------------------------------------------------------------------------------------+
-| inout bool **ACTIVE**           | ``true`` when Particle is active, can be set to ``false``.                          |
-+---------------------------------+-------------------------------------------------------------------------------------+
-| in bool **RESTART**             | ``true`` when particle must restart (lifetime cycled).                              |
-+---------------------------------+-------------------------------------------------------------------------------------+
-| inout vec4 **CUSTOM**           | Custom particle data. Accessible from shader of mesh as **INSTANCE_CUSTOM**.        |
-+---------------------------------+-------------------------------------------------------------------------------------+
-| inout mat4 **TRANSFORM**        | Particle transform.                                                                 |
-+---------------------------------+-------------------------------------------------------------------------------------+
-| in float **LIFETIME**           | Particle lifetime.                                                                  |
-+---------------------------------+-------------------------------------------------------------------------------------+
-| in float **DELTA**              | Delta process time.                                                                 |
-+---------------------------------+-------------------------------------------------------------------------------------+
-| in uint **NUMBER**              | Unique number since emission start.                                                 |
-+---------------------------------+-------------------------------------------------------------------------------------+
-| in int **INDEX**                | Particle index (from total particles).                                              |
-+---------------------------------+-------------------------------------------------------------------------------------+
-| in mat4 **EMISSION_TRANSFORM**  | Emitter transform (used for non-local systems).                                     |
-+---------------------------------+-------------------------------------------------------------------------------------+
-| in uint **RANDOM_SEED**         | Random seed used as base for random.                                                |
-+---------------------------------+-------------------------------------------------------------------------------------+
++--------------------------------+------------------------------------------------------------------------------+
+| Built-in                       | Description                                                                  |
++--------------------------------+------------------------------------------------------------------------------+
+| in float **LIFETIME**          | Particle lifetime.                                                           |
++--------------------------------+------------------------------------------------------------------------------+
+| in float **DELTA**             | Delta process time.                                                          |
++--------------------------------+------------------------------------------------------------------------------+
+| in uint **NUMBER**             | Unique number since emission start.                                          |
++--------------------------------+------------------------------------------------------------------------------+
+| in uint **INDEX**              | Particle index (from total particles).                                       |
++--------------------------------+------------------------------------------------------------------------------+
+| in mat4 **EMISSION_TRANSFORM** | Emitter transform (used for non-local systems).                              |
++--------------------------------+------------------------------------------------------------------------------+
+| in uint **RANDOM_SEED**        | Random seed used as base for random.                                         |
++--------------------------------+------------------------------------------------------------------------------+
+| in bool **RESTART**            | ``true`` when particle must restart (lifetime cycled).                       |
++--------------------------------+------------------------------------------------------------------------------+
+| in bool **RESTART_POSITION**   |                                                                              |
++--------------------------------+------------------------------------------------------------------------------+
+| in bool **RESTART_ROT_SCALE**  |                                                                              |
++--------------------------------+------------------------------------------------------------------------------+
+| in bool **RESTART_VELOCITY**   |                                                                              |
++--------------------------------+------------------------------------------------------------------------------+
+| in bool **RESTART_COLOR**      |                                                                              |
++--------------------------------+------------------------------------------------------------------------------+
+| in bool **RESTART_CUSTOM**     |                                                                              |
++--------------------------------+------------------------------------------------------------------------------+
+| inout bool **ACTIVE**          | ``true`` when Particle is active, can be set ``false``.                      |
++--------------------------------+------------------------------------------------------------------------------+
+| inout vec4 **COLOR**           | Particle color, can be written to and accessed in mesh's vertex function.    |
++--------------------------------+------------------------------------------------------------------------------+
+| inout vec3 **VELOCITY**        | Particle velocity, can be modified.                                          |
++--------------------------------+------------------------------------------------------------------------------+
+| inout mat4 **TRANSFORM**       | Particle transform.                                                          |
++--------------------------------+------------------------------------------------------------------------------+
+| inout vec4 **CUSTOM**          | Custom particle data. Accessible from shader of mesh as **INSTANCE_CUSTOM**. |
++--------------------------------+------------------------------------------------------------------------------+
+| inout float **MASS**           | Particle mass, use for attractors (not implemented in 3.1).                  |
++--------------------------------+------------------------------------------------------------------------------+
+
+Process built-ins
+^^^^^^^^^^^^^^^^^
+
++---------------------------------+------------------------------------------------------------------------------+
+| Built-in                        | Description                                                                  |
++---------------------------------+------------------------------------------------------------------------------+
+| in float **LIFETIME**           | Particle lifetime.                                                           |
++---------------------------------+------------------------------------------------------------------------------+
+| in float **DELTA**              | Delta process time.                                                          |
++---------------------------------+------------------------------------------------------------------------------+
+| in uint **NUMBER**              | Unique number since emission start.                                          |
++---------------------------------+------------------------------------------------------------------------------+
+| in uint **INDEX**               | Particle index (from total particles).                                       |
++---------------------------------+------------------------------------------------------------------------------+
+| in mat4 **EMISSION_TRANSFORM**  | Emitter transform (used for non-local systems).                              |
++---------------------------------+------------------------------------------------------------------------------+
+| in uint **RANDOM_SEED**         | Random seed used as base for random.                                         |
++---------------------------------+------------------------------------------------------------------------------+
+| in bool **RESTART**             | ``true`` when particle must restart (lifetime cycled).                       |
++---------------------------------+------------------------------------------------------------------------------+
+| in uint **FLAG_EMIT_POSITION**  |                                                                              |
++---------------------------------+------------------------------------------------------------------------------+
+| in uint **FLAG_EMIT_ROT_SCALE** |                                                                              |
++---------------------------------+------------------------------------------------------------------------------+
+| in uint **FLAG_EMIT_VELOCITY**  |                                                                              |
++---------------------------------+------------------------------------------------------------------------------+
+| in uint **FLAG_EMIT_COLOR**     |                                                                              |
++---------------------------------+------------------------------------------------------------------------------+
+| in uint **FLAG_EMIT_CUSTOM**    |                                                                              |
++---------------------------------+------------------------------------------------------------------------------+
+| in bool **COLLIDED**            | ``true`` when particle is collided with particle collider.                   |
++---------------------------------+------------------------------------------------------------------------------+
+| in vec3 **COLLISION_NORMAL**    |                                                                              |
++---------------------------------+------------------------------------------------------------------------------+
+| in float **COLLISION_DEPTH**    |                                                                              |
++---------------------------------+------------------------------------------------------------------------------+
+| in vec3 **ATTRACTOR_FORCE**     |                                                                              |
++---------------------------------+------------------------------------------------------------------------------+
+| inout bool **ACTIVE**           | ``true`` when Particle is active, can be set ``false``.                      |
++---------------------------------+------------------------------------------------------------------------------+
+| inout vec4 **COLOR**            | Particle color, can be written to and accessed in mesh's vertex function.    |
++---------------------------------+------------------------------------------------------------------------------+
+| inout vec3 **VELOCITY**         | Particle velocity, can be modified.                                          |
++---------------------------------+------------------------------------------------------------------------------+
+| inout mat4 **TRANSFORM**        | Particle transform.                                                          |
++---------------------------------+------------------------------------------------------------------------------+
+| inout vec4 **CUSTOM**           | Custom particle data. Accessible from shader of mesh as **INSTANCE_CUSTOM**. |
++---------------------------------+------------------------------------------------------------------------------+
+| inout float **MASS**            | Particle mass, use for attractors (not implemented in 3.1).                  |
++---------------------------------+------------------------------------------------------------------------------+

+ 22 - 20
tutorials/shaders/shader_reference/sky_shader.rst

@@ -141,23 +141,25 @@ There are 4 ``LIGHTX`` lights, accessed as ``LIGHT0``, ``LIGHT1``, ``LIGHT2``, a
 | in float **LIGHTX_SIZE**        | Angular diameter of ``LIGHTX`` in the sky. Expressed in degrees. For reference, the sun from earth is about 0.5 degrees. |
 | in float **LIGHTX_SIZE**        | Angular diameter of ``LIGHTX`` in the sky. Expressed in degrees. For reference, the sun from earth is about 0.5 degrees. |
 +---------------------------------+--------------------------------------------------------------------------------------------------------------------------+
 +---------------------------------+--------------------------------------------------------------------------------------------------------------------------+
 
 
-Fragment built-ins
-^^^^^^^^^^^^^^^^^^
-
-+---------------------------------+-------------------------------------------------------------------------------------------------+
-| Built-in                        | Description                                                                                     |
-+=================================+=================================================================================================+
-| out vec3 **COLOR**              | Output color                                                                                    |
-+---------------------------------+-------------------------------------------------------------------------------------------------+
-| out float **ALPHA**             | Output alpha value, can only be used in subpasses.                                              |
-+---------------------------------+-------------------------------------------------------------------------------------------------+
-| in vec3 **EYEDIR**              | Normalized direction of current pixel. Use this as your basic direction for procedural effects. |
-+---------------------------------+-------------------------------------------------------------------------------------------------+
-| in vec2 **SCREEN_UV**           | Screen UV coordinate for current pixel. Used to map a texture to the full screen.               |
-+---------------------------------+-------------------------------------------------------------------------------------------------+
-| in vec2 **SKY_COORDS**          | Sphere UV. Used to map a panorama texture to the sky.                                           |
-+---------------------------------+-------------------------------------------------------------------------------------------------+
-| in vec4 **HALF_RES_COLOR**      | Color value of corresponding pixel from half resolution pass. Uses linear filter.               |
-+---------------------------------+-------------------------------------------------------------------------------------------------+
-| in vec4 **QUARTER_RES_COLOR**   | Color value of corresponding pixel from quarter resolution pass. Uses linear filter.            |
-+---------------------------------+-------------------------------------------------------------------------------------------------+
+Sky built-ins
+^^^^^^^^^^^^^
+
++-------------------------------+-------------------------------------------------------------------------------------------------+
+| Built-in                      | Description                                                                                     |
++-------------------------------+-------------------------------------------------------------------------------------------------+
+| in vec3 **EYEDIR**            | Normalized direction of current pixel. Use this as your basic direction for procedural effects. |
++-------------------------------+-------------------------------------------------------------------------------------------------+
+| in vec2 **SCREEN_UV**         | Screen UV coordinate for current pixel. Used to map a texture to the full screen.               |
++-------------------------------+-------------------------------------------------------------------------------------------------+
+| in vec2 **SKY_COORDS**        | Sphere UV. Used to map a panorama texture to the sky.                                           |
++-------------------------------+-------------------------------------------------------------------------------------------------+
+| in vec4 **HALF_RES_COLOR**    | Color value of corresponding pixel from half resolution pass. Uses linear filter.               |
++-------------------------------+-------------------------------------------------------------------------------------------------+
+| in vec4 **QUARTER_RES_COLOR** | Color value of corresponding pixel from quarter resolution pass. Uses linear filter.            |
++-------------------------------+-------------------------------------------------------------------------------------------------+
+| inout vec3 **COLOR**          | Output color.                                                                                   |
++-------------------------------+-------------------------------------------------------------------------------------------------+
+| inout float **ALPHA**         | Output alpha value, can only be used in subpasses.                                              |
++-------------------------------+-------------------------------------------------------------------------------------------------+
+| inout vec4 **FOG**            |                                                                                                 |
++-------------------------------+-------------------------------------------------------------------------------------------------+

+ 224 - 190
tutorials/shaders/shader_reference/spatial_shader.rst

@@ -135,50 +135,66 @@ is usually:
 This allows you to easily adjust the shader to a particle system using default particles material. When writing a custom particle
 This allows you to easily adjust the shader to a particle system using default particles material. When writing a custom particle
 shader, this value can be used as desired.
 shader, this value can be used as desired.
 
 
-+--------------------------------------+-------------------------------------------------------+
-| Built-in                             | Description                                           |
-+======================================+=======================================================+
-| in vec2 **VIEWPORT_SIZE**            | Size of viewport (in pixels).                         |
-+--------------------------------------+-------------------------------------------------------+
-| inout mat4 **WORLD_MATRIX**          | Model space to world space transform.                 |
-+--------------------------------------+-------------------------------------------------------+
-| in mat4 **INV_CAMERA_MATRIX**        | World space to view space transform.                  |
-+--------------------------------------+-------------------------------------------------------+
-| inout mat4 **PROJECTION_MATRIX**     | View space to clip space transform.                   |
-+--------------------------------------+-------------------------------------------------------+
-| in mat4 **CAMERA_MATRIX**            | View space to world space transform.                  |
-+--------------------------------------+-------------------------------------------------------+
-| inout mat4 **MODELVIEW_MATRIX**      | Model space to view space transform (use if possible).|
-+--------------------------------------+-------------------------------------------------------+
-| inout mat4 **INV_PROJECTION_MATRIX** | Clip space to view space transform.                   |
-+--------------------------------------+-------------------------------------------------------+
-| inout vec3 **VERTEX**                | Vertex in local coordinates.                          |
-+--------------------------------------+-------------------------------------------------------+
-| out vec4  **POSITION**               | If written to, overrides final vertex position.       |
-+--------------------------------------+-------------------------------------------------------+
-| inout vec3 **NORMAL**                | Normal in local coordinates.                          |
-+--------------------------------------+-------------------------------------------------------+
-| inout vec3 **TANGENT**               | Tangent in local coordinates.                         |
-+--------------------------------------+-------------------------------------------------------+
-| inout vec3 **BINORMAL**              | Binormal in local coordinates.                        |
-+--------------------------------------+-------------------------------------------------------+
-| out float **ROUGHNESS**              | Roughness for vertex lighting.                        |
-+--------------------------------------+-------------------------------------------------------+
-| inout vec2 **UV**                    | UV main channel.                                      |
-+--------------------------------------+-------------------------------------------------------+
-| inout vec2 **UV2**                   | UV secondary channel.                                 |
-+--------------------------------------+-------------------------------------------------------+
-| in bool **OUTPUT_IS_SRGB**           | ``true`` when calculations happen in sRGB color space |
-|                                      | (``true`` in GLES2, ``false`` in GLES3).              |
-+--------------------------------------+-------------------------------------------------------+
-| inout vec4 **COLOR**                 | Color from vertices.                                  |
-+--------------------------------------+-------------------------------------------------------+
-| inout float **POINT_SIZE**           | Point size for point rendering.                       |
-+--------------------------------------+-------------------------------------------------------+
-| in int **INSTANCE_ID**               | Instance ID for instancing.                           |
-+--------------------------------------+-------------------------------------------------------+
-| in vec4 **INSTANCE_CUSTOM**          | Instance custom data (for particles, mostly).         |
-+--------------------------------------+-------------------------------------------------------+
++----------------------------------------+--------------------------------------------------------+
+| Built-in                               | Description                                            |
++----------------------------------------+--------------------------------------------------------+
+| in vec2 **VIEWPORT_SIZE**              | Size of viewport (in pixels).                          |
++----------------------------------------+--------------------------------------------------------+
+| in mat4 **INV_CAMERA_MATRIX**          | World space to view space transform.                   |
++----------------------------------------+--------------------------------------------------------+
+| in mat4 **CAMERA_MATRIX**              | View space to world space transform.                   |
++----------------------------------------+--------------------------------------------------------+
+| in mat4 **INV_PROJECTION_MATRIX**      | Clip space to view space transform.                    |
++----------------------------------------+--------------------------------------------------------+
+| in bool **OUTPUT_IS_SRGB**             | ``true`` when calculations happen in sRGB color space  |
+|                                        | (``true`` in GLES2, ``false`` in GLES3).               |
++----------------------------------------+--------------------------------------------------------+
+| in int **INSTANCE_ID**                 | Instance ID for instancing.                            |
++----------------------------------------+--------------------------------------------------------+
+| in vec4 **INSTANCE_CUSTOM**            | Instance custom data (for particles, mostly).          |
++----------------------------------------+--------------------------------------------------------+
+| inout vec3 **VERTEX**                  | Vertex in local coordinates.                           |
++----------------------------------------+--------------------------------------------------------+
+| inout vec3 **NORMAL**                  | Normal in local coordinates.                           |
++----------------------------------------+--------------------------------------------------------+
+| inout vec3 **TANGENT**                 | Tangent in local coordinates.                          |
++----------------------------------------+--------------------------------------------------------+
+| inout vec3 **BINORMAL**                | Binormal in local coordinates.                         |
++----------------------------------------+--------------------------------------------------------+
+| inout vec4 **POSITION**                | If written to, overrides final vertex position.        |
++----------------------------------------+--------------------------------------------------------+
+| inout vec2 **UV**                      | UV main channel.                                       |
++----------------------------------------+--------------------------------------------------------+
+| inout vec2 **UV2**                     | UV secondary channel.                                  |
++----------------------------------------+--------------------------------------------------------+
+| inout vec4 **COLOR**                   | Color from vertices.                                   |
++----------------------------------------+--------------------------------------------------------+
+| inout float **ROUGHNESS**              | Roughness for vertex lighting.                         |
++----------------------------------------+--------------------------------------------------------+
+| inout float **POINT_SIZE**             | Point size for point rendering.                        |
++----------------------------------------+--------------------------------------------------------+
+| inout mat4 **MODELVIEW_MATRIX**        | Model space to view space transform (use if possible). |
++----------------------------------------+--------------------------------------------------------+
+| inout mat3 **MODELVIEW_NORMAL_MATRIX** |                                                        |
++----------------------------------------+--------------------------------------------------------+
+| inout mat4 **WORLD_MATRIX**            | Model space to world space transform.                  |
++----------------------------------------+--------------------------------------------------------+
+| inout mat3 **WORLD_NORMAL_MATRIX**     |                                                        |
++----------------------------------------+--------------------------------------------------------+
+| inout mat4 **PROJECTION_MATRIX**       | View space to clip space transform.                    |
++----------------------------------------+--------------------------------------------------------+
+| inout uvec4 **BONE_INDICES**           |                                                        |
++----------------------------------------+--------------------------------------------------------+
+| inout vec4 **BONE_WEIGHTS**            |                                                        |
++----------------------------------------+--------------------------------------------------------+
+| inout vec4 **CUSTOM0**                 |                                                        |
++----------------------------------------+--------------------------------------------------------+
+| inout vec4 **CUSTOM1**                 |                                                        |
++----------------------------------------+--------------------------------------------------------+
+| inout vec4 **CUSTOM2**                 |                                                        |
++----------------------------------------+--------------------------------------------------------+
+| inout vec4 **CUSTOM3**                 |                                                        |
++----------------------------------------+--------------------------------------------------------+
 
 
 Fragment built-ins
 Fragment built-ins
 ^^^^^^^^^^^^^^^^^^
 ^^^^^^^^^^^^^^^^^^
@@ -187,98 +203,116 @@ 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
 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.
 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 mat4 **WORLD_MATRIX**          | Model space to world space transform.                                                            |
-+-----------------------------------+--------------------------------------------------------------------------------------------------+
-| 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 vec3 **VIEW**                  | Vector from camera to fragment position (in view space).                                         |
-+-----------------------------------+--------------------------------------------------------------------------------------------------+
-| in bool **FRONT_FACING**          | ``true`` if current face is front face.                                                          |
-+-----------------------------------+--------------------------------------------------------------------------------------------------+
-| 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 **NORMALMAP**            | Set normal here if reading normal from a texture instead of NORMAL.                              |
-+-----------------------------------+--------------------------------------------------------------------------------------------------+
-| out float **NORMALMAP_DEPTH**     | Depth from variable above. Defaults to 1.0.                                                      |
-+-----------------------------------+--------------------------------------------------------------------------------------------------+
-| in vec2 **UV**                    | UV that comes from vertex function.                                                              |
-+-----------------------------------+--------------------------------------------------------------------------------------------------+
-| in vec2 **UV2**                   | UV2 that comes from vertex function.                                                             |
-+-----------------------------------+--------------------------------------------------------------------------------------------------+
-| in bool **OUTPUT_IS_SRGB**        | ``true`` when calculations happen in sRGB color space (``true`` in GLES2, ``false`` in GLES3).   |
-+-----------------------------------+--------------------------------------------------------------------------------------------------+
-| in vec4 **COLOR**                 | COLOR that comes from vertex function.                                                           |
-+-----------------------------------+--------------------------------------------------------------------------------------------------+
-| 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**       | If written to, values below a certain amount of alpha are discarded.                             |
-+-----------------------------------+--------------------------------------------------------------------------------------------------+
-| 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 vec3 **TRANSMISSION**         | Transmission mask (default 0,0,0). Allows light to pass through object. Only applied if used.    |
-+-----------------------------------+--------------------------------------------------------------------------------------------------+
-| out vec3 **EMISSION**             | Emission color (can go over 1,1,1 for HDR).                                                      |
-+-----------------------------------+--------------------------------------------------------------------------------------------------+
-| 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).                                                    |
-+-----------------------------------+--------------------------------------------------------------------------------------------------+
-| sampler2D **SCREEN_TEXTURE**      | Built-in Texture for reading from the screen. Mipmaps contain increasingly blurred copies.       |
-+-----------------------------------+--------------------------------------------------------------------------------------------------+
-| 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).                                                                       |
-+-----------------------------------+--------------------------------------------------------------------------------------------------+
-| in vec2 **SCREEN_UV**             | Screen UV coordinate for current pixel.                                                          |
-+-----------------------------------+--------------------------------------------------------------------------------------------------+
-| in vec2 **POINT_COORD**           | Point Coordinate for drawing points with POINT_SIZE.                                             |
-+-----------------------------------+--------------------------------------------------------------------------------------------------+
-| 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 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.                                                          |
++-------------------------------------------+--------------------------------------------------------------------------------------------------+
+| in sampler2D **NORMAL_ROUGHNESS_TEXTURE** |                                                                                                  |
++-------------------------------------------+--------------------------------------------------------------------------------------------------+
+| in sampler2D **DEPTH_TEXTURE**            | Built-in Texture for reading depth from the screen. Must convert to linear using INV_PROJECTION. |
++-------------------------------------------+--------------------------------------------------------------------------------------------------+
+| inout 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.                                                        |
++-------------------------------------------+--------------------------------------------------------------------------------------------------+
+| inout vec3 **NORMAL_MAP**                 | Set normal here if reading normal from a texture instead of NORMAL.                              |
++-------------------------------------------+--------------------------------------------------------------------------------------------------+
+| inout float **NORMAL_MAP_DEPTH**          | Depth from variable above. Defaults to 1.0.                                                      |
++-------------------------------------------+--------------------------------------------------------------------------------------------------+
+| inout vec3 **ALBEDO**                     | Albedo (default white).                                                                          |
++-------------------------------------------+--------------------------------------------------------------------------------------------------+
+| inout float **ALPHA**                     | Alpha (0..1); if written to, the material will go to the transparent pipeline.                   |
++-------------------------------------------+--------------------------------------------------------------------------------------------------+
+| inout float **ALPHA_SCISSOR_THRESHOLD**   | If written to, values below a certain amount of alpha are discarded.                             |
++-------------------------------------------+--------------------------------------------------------------------------------------------------+
+| inout float **ALPHA_HASH_SCALE**          |                                                                                                  |
++-------------------------------------------+--------------------------------------------------------------------------------------------------+
+| inout float **ALPHA_ANTIALIASING_EDGE**   |                                                                                                  |
++-------------------------------------------+--------------------------------------------------------------------------------------------------+
+| inout vec2 **ALPHA_TEXTURE_COORDINATE**   |                                                                                                  |
++-------------------------------------------+--------------------------------------------------------------------------------------------------+
+| inout float **METALLIC**                  | Metallic (0..1).                                                                                 |
++-------------------------------------------+--------------------------------------------------------------------------------------------------+
+| inout float **SPECULAR**                  | Specular. Defaults to 0.5, best not to modify unless you want to change IOR.                     |
++-------------------------------------------+--------------------------------------------------------------------------------------------------+
+| inout float **ROUGHNESS**                 | Roughness (0..1).                                                                                |
++-------------------------------------------+--------------------------------------------------------------------------------------------------+
+| inout float **RIM**                       | Rim (0..1). If used, Godot calculates rim lighting.                                              |
++-------------------------------------------+--------------------------------------------------------------------------------------------------+
+| inout float **RIM_TINT**                  | Rim Tint, goes from 0 (white) to 1 (albedo). If used, Godot calculates rim lighting.             |
++-------------------------------------------+--------------------------------------------------------------------------------------------------+
+| inout float **CLEARCOAT**                 | Small added specular blob. If used, Godot calculates Clearcoat.                                  |
++-------------------------------------------+--------------------------------------------------------------------------------------------------+
+| inout float **CLEARCOAT_GLOSS**           | Gloss of Clearcoat. If used, Godot calculates Clearcoat.                                         |
++-------------------------------------------+--------------------------------------------------------------------------------------------------+
+| inout float **ANISOTROPY**                | For distorting the specular blob according to tangent space.                                     |
++-------------------------------------------+--------------------------------------------------------------------------------------------------+
+| inout vec2 **ANISOTROPY_FLOW**            | Distortion direction, use with flowmaps.                                                         |
++-------------------------------------------+--------------------------------------------------------------------------------------------------+
+| inout float **SSS_STRENGTH**              | Strength of Subsurface Scattering. If used, Subsurface Scattering will be applied to object.     |
++-------------------------------------------+--------------------------------------------------------------------------------------------------+
+| inout vec4 **SSS_TRANSMITTANCE_COLOR**    |                                                                                                  |
++-------------------------------------------+--------------------------------------------------------------------------------------------------+
+| inout float **SSS_TRANSMITTANCE_DEPTH**   |                                                                                                  |
++-------------------------------------------+--------------------------------------------------------------------------------------------------+
+| inout float **SSS_TRANSMITTANCE_CURVE**   |                                                                                                  |
++-------------------------------------------+--------------------------------------------------------------------------------------------------+
+| inout float **SSS_TRANSMITTANCE_BOOST**   |                                                                                                  |
++-------------------------------------------+--------------------------------------------------------------------------------------------------+
+| inout vec3 **BACKLIGHT**                  |                                                                                                  |
++-------------------------------------------+--------------------------------------------------------------------------------------------------+
+| inout float **AO**                        | Strength of Ambient Occlusion. For use with pre-baked AO.                                        |
++-------------------------------------------+--------------------------------------------------------------------------------------------------+
+| inout float **AO_LIGHT_AFFECT**           | How much AO affects lights (0..1; default 0).                                                    |
++-------------------------------------------+--------------------------------------------------------------------------------------------------+
+| inout vec3 **EMISSION**                   | Emission color (can go over 1,1,1 for HDR).                                                      |
++-------------------------------------------+--------------------------------------------------------------------------------------------------+
+| inout vec4 **FOG**                        | If written to, blends final pixel color with FOG.rgb based on FOG.a.                             |
++-------------------------------------------+--------------------------------------------------------------------------------------------------+
+| inout vec4 **RADIANCE**                   | If written to, blends environment map radiance with RADIANCE.rgb based on RADIANCE.a.            |
++-------------------------------------------+--------------------------------------------------------------------------------------------------+
+| inout vec4 **IRRADIANCE**                 | If written to, blends environment map IRRADIANCE with IRRADIANCE.rgb based on IRRADIANCE.a.      |
++-------------------------------------------+--------------------------------------------------------------------------------------------------+
 
 
 Light built-ins
 Light built-ins
 ^^^^^^^^^^^^^^^
 ^^^^^^^^^^^^^^^
@@ -311,57 +345,57 @@ If you want the lights to add together, add the light contribution to ``DIFFUSE_
     **Rendering > Quality > Shading > Force Vertex Shading** is enabled in the
     **Rendering > Quality > Shading > Force Vertex Shading** is enabled in the
     Project Settings. (It's enabled by default on mobile platforms.)
     Project Settings. (It's enabled by default on mobile platforms.)
 
 
-+-----------------------------------+-----------------------------------------------------+
-| Built-in                          | Description                                         |
-+===================================+=====================================================+
-| in float **TIME**                 | Elapsed total time in seconds.                      |
-+-----------------------------------+-----------------------------------------------------+
-| 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 mat4 **WORLD_MATRIX**          | Model space to world space transform.               |
-+-----------------------------------+-----------------------------------------------------+
-| 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 **NORMAL**                | Normal vector, in view space.                       |
-+-----------------------------------+-----------------------------------------------------+
-| in vec2 **UV**                    | UV that comes from vertex function.                 |
-+-----------------------------------+-----------------------------------------------------+
-| in vec2 **UV2**                   | UV2 that comes from vertex function.                |
-+-----------------------------------+-----------------------------------------------------+
-| in vec3 **VIEW**                  | View vector, in view space.                         |
-+-----------------------------------+-----------------------------------------------------+
-| in vec3 **LIGHT**                 | Light Vector, in view space.                        |
-+-----------------------------------+-----------------------------------------------------+
-| in vec3 **ATTENUATION**           | Attenuation based on distance or shadow.            |
-+-----------------------------------+-----------------------------------------------------+
-| in bool **OUTPUT_IS_SRGB**        | ``true`` when calculations happen in sRGB color     |
-|                                   | space (``true`` in GLES2, ``false`` in GLES3).      |
-+-----------------------------------+-----------------------------------------------------+
-| in vec3 **ALBEDO**                | Base albedo.                                        |
-+-----------------------------------+-----------------------------------------------------+
-| in vec3 **LIGHT_COLOR**           | Color of light multiplied by energy.                |
-+-----------------------------------+-----------------------------------------------------+
-| out float **ALPHA**               | Alpha (0..1); if written to, the material will go   |
-|                                   | to the transparent pipeline.                        |
-+-----------------------------------+-----------------------------------------------------+
-| in float **METALLIC**             | Metallic.                                           |
-+-----------------------------------+-----------------------------------------------------+
-| in float **ROUGHNESS**            | Roughness.                                          |
-+-----------------------------------+-----------------------------------------------------+
-| in vec3 **TRANSMISSION**          | Transmission mask from fragment function.           |
-+-----------------------------------+-----------------------------------------------------+
-| out vec3 **DIFFUSE_LIGHT**        | Diffuse light result.                               |
-+-----------------------------------+-----------------------------------------------------+
-| out vec3 **SPECULAR_LIGHT**       | Specular light result.                              |
-+-----------------------------------+-----------------------------------------------------+
++-----------------------------------+----------------------------------------------------+
+| 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 mat4 **WORLD_MATRIX**          | Model space to world space transform.              |
++-----------------------------------+----------------------------------------------------+
+| in mat4 **CAMERA_MATRIX**         | View space to world space transform.               |
++-----------------------------------+----------------------------------------------------+
+| in mat4 **INV_CAMERA_MATRIX**     | World space to view 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 **NORMAL**                | Normal vector, in view space.                      |
++-----------------------------------+----------------------------------------------------+
+| in vec2 **UV**                    | UV that comes from vertex function.                |
++-----------------------------------+----------------------------------------------------+
+| in vec2 **UV2**                   | UV2 that comes from vertex function.               |
++-----------------------------------+----------------------------------------------------+
+| in vec3 **VIEW**                  | View vector, in view space.                        |
++-----------------------------------+----------------------------------------------------+
+| in vec3 **LIGHT**                 | Light Vector, in view space.                       |
++-----------------------------------+----------------------------------------------------+
+| in vec3 **LIGHT_COLOR**           | Color of light multiplied by energy.               |
++-----------------------------------+----------------------------------------------------+
+| in float **ATTENUATION**          | Attenuation based on distance or shadow.           |
++-----------------------------------+----------------------------------------------------+
+| in vec3 **SHADOW_ATTENUATION**    |                                                    |
++-----------------------------------+----------------------------------------------------+
+| in vec3 **ALBEDO**                | Base albedo.                                       |
++-----------------------------------+----------------------------------------------------+
+| in vec3 **BACKLIGHT**             |                                                    |
++-----------------------------------+----------------------------------------------------+
+| in float **METALLIC**             | Metallic.                                          |
++-----------------------------------+----------------------------------------------------+
+| in float **ROUGHNESS**            | Roughness.                                         |
++-----------------------------------+----------------------------------------------------+
+| in bool **OUTPUT_IS_SRGB**        | ``true`` when calculations happen in sRGB color    |
+|                                   | space (``true`` in GLES2, ``false`` in GLES3).     |
++-----------------------------------+----------------------------------------------------+
+| inout vec3 **DIFFUSE_LIGHT**      | Diffuse light result.                              |
++-----------------------------------+----------------------------------------------------+
+| inout vec3 **SPECULAR_LIGHT**     | Specular light result.                             |
++-----------------------------------+----------------------------------------------------+
+| inout float **ALPHA**             | Alpha (0..1); if written to, the material will go  |
+|                                   | to the transparent pipeline.                       |
++-----------------------------------+----------------------------------------------------+