BlendShader.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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/#manual/en/introduction/Installation." );
  2. /**
  3. * Blend two textures
  4. */
  5. THREE.BlendShader = {
  6. uniforms: {
  7. "tDiffuse1": { value: null },
  8. "tDiffuse2": { value: null },
  9. "mixRatio": { value: 0.5 },
  10. "opacity": { value: 1.0 }
  11. },
  12. vertexShader: [
  13. "varying vec2 vUv;",
  14. "void main() {",
  15. " vUv = uv;",
  16. " gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
  17. "}"
  18. ].join( "\n" ),
  19. fragmentShader: [
  20. "uniform float opacity;",
  21. "uniform float mixRatio;",
  22. "uniform sampler2D tDiffuse1;",
  23. "uniform sampler2D tDiffuse2;",
  24. "varying vec2 vUv;",
  25. "void main() {",
  26. " vec4 texel1 = texture2D( tDiffuse1, vUv );",
  27. " vec4 texel2 = texture2D( tDiffuse2, vUv );",
  28. " gl_FragColor = opacity * mix( texel1, texel2, mixRatio );",
  29. "}"
  30. ].join( "\n" )
  31. };