SkyFragment.glsl 484 B

12345678910111213141516171819202122
  1. // https://gamedevelopment.tutsplus.com/tutorials/a-beginners-guide-to-coding-graphics-shaders--cms-23313
  2. uniform vec3 topColor;
  3. uniform vec3 horizontColor;
  4. uniform float offset;
  5. uniform float exponent;
  6. varying vec3 vWorldPosition;
  7. void main() {
  8. float h = normalize( vWorldPosition + offset ).y;
  9. gl_FragColor = vec4(
  10. mix(
  11. horizontColor,
  12. topColor,
  13. max(
  14. pow(
  15. max( h , 0.0),
  16. exponent
  17. ),
  18. 0.0
  19. )
  20. ), 1.0
  21. );
  22. }