Hello,

Simple question about GLSL and fragment shaders. May I return the "final color" early if I don't need to do any further processing in the void main function?

Consider the following example:

Code :
#version 330 core
 
out vec4 finalColor;
 
uniform float drawWireframe;
 
uniform vec4 materialColor;
 
vec4 fancyLightingFunction(vec4 colorToProcess) {
 
// Fancy lighting function here...
 
}
 
void main() {
 
if (drawWireframe == 1.0) finalColor = materialColor;
 
// May I call "return" here?
 
finalColor = fancyLightingFunction(materialColor);
 
}

Thank you for your time.