BlendShader.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. console.warn( "THREE.BlendShader: As part of the transition to ES6 Modules, the files in 'examples/js' were deprecated in May 2020 (r117) and will be deleted in December 2020 (r124). You can find more information about developing using ES6 Modules in https://threejs.org/docs/index.html#manual/en/introduction/Import-via-modules." );
  2. /**
  3. * @author alteredq / http://alteredqualia.com/
  4. *
  5. * Blend two textures
  6. */
  7. THREE.BlendShader = {
  8. uniforms: {
  9. "tDiffuse1": { value: null },
  10. "tDiffuse2": { value: null },
  11. "mixRatio": { value: 0.5 },
  12. "opacity": { value: 1.0 }
  13. },
  14. vertexShader: [
  15. "varying vec2 vUv;",
  16. "void main() {",
  17. " vUv = uv;",
  18. " gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
  19. "}"
  20. ].join( "\n" ),
  21. fragmentShader: [
  22. "uniform float opacity;",
  23. "uniform float mixRatio;",
  24. "uniform sampler2D tDiffuse1;",
  25. "uniform sampler2D tDiffuse2;",
  26. "varying vec2 vUv;",
  27. "void main() {",
  28. " vec4 texel1 = texture2D( tDiffuse1, vUv );",
  29. " vec4 texel2 = texture2D( tDiffuse2, vUv );",
  30. " gl_FragColor = opacity * mix( texel1, texel2, mixRatio );",
  31. "}"
  32. ].join( "\n" )
  33. };