diff --git a/QtMeshViewer/Resources/fshader.glsl b/QtMeshViewer/Resources/fshader.glsl index ec72252..4e5d7be 100644 --- a/QtMeshViewer/Resources/fshader.glsl +++ b/QtMeshViewer/Resources/fshader.glsl @@ -39,7 +39,7 @@ void main() vec3 surfaceToLight; float attenuation; // directional light - if(light.position.w == 0) + if(light.position.w == 0.0f) { surfaceToLight = normalize(light.position.xyz); } @@ -65,9 +65,12 @@ void main() float specularCoefficient = 0.0; if(diffuseCoefficient > 0.0) specularCoefficient = pow(max(0.0, dot(surfaceToCamera, reflect(-surfaceToLight, normalWorld))), materialShininess); + vec3 specColor; if(b_specular) - materialSpecularColor = vec3(surfaceColor.a); - vec3 specular = specularCoefficient * materialSpecularColor * light.intensities; + specColor = vec3(surfaceColor.a); + else + specColor = materialSpecularColor; + vec3 specular = specularCoefficient * specColor * light.intensities; // linear color before gamma correction) vec3 linearColor = ambient + attenuation * (diffuse + specular);