Samplers.glsl 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifdef COMPILEPS
  2. uniform sampler2D sDiffMap;
  3. uniform samplerCube sDiffCubeMap;
  4. uniform sampler2D sNormalMap;
  5. uniform sampler2D sSpecMap;
  6. uniform sampler2D sEmissiveMap;
  7. uniform sampler2D sEnvMap;
  8. uniform samplerCube sEnvCubeMap;
  9. uniform sampler2D sLightRampMap;
  10. uniform sampler2D sLightSpotMap;
  11. uniform samplerCube sLightCubeMap;
  12. #ifndef GL_ES
  13. uniform sampler3D sVolumeMap;
  14. uniform sampler2D sAlbedoBuffer;
  15. uniform sampler2D sNormalBuffer;
  16. uniform sampler2D sDepthBuffer;
  17. uniform sampler2D sLightBuffer;
  18. uniform sampler2DShadow sShadowMap;
  19. uniform samplerCube sFaceSelectCubeMap;
  20. uniform samplerCube sIndirectionCubeMap;
  21. uniform samplerCube sZoneCubeMap;
  22. uniform sampler3D sZoneVolumeMap;
  23. #else
  24. uniform sampler2D sShadowMap;
  25. #endif
  26. vec3 DecodeNormal(vec4 normalInput)
  27. {
  28. #ifdef PACKEDNORMAL
  29. vec3 normal;
  30. normal.xy = normalInput.ag * 2.0 - 1.0;
  31. normal.z = sqrt(max(1.0 - dot(normal.xy, normal.xy), 0.0));
  32. return normal;
  33. #else
  34. return normalize(normalInput.rgb * 2.0 - 1.0);
  35. #endif
  36. }
  37. vec3 EncodeDepth(float depth)
  38. {
  39. vec3 ret;
  40. depth *= 255.0;
  41. ret.x = floor(depth);
  42. depth = (depth - ret.x) * 255.0;
  43. ret.y = floor(depth);
  44. ret.z = (depth - ret.y);
  45. ret.xy *= 1.0 / 255.0;
  46. return ret;
  47. }
  48. float DecodeDepth(vec3 depth)
  49. {
  50. const vec3 dotValues = vec3(1.0, 1.0 / 255.0, 1.0 / (255.0 * 255.0));
  51. return dot(depth, dotValues);
  52. }
  53. #endif