Skybox.glsl 827 B

12345678910111213141516171819202122232425262728293031
  1. #include "Uniforms.glsl"
  2. #include "Samplers.glsl"
  3. #include "Transform.glsl"
  4. varying vec3 vTexCoord;
  5. void VS()
  6. {
  7. #ifdef IGNORENODETRANSFORM
  8. mat4 modelMatrix = transpose(mat4(
  9. vec4(1.0, 0.0, 0.0, 0.0),
  10. vec4(0.0, 1.0, 0.0, 0.0),
  11. vec4(0.0, 0.0, 1.0, 0.0),
  12. transpose(cViewInv)[3]));
  13. #else
  14. mat4 modelMatrix = iModelMatrix;
  15. #endif
  16. vec3 worldPos = GetWorldPos(modelMatrix);
  17. gl_Position = GetClipPos(worldPos);
  18. gl_Position.z = gl_Position.w;
  19. vTexCoord = iPos.xyz;
  20. }
  21. void PS()
  22. {
  23. vec4 sky = cMatDiffColor * textureCube(sDiffCubeMap, vTexCoord);
  24. #ifdef HDRSCALE
  25. sky = pow(sky + clamp((cAmbientColor.a - 1.0) * 0.1, 0.0, 0.25), max(vec4(cAmbientColor.a), 1.0)) * clamp(cAmbientColor.a, 0.0, 1.0);
  26. #endif
  27. gl_FragColor = sky;
  28. }