background.glsl.js 829 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. export const vertex = /* glsl */`
  2. varying vec2 vUv;
  3. uniform mat3 uvTransform;
  4. void main() {
  5. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  6. gl_Position = vec4( position.xy, 1.0, 1.0 );
  7. }
  8. `;
  9. export const fragment = /* glsl */`
  10. uniform sampler2D t2D;
  11. uniform float backgroundIntensity;
  12. varying vec2 vUv;
  13. void main() {
  14. vec4 texColor = texture2D( t2D, vUv );
  15. #ifdef DECODE_VIDEO_TEXTURE
  16. // use inline sRGB decode until browsers properly support SRGB8_APLHA8 with video textures
  17. texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
  18. #endif
  19. texColor.rgb *= backgroundIntensity;
  20. gl_FragColor = texColor;
  21. #include <tonemapping_fragment>
  22. #include <colorspace_fragment>
  23. }
  24. `;