Shader_Minifier icon indicating copy to clipboard operation
Shader_Minifier copied to clipboard

Inlining of global floats in vec3

Open heyjuvi opened this issue 1 year ago • 2 comments

When using (global) variables like

float a = 4;
vec3 b = vec3(a / 8, a / 8, 0);

the variable a gets inlined, but the information that it was a float seems to be lost, it appears as if an integer division is performed and the result is

vec3 b = vec3(0);

heyjuvi avatar Sep 27 '23 08:09 heyjuvi

Thanks for the report! Using 4. should fix it.

Can you check if your GLSL compiler throws a type error when you write float a = 4; (without running Shader Minifier)?

laurentlb avatar Sep 27 '23 09:09 laurentlb

Yes. I checked it with using 8., but I’m sure 4. fixes this as well.

During development I'm using a non-minified version and it compiles fine (Nvidia driver for Linux). I think I also checked it with glslangValidator at some point as well and it didn't complain.

heyjuvi avatar Sep 27 '23 13:09 heyjuvi