topical media & game development
mobile-query-three-vendor-three-r53.js-postprocessing-FilmPass.js / js
author: alteredq / 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;
};
THREE.FilmPass.prototype = {
render: function ( renderer, writeBuffer, readBuffer, delta ) {
this.uniforms[ "tDiffuse" ].value = readBuffer;
this.uniforms[ "time" ].value += delta;
THREE.EffectComposer.quad.material = this.material;
if ( this.renderToScreen ) {
renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera );
} else {
renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera, writeBuffer, false );
}
}
};
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.