Skip to content

Commit 3f728cb

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

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

tutorials/shaders/shader_reference/spatial_shader.rst

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

0 commit comments

Comments
 (0)