BlendShader.js 808 B

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