BlendShader.js 754 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /**
  2. * Blend two textures
  3. */
  4. const BlendShader = {
  5. name: 'BlendShader',
  6. uniforms: {
  7. 'tDiffuse1': { value: null },
  8. 'tDiffuse2': { value: null },
  9. 'mixRatio': { value: 0.5 },
  10. 'opacity': { value: 1.0 }
  11. },
  12. vertexShader: /* glsl */`
  13. varying vec2 vUv;
  14. void main() {
  15. vUv = uv;
  16. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  17. }`,
  18. fragmentShader: /* glsl */`
  19. uniform float opacity;
  20. uniform float mixRatio;
  21. uniform sampler2D tDiffuse1;
  22. uniform sampler2D tDiffuse2;
  23. varying vec2 vUv;
  24. void main() {
  25. vec4 texel1 = texture2D( tDiffuse1, vUv );
  26. vec4 texel2 = texture2D( tDiffuse2, vUv );
  27. gl_FragColor = opacity * mix( texel1, texel2, mixRatio );
  28. }`
  29. };
  30. export { BlendShader };