From 79155fd547598a9983de4275bc57b5825244434e Mon Sep 17 00:00:00 2001 From: Mugen87 Date: Tue, 22 Jan 2019 11:08:15 +0100 Subject: [PATCH] Examples: Make SSAOPass WebGL 2 compatible. --- examples/js/postprocessing/SSAOPass.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/examples/js/postprocessing/SSAOPass.js b/examples/js/postprocessing/SSAOPass.js index 2421514f76..04c567ff08 100644 --- a/examples/js/postprocessing/SSAOPass.js +++ b/examples/js/postprocessing/SSAOPass.js @@ -369,19 +369,26 @@ THREE.SSAOPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), var simplex = new SimplexNoise(); var size = width * height; - var data = new Float32Array( size ); + var data = new Float32Array( size * 4 ); for ( var i = 0; i < size; i ++ ) { + var stride = i * 4; + var x = ( Math.random() * 2 ) - 1; var y = ( Math.random() * 2 ) - 1; var z = 0; - data[ i ] = simplex.noise3d( x, y, z ); + var noise = simplex.noise3d( x, y, z ); + + data[ stride ] = noise; + data[ stride + 1 ] = noise; + data[ stride + 2 ] = noise; + data[ stride + 3 ] = 1; } - this.noiseTexture = new THREE.DataTexture( data, width, height, THREE.LuminanceFormat, THREE.FloatType ); + this.noiseTexture = new THREE.DataTexture( data, width, height, THREE.RGBA, THREE.FloatType ); this.noiseTexture.wrapS = THREE.RepeatWrapping; this.noiseTexture.wrapT = THREE.RepeatWrapping; this.noiseTexture.needsUpdate = true; -- GitLab