skybox.fs (704B)
1 #version 330 2 3 // Input vertex attributes (from vertex shader) 4 in vec3 fragPosition; 5 6 // Input uniform values 7 uniform samplerCube environmentMap; 8 uniform bool vflipped; 9 uniform bool doGamma; 10 11 // Output fragment color 12 out vec4 finalColor; 13 14 void main() 15 { 16 // Fetch color from texture map 17 vec3 color = vec3(0.0); 18 19 if (vflipped) color = texture(environmentMap, vec3(fragPosition.x, -fragPosition.y, fragPosition.z)).rgb; 20 else color = texture(environmentMap, fragPosition).rgb; 21 22 if (doGamma)// Apply gamma correction 23 { 24 color = color/(color + vec3(1.0)); 25 color = pow(color, vec3(1.0/2.2)); 26 } 27 28 // Calculate final fragment color 29 finalColor = vec4(color, 1.0); 30 }