BlendShader.js 817 B

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