ColorifyShader.js 996 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. console.warn( "THREE.ColorifyShader: 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. * Colorify shader
  4. */
  5. THREE.ColorifyShader = {
  6. uniforms: {
  7. "tDiffuse": { value: null },
  8. "color": { value: new THREE.Color( 0xffffff ) }
  9. },
  10. vertexShader: [
  11. "varying vec2 vUv;",
  12. "void main() {",
  13. " vUv = uv;",
  14. " gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
  15. "}"
  16. ].join( "\n" ),
  17. fragmentShader: [
  18. "uniform vec3 color;",
  19. "uniform sampler2D tDiffuse;",
  20. "varying vec2 vUv;",
  21. "void main() {",
  22. " vec4 texel = texture2D( tDiffuse, vUv );",
  23. " vec3 luma = vec3( 0.299, 0.587, 0.114 );",
  24. " float v = dot( texel.xyz, luma );",
  25. " gl_FragColor = vec4( v * color, texel.w );",
  26. "}"
  27. ].join( "\n" )
  28. };