浏览代码

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.
tetrapod00 9 月之前
父节点
当前提交
b757d4019d
共有 1 个文件被更改,包括 8 次插入0 次删除
  1. 8 0
      tutorials/shaders/shader_reference/shading_language.rst

+ 8 - 0
tutorials/shaders/shader_reference/shading_language.rst

@@ -86,6 +86,14 @@ Most GLSL ES 3.0 datatypes are supported:
 |                      | Only supported in Forward+ and Mobile, not Compatibility.                       |
 |                      | Only supported in Forward+ and Mobile, not Compatibility.                       |
 +----------------------+---------------------------------------------------------------------------------+
 +----------------------+---------------------------------------------------------------------------------+
 
 
+.. warning::
+
+    Local variables are not initialized to a default value such as ``0.0``. If
+    you use a variable without assigning it first, it will contain whatever
+    value was already present at that memory location, and unpredictable visual
+    glitches will appear. However, uniforms and varyings are initialized to a
+    default value.
+
 Comments
 Comments
 ~~~~~~~~
 ~~~~~~~~