You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
704 B

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