FIXED: 2020.25380 - phong/pbr glsl output - remove superfluous uniforms from vertex shader + option for picking if block?

Hello,

Not technically a bug and a pretty small thing, but I find myself removing over and over the uniforms pertaining to the pixel shader in the vertex shader :

uniform vec4 uDiffuseColor;
uniform vec4 uAmbientColor;
uniform vec3 uSpecularColor;
uniform float uShininess;
uniform float uShadowStrength;
uniform vec3 uShadowColor;

and as well, I’m not using picking that often and often remove the #ifndef TD_PICKING_ACTIVE + comments block, so it would be great to have that an option for the generated output, much like the option for the geometry shader.

Thanks a lot!

I’ve cleaned up the uniforms in the vertex shader so they should be only what’s needed now (if any).

Not sure about removing the picking block offhand, I’ll think about that case more.

1 Like

Thanks @malcolm!
I noticed the vertex shader starts with a blank line now though but I can live with it :smiley:

On the other hand and another thing I’ve been wondering for a while, would love to get some explanation on :

{ // Avoid duplicate variable defs
	vec3 texcoord = TDInstanceTexCoord(uv[0]);
	oVert.texCoord0.st = texcoord.st;
}

Didn’t see anything in the doc Write a GLSL Material - Derivative, why are the {} needed?
Thank you!

Those are there due to the on demand generation of the shader that occurs in C++ for the Phong MAT. It just makes the programming in the C++ side easier

Thanks @malcolm, curious if you can get into a little more detail? Not seeing any ill effect when I comment out the {} in general, what should I be cautious with?
Thank you!

Some shaders may have multiple {} blocks with identical variables declared within them. Those are the cases where removing the {} would case compile issues

1 Like

Oh I see, makes sense, not sure I’ve encountered those often! thank you