From f2ea2014c16a232c905b84056bdb6830c6e29f39 Mon Sep 17 00:00:00 2001 From: tetrapod00 <145553014+tetrapod00@users.noreply.github.com> Date: Thu, 17 Oct 2024 12:48:04 -0700 Subject: [PATCH] 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. --- tutorials/shaders/shader_reference/shading_language.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tutorials/shaders/shader_reference/shading_language.rst b/tutorials/shaders/shader_reference/shading_language.rst index ba2ca01d7..f9913a9a0 100644 --- a/tutorials/shaders/shader_reference/shading_language.rst +++ b/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. | +----------------------+---------------------------------------------------------------------------------+ +.. 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 ~~~~~~~~