first commit
This commit is contained in:
61
FilmPass.js
Normal file
61
FilmPass.js
Normal file
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* @author alteredq / http://alteredqualia.com/
|
||||
*/
|
||||
|
||||
THREE.FilmPass = function ( noiseIntensity, scanlinesIntensity, scanlinesCount, grayscale ) {
|
||||
|
||||
if ( THREE.FilmShader === undefined )
|
||||
console.error( "THREE.FilmPass relies on THREE.FilmShader" );
|
||||
|
||||
var shader = THREE.FilmShader;
|
||||
|
||||
this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
|
||||
|
||||
this.material = new THREE.ShaderMaterial( {
|
||||
|
||||
uniforms: this.uniforms,
|
||||
vertexShader: shader.vertexShader,
|
||||
fragmentShader: shader.fragmentShader
|
||||
|
||||
} );
|
||||
|
||||
if ( grayscale !== undefined ) this.uniforms.grayscale.value = grayscale;
|
||||
if ( noiseIntensity !== undefined ) this.uniforms.nIntensity.value = noiseIntensity;
|
||||
if ( scanlinesIntensity !== undefined ) this.uniforms.sIntensity.value = scanlinesIntensity;
|
||||
if ( scanlinesCount !== undefined ) this.uniforms.sCount.value = scanlinesCount;
|
||||
|
||||
this.enabled = true;
|
||||
this.renderToScreen = false;
|
||||
this.needsSwap = true;
|
||||
|
||||
|
||||
this.camera = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 );
|
||||
this.scene = new THREE.Scene();
|
||||
|
||||
this.quad = new THREE.Mesh( new THREE.PlaneGeometry( 2, 2 ), null );
|
||||
this.scene.add( this.quad );
|
||||
|
||||
};
|
||||
|
||||
THREE.FilmPass.prototype = {
|
||||
|
||||
render: function ( renderer, writeBuffer, readBuffer, delta ) {
|
||||
|
||||
this.uniforms[ "tDiffuse" ].value = readBuffer;
|
||||
this.uniforms[ "time" ].value += delta;
|
||||
|
||||
this.quad.material = this.material;
|
||||
|
||||
if ( this.renderToScreen ) {
|
||||
|
||||
renderer.render( this.scene, this.camera );
|
||||
|
||||
} else {
|
||||
|
||||
renderer.render( this.scene, this.camera, writeBuffer, false );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user