Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
mamayaya1
GitHub Repository: mamayaya1/game
Path: blob/main/projects/HexGL/libs/postprocessing/FilmPass.js
4627 views
1
/**
2
* @author alteredq / http://alteredqualia.com/
3
*/
4
5
THREE.FilmPass = function ( noiseIntensity, scanlinesIntensity, scanlinesCount, grayscale ) {
6
7
var shader = THREE.ShaderExtras[ "film" ];
8
9
this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
10
11
this.material = new THREE.ShaderMaterial( {
12
13
uniforms: this.uniforms,
14
vertexShader: shader.vertexShader,
15
fragmentShader: shader.fragmentShader
16
17
} );
18
19
if ( grayscale !== undefined ) this.uniforms.grayscale.value = grayscale;
20
if ( noiseIntensity !== undefined ) this.uniforms.nIntensity.value = noiseIntensity;
21
if ( scanlinesIntensity !== undefined ) this.uniforms.sIntensity.value = scanlinesIntensity;
22
if ( scanlinesCount !== undefined ) this.uniforms.sCount.value = scanlinesCount;
23
24
this.enabled = true;
25
this.renderToScreen = false;
26
this.needsSwap = true;
27
28
};
29
30
THREE.FilmPass.prototype = {
31
32
render: function ( renderer, writeBuffer, readBuffer, delta ) {
33
34
this.uniforms[ "tDiffuse" ].texture = readBuffer;
35
this.uniforms[ "time" ].value += delta;
36
37
THREE.EffectComposer.quad.material = this.material;
38
39
if ( this.renderToScreen ) {
40
41
renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera );
42
43
} else {
44
45
renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera, writeBuffer, false );
46
47
}
48
49
}
50
51
};
52
53