forked from mrdoob/three.js
-
Notifications
You must be signed in to change notification settings - Fork 87
/
Copy pathTexturePass.js
40 lines (24 loc) · 902 Bytes
/
TexturePass.js
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
/**
* @author alteredq / http://alteredqualia.com/
*/
THREE.TexturePass = function ( texture, opacity ) {
if ( THREE.CopyShader === undefined )
console.error( "THREE.TexturePass relies on THREE.CopyShader" );
var shader = THREE.CopyShader;
this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
this.uniforms[ "opacity" ].value = ( opacity !== undefined ) ? opacity : 1.0;
this.uniforms[ "tDiffuse" ].value = texture;
this.material = new THREE.ShaderMaterial( {
uniforms: this.uniforms,
vertexShader: shader.vertexShader,
fragmentShader: shader.fragmentShader
} );
this.enabled = true;
this.needsSwap = false;
};
THREE.TexturePass.prototype = {
render: function ( renderer, writeBuffer, readBuffer, delta ) {
THREE.EffectComposer.quad.material = this.material;
renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera, readBuffer );
}
};