Skip to content

Commit a44e3a6

Browse files
committed
Add initial stencil documentation
1 parent 6b8faf3 commit a44e3a6

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

tutorials/shaders/shader_reference/spatial_shader.rst

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ For visual examples of these render modes, see :ref:`Standard Material 3D and OR
3535
+-------------------------------+------------------------------------------------------------------------------------------------------+
3636
| **depth_test_disabled** | Disable depth testing. |
3737
+-------------------------------+------------------------------------------------------------------------------------------------------+
38+
| **depth_test_default** | Depth test will discard the pixel if it is behind other pixels. |
39+
+-------------------------------+------------------------------------------------------------------------------------------------------+
40+
| **depth_test_inverted** | Depth test will discard the pixel if it is in front of other pixels. Useful for stencil effects |
41+
+-------------------------------+------------------------------------------------------------------------------------------------------+
3842
| **sss_mode_skin** | Subsurface Scattering mode for skin (optimizes visuals for human skin, e.g. boosted red channel). |
3943
+-------------------------------+------------------------------------------------------------------------------------------------------+
4044
| **cull_back** | Cull back-faces (default). |
@@ -90,6 +94,44 @@ For visual examples of these render modes, see :ref:`Standard Material 3D and OR
9094
| **fog_disabled** | Disable receiving depth-based or volumetric fog. Useful for ``blend_add`` materials like particles. |
9195
+-------------------------------+------------------------------------------------------------------------------------------------------+
9296

97+
Stencil modes
98+
------------
99+
Stencil operations are a set of operations that allow to write into an efficient, often hardeware integrated, buffer.
100+
Stencil is generally use to mask in or out parts of the scene.
101+
102+
NOTE: Stencil support is experimental, use at your own risk. We will try to not break compatibility as much as possible, but if major flaws
103+
are found in the API, it may change in the next version.
104+
105+
Some of the most known uses are:
106+
- Outlines: stencil allows to mask out the inner mesh that is being outlined to avoid inner outlines.
107+
- Xray: display a mesh behind other objects.
108+
- Portals: Draw impossible geometry by masking objects
109+
110+
NOTE: You can only read stencil in the transparent pass. Any attempt to read in the opaque pass will fail and it's not supported behaviour.
111+
NOTE: Stencil operations aren't yet supported in compositor effects. Please use full screen quad method.
112+
113+
+-------------------------------+------------------------------------------------------------------------------------------------------+
114+
| Stencil mode | Description |
115+
+===============================+======================================================================================================+
116+
| **read** | Read from stencil buffer. |
117+
+-------------------------------+------------------------------------------------------------------------------------------------------+
118+
| **write** | Write reference value to stencil buffer. |
119+
+-------------------------------+------------------------------------------------------------------------------------------------------+
120+
| **write_if_depth_fail** | Write reference value to stencil buffer if depth test fails. |
121+
+-------------------------------+------------------------------------------------------------------------------------------------------+
122+
| **compare_equal** | Pass stencil test if ref value is equal to stencil buffer value. |
123+
+-------------------------------+------------------------------------------------------------------------------------------------------+
124+
| **compare_not_equal** | Pass stencil test if ref value is not equal to stencil buffer value. |
125+
+-------------------------------+------------------------------------------------------------------------------------------------------+
126+
| **compare_less** | Pass stencil test if ref value is lesser than stencil buffer value. |
127+
+-------------------------------+------------------------------------------------------------------------------------------------------+
128+
| **compare_less_or_equal** | Pass stencil test if ref value is lesser or equal than stencil buffer value. |
129+
+-------------------------------+------------------------------------------------------------------------------------------------------+
130+
| **compare_greater** | Pass stencil test if ref value is greater than stencil buffer value. |
131+
+-------------------------------+------------------------------------------------------------------------------------------------------+
132+
| **compare_greater_or_equal** | Pass stencil test if ref value is lesser or equal than stencil buffer value. |
133+
+-------------------------------+------------------------------------------------------------------------------------------------------+
134+
93135
Built-ins
94136
---------
95137

0 commit comments

Comments
 (0)