Removed unneeded branching from shaders

This commit is contained in:
enricoturri1966 2020-04-08 08:22:02 +02:00
parent 0e2fba6d6f
commit c887ecfefa
2 changed files with 6 additions and 14 deletions

View File

@ -64,15 +64,11 @@ void main()
intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE; intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE;
intensity.y = 0.0; intensity.y = 0.0;
if (NdotL > 0.0)
{
vec3 position = (gl_ModelViewMatrix * gl_Vertex).xyz; vec3 position = (gl_ModelViewMatrix * gl_Vertex).xyz;
intensity.y += LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(position), reflect(-LIGHT_TOP_DIR, normal)), 0.0), LIGHT_TOP_SHININESS); intensity.y += LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(position), reflect(-LIGHT_TOP_DIR, normal)), 0.0), LIGHT_TOP_SHININESS);
}
// Perform the same lighting calculation for the 2nd light source (no specular applied). // Perform the same lighting calculation for the 2nd light source (no specular applied).
NdotL = max(dot(normal, LIGHT_FRONT_DIR), 0.0); NdotL = max(dot(normal, LIGHT_FRONT_DIR), 0.0);
if (NdotL > 0.0)
intensity.x += NdotL * LIGHT_FRONT_DIFFUSE; intensity.x += NdotL * LIGHT_FRONT_DIFFUSE;
// compute deltas for out of print volume detection (world coordinates) // compute deltas for out of print volume detection (world coordinates)

View File

@ -34,16 +34,12 @@ void main()
intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE; intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE;
intensity.y = 0.0; intensity.y = 0.0;
if (NdotL > 0.0)
{
vec3 position = (gl_ModelViewMatrix * gl_Vertex).xyz; vec3 position = (gl_ModelViewMatrix * gl_Vertex).xyz;
intensity.y += LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(position), reflect(-LIGHT_TOP_DIR, normal)), 0.0), LIGHT_TOP_SHININESS); intensity.y += LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(position), reflect(-LIGHT_TOP_DIR, normal)), 0.0), LIGHT_TOP_SHININESS);
}
// Perform the same lighting calculation for the 2nd light source (no specular) // Perform the same lighting calculation for the 2nd light source (no specular)
NdotL = max(dot(normal, LIGHT_FRONT_DIR), 0.0); NdotL = max(dot(normal, LIGHT_FRONT_DIR), 0.0);
if (NdotL > 0.0)
intensity.x += NdotL * LIGHT_FRONT_DIFFUSE; intensity.x += NdotL * LIGHT_FRONT_DIFFUSE;
// Scaled to widths of the Z texture. // Scaled to widths of the Z texture.