Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scene_forward.glsl fails to compile on editor launch #45908

Closed
christianhassler opened this issue Feb 11, 2021 · 1 comment · Fixed by #45987
Closed

scene_forward.glsl fails to compile on editor launch #45908

christianhassler opened this issue Feb 11, 2021 · 1 comment · Fixed by #45987

Comments

@christianhassler
Copy link

Godot version:
#45879

OS/device including version:
OS: Arch Linux 5.10.14
GPU: RTX 2070 (driver version 460.39, Vulkan backend)

Issue description:
Variant 1 (and I think also 0) of scene_forward.glsl fail to compile at launch. Seems to be a consequence of defining one of TANGENT_USED, NORMAL_MAP_USED, or LIGHT_ANISOTROPY_USED while NORMAL_USED is not defined. This causes vec3 normal to not be defined, even though it is used in some later code paths (specifically for computing the binormal).

The log is long and repetitive because it dumps all shader source for every shader that fails to compile, but here's the important bit.

Godot Engine v4.0.dev.custom_build.ad293a82f - https://godotengine.org
Using ICU / HarfBuzz / Graphite text server...
Using Vulkan Device #0: NVIDIA - GeForce RTX 2070
DisplayServer::_create_window 0 want rect: 448, 300, 1024, 600 got rect 448, 300, 1024, 600

DisplayServer::_window_changed: 0 rect: 2001, 721, 638, 1179
Editing project: /tmp/Tmp (::tmp::Tmp)
ALSA lib pcm_dmix.c:1075:(snd_pcm_dmix_open) unable to open slave
ERROR: Condition "status < 0" is true. Returning: ERR_CANT_OPEN
   at: init_device (drivers/alsa/audio_driver_alsa.cpp:83)
WARNING: All audio drivers failed, falling back to the dummy driver.
     at: initialize (servers/audio_server.cpp:222)
ERROR: Condition "!shape->is_configured()" is true. Returning: Variant()
   at: shape_get_data (servers/physics_3d/physics_server_3d_sw.cpp:125)
ERROR: Condition "!d.has("cell_size")" is true.
   at: set_data (servers/physics_3d/shape_3d_sw.cpp:1688)
ERROR: Condition "!body" is true.
   at: body_attach_object_instance_id (servers/physics_3d/physics_server_3d_sw.cpp:614)
ERROR: Invalid ID.
   at: free (servers/physics_3d/physics_server_3d_sw.cpp:1322)
ERROR: Error compiling Vertex shader, variant #1 (
#define MODE_RENDER_DEPTH
#define MODE_DUAL_PARABOLOID
).
   at: _compile_variant (servers/rendering/renderer_rd/shader_rd.cpp:339)
ERROR: Failed parse:
ERROR: 0:677: 'normal' : undeclared identifier
ERROR: 0:677: '' : compilation terminated
ERROR: 2 compilation errors.  No code generated.

Steps to reproduce:
Launch godot and choose or create a project.

Minimal reproduction project:
Not tied to any particular project.

Possible Fix:
I don't know how you intended to handle this case, but here's a patch that just initializes normal to vec3(0.0).

diff --git a/servers/rendering/renderer_rd/shaders/scene_forward.glsl b/servers/rendering/renderer_rd/shaders/scene_forward.glsl
index adccf1e712..90802dcf11 100644
--- a/servers/rendering/renderer_rd/shaders/scene_forward.glsl
+++ b/servers/rendering/renderer_rd/shaders/scene_forward.glsl
@@ -161,6 +161,8 @@ void main() {
        vec3 vertex = vertex_attrib;
 #ifdef NORMAL_USED
        vec3 normal = normal_attrib * 2.0 - 1.0;
+#else
+    vec3 normal = vec3(0.0);
 #endif

 #if defined(TANGENT_USED) || defined(NORMAL_MAP_USED) || defined(LIGHT_ANISOTROPY_USED)
@@ -243,6 +245,8 @@ VERTEX_SHADER_CODE
        vertex = (modelview * vec4(vertex, 1.0)).xyz;
 #ifdef NORMAL_USED
        normal = modelview_normal * normal;
+#else
+    normal = modelview_normal;
 #endif

 #endif
@@ -1891,6 +1895,8 @@ void main() {
        }
 #endif

+#else
+    vec3 normal = vec3(0.0);
 #endif //NORMAL_USED

 #ifdef UV_USED

It also might be that this code path is never supposed to happen (i.e. NORMAL_USED is supposed to always be defined whenever the binormals are computed). I'm not familiar enough with the godot codebase to say either way.

@Calinou Calinou added this to the 4.0 milestone Feb 11, 2021
@bruvzg
Copy link
Member

bruvzg commented Feb 13, 2021

Same error on macOS 11.2.1 / MoltenVK 1.1.2 (Vulkan SDK 1.2.162.1), bisected to #45845 (cased by changex in the init of the Material).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants