Skip to content

Commit b757d40

Browse files
committed
Add warning about uninitialized variables in shaders
Adds a warning note to shading_language.rst. GDShader does not initialize local variables to 0, and an uninitialized local variable can contain an arbitrary value.
1 parent ee8b70e commit b757d40

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tutorials/shaders/shader_reference/shading_language.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@ Most GLSL ES 3.0 datatypes are supported:
8686
| | Only supported in Forward+ and Mobile, not Compatibility. |
8787
+----------------------+---------------------------------------------------------------------------------+
8888

89+
.. warning::
90+
91+
Local variables are not initialized to a default value such as ``0.0``. If
92+
you use a variable without assigning it first, it will contain whatever
93+
value was already present at that memory location, and unpredictable visual
94+
glitches will appear. However, uniforms and varyings are initialized to a
95+
default value.
96+
8997
Comments
9098
~~~~~~~~
9199

0 commit comments

Comments
 (0)