2
0

Samplers.frag 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. uniform sampler2D sDiffMap;
  2. uniform samplerCube sDiffCubeMap;
  3. uniform sampler2D sNormalMap;
  4. uniform sampler2D sSpecMap;
  5. uniform sampler2D sEmissiveMap;
  6. uniform sampler2D sDetailMap;
  7. uniform sampler2D sEnvMap;
  8. uniform samplerCube sEnvCubeMap;
  9. uniform sampler2DShadow sShadowMap;
  10. uniform sampler2D sLightRampMap;
  11. uniform sampler2D sLightSpotMap;
  12. uniform samplerCube sLightCubeMap;
  13. uniform samplerCube sFaceSelectCubeMap;
  14. uniform samplerCube sIndirectionCubeMap;
  15. uniform sampler2D sAlbedoBuffer;
  16. uniform sampler2D sNormalBuffer;
  17. uniform sampler2D sDepthBuffer;
  18. uniform sampler2D sLightBuffer;
  19. vec3 DecodeNormal(vec4 normalInput)
  20. {
  21. vec3 normal;
  22. normal.xy = normalInput.ag * 2.0 - 1.0;
  23. normal.z = sqrt(max(1.0 - dot(normal.xy, normal.xy), 0.0));
  24. return normal;
  25. }
  26. vec3 EncodeDepth(float depth)
  27. {
  28. vec3 ret;
  29. depth *= 255.0;
  30. ret.x = floor(depth);
  31. depth = (depth - ret.x) * 255.0;
  32. ret.y = floor(depth);
  33. ret.z = (depth - ret.y);
  34. ret.xy *= 1.0 / 255.0;
  35. return ret;
  36. }
  37. float DecodeDepth(vec3 depth)
  38. {
  39. const vec3 dotValues = vec3(1.0, 1.0 / 255.0, 1.0 / (255.0 * 255.0));
  40. return dot(depth, dotValues);
  41. }
  42. float ReconstructDepth(float hwDepth)
  43. {
  44. return cDepthReconstruct.y / (hwDepth - cDepthReconstruct.x);
  45. }