Skip to content

Commit cce46dc

Browse files
committed
Update list of spatial shader render modes for Godot 4.3
This also improves the documentation for existing render modes.
1 parent c3f0ec7 commit cce46dc

2 files changed

Lines changed: 27 additions & 16 deletions

File tree

tutorials/assets_pipeline/importing_images.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,12 @@ displayed correctly:
412412

413413
- In 2D, a :ref:`class_CanvasItemMaterial` will need to be created and
414414
configured to use the **Premul Alpha** blend mode on CanvasItems that use this
415-
texture.
416-
- In 3D, there is no support for premultiplied alpha blend mode yet, so this
417-
option is only suited for 2D.
415+
texture. In :ref:`custom canvas item shaders <doc_canvas_item_shader>`,
416+
``render_mode blend_premul_alpha;`` should be used.
417+
- In 3D, a :ref:`class_BaseMaterial3D` will need to be created and configured
418+
to use the **Premul Alpha** blend mode on materials that use this texture.
419+
In :ref:`custom spatial shaders <doc_spatial_shader>`,
420+
``render_mode blend_premul_alpha;`` should be used.
418421

419422
Process > Normal Map Invert Y
420423
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tutorials/shaders/shader_reference/spatial_shader.rst

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Render modes
2222
+-------------------------------+------------------------------------------------------------------------------------------------------+
2323
| **blend_mul** | Multiplicative blend mode. |
2424
+-------------------------------+------------------------------------------------------------------------------------------------------+
25+
| **blend_premul_alpha** | Premultiplied alpha blend mode (fully transparent = add, fully opaque = mix). |
26+
+-------------------------------+------------------------------------------------------------------------------------------------------+
2527
| **depth_draw_opaque** | Only draw depth for opaque geometry (not transparent). |
2628
+-------------------------------+------------------------------------------------------------------------------------------------------+
2729
| **depth_draw_always** | Always draw depth (opaque and transparent). |
@@ -32,55 +34,57 @@ Render modes
3234
+-------------------------------+------------------------------------------------------------------------------------------------------+
3335
| **depth_test_disabled** | Disable depth testing. |
3436
+-------------------------------+------------------------------------------------------------------------------------------------------+
35-
| **sss_mode_skin** | Subsurface Scattering mode for skin. |
37+
| **sss_mode_skin** | Subsurface Scattering mode for skin (optimizes visuals for human skin, e.g. boosted red channel). |
3638
+-------------------------------+------------------------------------------------------------------------------------------------------+
3739
| **cull_back** | Cull back-faces (default). |
3840
+-------------------------------+------------------------------------------------------------------------------------------------------+
3941
| **cull_front** | Cull front-faces. |
4042
+-------------------------------+------------------------------------------------------------------------------------------------------+
4143
| **cull_disabled** | Culling disabled (double sided). |
4244
+-------------------------------+------------------------------------------------------------------------------------------------------+
43-
| **unshaded** | Result is just albedo. No lighting/shading happens in material. |
45+
| **unshaded** | Result is just albedo. No lighting/shading happens in material, making it faster to render. |
46+
+-------------------------------+------------------------------------------------------------------------------------------------------+
47+
| **wireframe** | Geometry draws using lines (useful for troubleshooting). |
4448
+-------------------------------+------------------------------------------------------------------------------------------------------+
45-
| **wireframe** | Geometry draws using lines. |
49+
| **debug_shadow_splits** | Directional shadows are drawn using different colors for each split (useful for troubleshooting). |
4650
+-------------------------------+------------------------------------------------------------------------------------------------------+
4751
| **diffuse_burley** | Burley (Disney PBS) for diffuse (default). |
4852
+-------------------------------+------------------------------------------------------------------------------------------------------+
4953
| **diffuse_lambert** | Lambert shading for diffuse. |
5054
+-------------------------------+------------------------------------------------------------------------------------------------------+
51-
| **diffuse_lambert_wrap** | Lambert wrapping (roughness dependent) for diffuse. |
55+
| **diffuse_lambert_wrap** | Lambert-wrap shading (roughness-dependent) for diffuse. |
5256
+-------------------------------+------------------------------------------------------------------------------------------------------+
5357
| **diffuse_toon** | Toon shading for diffuse. |
5458
+-------------------------------+------------------------------------------------------------------------------------------------------+
55-
| **specular_schlick_ggx** | Schlick-GGX for specular (default). |
59+
| **specular_schlick_ggx** | Schlick-GGX for direct light specular lobes (default). |
5660
+-------------------------------+------------------------------------------------------------------------------------------------------+
57-
| **specular_toon** | Toon for specular. |
61+
| **specular_toon** | Toon for direct light specular lobes. |
5862
+-------------------------------+------------------------------------------------------------------------------------------------------+
59-
| **specular_disabled** | Disable specular. |
63+
| **specular_disabled** | Disable direct light specular lobes. |
6064
+-------------------------------+------------------------------------------------------------------------------------------------------+
61-
| **skip_vertex_transform** | VERTEX/NORMAL/etc. need to be transformed manually in vertex function. |
65+
| **skip_vertex_transform** | ``VERTEX``/``NORMAL``/etc. need to be transformed manually in the ``vertex()`` function. |
6266
+-------------------------------+------------------------------------------------------------------------------------------------------+
63-
| **world_vertex_coords** | VERTEX/NORMAL/etc. are modified in world coordinates instead of local. |
67+
| **world_vertex_coords** | ``VERTEX``/``NORMAL``/etc. are modified in world coordinates instead of local. |
6468
+-------------------------------+------------------------------------------------------------------------------------------------------+
65-
| **ensure_correct_normals** | Use when non-uniform scale is applied to mesh. |
69+
| **ensure_correct_normals** | Use when non-uniform scale is applied to mesh *(note: currently unimplemented)*. |
6670
+-------------------------------+------------------------------------------------------------------------------------------------------+
67-
| **shadows_disabled** | Disable computing shadows in shader. |
71+
| **shadows_disabled** | Disable computing shadows in shader. The shader will not cast shadows, but can still receive them. |
6872
+-------------------------------+------------------------------------------------------------------------------------------------------+
6973
| **ambient_light_disabled** | Disable contribution from ambient light and radiance map. |
7074
+-------------------------------+------------------------------------------------------------------------------------------------------+
7175
| **shadow_to_opacity** | Lighting modifies the alpha so shadowed areas are opaque and |
7276
| | non-shadowed areas are transparent. Useful for overlaying shadows onto |
7377
| | a camera feed in AR. |
7478
+-------------------------------+------------------------------------------------------------------------------------------------------+
75-
| **vertex_lighting** | Use vertex-based lighting. |
79+
| **vertex_lighting** | Use vertex-based lighting *(note: currently unimplemented)*. |
7680
+-------------------------------+------------------------------------------------------------------------------------------------------+
7781
| **particle_trails** | Enables the trails when used on particles geometry. |
7882
+-------------------------------+------------------------------------------------------------------------------------------------------+
7983
| **alpha_to_coverage** | Alpha antialiasing mode, see `here <https://github.com/godotengine/godot/pull/40364>`_ for more. |
8084
+-------------------------------+------------------------------------------------------------------------------------------------------+
8185
| **alpha_to_coverage_and_one** | Alpha antialiasing mode, see `here <https://github.com/godotengine/godot/pull/40364>`_ for more. |
8286
+-------------------------------+------------------------------------------------------------------------------------------------------+
83-
| **fog_disabled** | Disable receiving depth-based or volumetric fog. Useful for blend_add materials like particles. |
87+
| **fog_disabled** | Disable receiving depth-based or volumetric fog. Useful for ``blend_add`` materials like particles. |
8488
+-------------------------------+------------------------------------------------------------------------------------------------------+
8589

8690
Built-ins
@@ -347,6 +351,10 @@ these properties, and if you don't write to them, Godot will optimize away the c
347351
+----------------------------------------+--------------------------------------------------------------------------------------------------+
348352
| out vec2 **ALPHA_TEXTURE_COORDINATE** | |
349353
+----------------------------------------+--------------------------------------------------------------------------------------------------+
354+
| out float **PREMUL_ALPHA_FACTOR** | Premultiplied alpha factor. Only effective if ``render_mode blend_premul_alpha;`` is used. |
355+
| | This should be written to when using a *shaded* material with premultiplied alpha blending for |
356+
| | interaction with lighting. This is not required for unshaded materials. |
357+
+----------------------------------------+--------------------------------------------------------------------------------------------------+
350358
| out float **METALLIC** | Metallic (0..1). |
351359
+----------------------------------------+--------------------------------------------------------------------------------------------------+
352360
| out float **SPECULAR** | Specular. Defaults to 0.5, best not to modify unless you want to change IOR. |

0 commit comments

Comments
 (0)