Spaces:
Running
Running
File size: 923 Bytes
a28eca3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
const FilmShader = {
name: 'FilmShader',
uniforms: {
'tDiffuse': { value: null },
'time': { value: 0.0 },
'intensity': { value: 0.5 },
'grayscale': { value: false }
},
vertexShader: /* glsl */`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,
fragmentShader: /* glsl */`
#include <common>
uniform float intensity;
uniform bool grayscale;
uniform float time;
uniform sampler2D tDiffuse;
varying vec2 vUv;
void main() {
vec4 base = texture2D( tDiffuse, vUv );
float noise = rand( fract( vUv + time ) );
vec3 color = base.rgb + base.rgb * clamp( 0.1 + noise, 0.0, 1.0 );
color = mix( base.rgb, color, intensity );
if ( grayscale ) {
color = vec3( luminance( color ) ); // assuming linear-srgb
}
gl_FragColor = vec4( color, base.a );
}`,
};
export { FilmShader };
|