12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- /**
- * @author Mugen87 / https://github.com/Mugen87
- *
- * see https://en.wikipedia.org/wiki/Grayscale
- *
- */
- THREE.GrayScaleShader = {
- uniforms: {
- "tDiffuse": { value: null }
- },
- vertexShader: [
- "varying vec2 vUv;",
- "void main() {",
- "vUv = uv;",
- "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
- "}"
- ].join( "\n" ),
- fragmentShader: [
- "uniform sampler2D tDiffuse;",
- "varying vec2 vUv;",
- "void main() {",
- "const vec3 weight = vec3( 0.2126, 0.7152, 0.0722 );",
- "vec3 color = texture2D( tDiffuse, vUv ).rgb;",
- "float luminance = dot( color, weight );",
- "gl_FragColor = vec4( vec3( luminance ), 1 );",
- "}"
- ].join( "\n" )
- };
|