objectpass_spheremap.frag 889 B

12345678910111213141516171819202122232425262728293031
  1. // See http://www.ozone3d.net/tutorials/glsl_texturing_p04.php for ref
  2. #ifdef Use_Bindless_Texture
  3. layout(bindless_sampler) uniform sampler2D tex;
  4. #else
  5. uniform sampler2D tex;
  6. #endif
  7. in vec3 nor;
  8. out vec4 FragColor;
  9. vec4 getPosFromUVDepth(vec3 uvDepth, mat4 InverseProjectionMatrix);
  10. vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue, float emitMapValue);
  11. void main() {
  12. vec3 texc = gl_FragCoord.xyz / vec3(screen, 1.);
  13. vec3 u = getPosFromUVDepth(texc, InverseProjectionMatrix).xyz;
  14. vec3 r = reflect(u, nor);
  15. float m = 2.0 * sqrt(r.x * r.x + r.y * r.y + (r.z + 1.0) * (r.z + 1.0));
  16. r.y = - r.y;
  17. vec4 detail0 = texture(tex, r.xy / m + .5);
  18. #ifdef Use_Bindless_Texture
  19. #ifdef SRGBBindlessFix
  20. detail0.xyz = pow(detail0.xyz, vec3(2.2));
  21. #endif
  22. #endif
  23. FragColor = vec4(getLightFactor(detail0.xyz, vec3(1.), 0., 0.), 1.);
  24. }