Hi,
I have a nme material that generates invalid GLSL shader code. This is the material: Babylon.js Node Material Editor
It calculates the reflection in the vertex shader but it wants to do it before the worldnormal variable is created. This results in a normalize()
call without any arguments.
I also have this variant of the shader, which should functionally be the same: https://nme.babylonjs.com/#8GBF2X#1
This however results in it wanting to use an output5
variable before it’s declared.
This is a GLSL output snipped of the incorrect code:
v_output6 = output6;
#ifdef REFLECTIONMAP_SKYBOX0
positionUVW = position.xyz;
#endif
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED0) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED0)
directionW = normalize(vec3(u_World * vec4(position.xyz, 0.0)));
#endif
#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
vec3 reflectionVector = vec3(reflectionMatrix * vec4(normalize(output5).xyz, 0)).xyz;
#ifdef REFLECTIONMAP_OPPOSITEZ0
reflectionVector.z *= -1.0;
#endif
vEnvironmentIrradiance = computeEnvironmentIrradiance(reflectionVector);
#endif
vec4 worldPos = output6;
mat4 view = u_view;
#include<shadowsVertex>[0..maxSimultaneousLights]
//World position
vec4 output3 = u_World1 * vec4(position, 1.0);
//Reflection texture
//World normal
mat3 u_World_NUS = mat3(u_World2);
#ifdef NONUNIFORMSCALING
u_World_NUS = transposeMat3(inverseMat3(u_World_NUS));
#endif
vec4 output5 = vec4(u_World_NUS * normal, 0.0);
Obviously, it also doesn’t work if I try to use the exported NodeMaterial
code.
Is there a workaround I could use for now? Manually fixing the glsl and using that doesn’t seem like a great option since I’m not sure what all the uniform should be set to.