|
@@ -193,7 +193,10 @@ THREE.LensFlarePlugin = function ( renderer, flares ) {
|
|
var screenPosition = new THREE.Vector3( 1, 1, 0 ),
|
|
var screenPosition = new THREE.Vector3( 1, 1, 0 ),
|
|
screenPositionPixels = new THREE.Vector2( 1, 1 );
|
|
screenPositionPixels = new THREE.Vector2( 1, 1 );
|
|
|
|
|
|
- var areaToCopy = new THREE.Vector2();
|
|
|
|
|
|
+ var validArea = new THREE.Box2();
|
|
|
|
+
|
|
|
|
+ validArea.min.set( 0, 0 );
|
|
|
|
+ validArea.max.set( viewport.z - 16, viewport.w - 16 );
|
|
|
|
|
|
if ( program === undefined ) {
|
|
if ( program === undefined ) {
|
|
|
|
|
|
@@ -241,18 +244,14 @@ THREE.LensFlarePlugin = function ( renderer, flares ) {
|
|
|
|
|
|
screenPosition.copy( tempPosition );
|
|
screenPosition.copy( tempPosition );
|
|
|
|
|
|
- screenPositionPixels.x = screenPosition.x * halfViewportWidth + halfViewportWidth;
|
|
|
|
- screenPositionPixels.y = screenPosition.y * halfViewportHeight + halfViewportHeight;
|
|
|
|
|
|
+ // horizontal and vertical coordinate of the lower left corner of the pixels to copy
|
|
|
|
|
|
- areaToCopy.x = viewport.x + screenPositionPixels.x - 8; // horizontal coordinate of the lower left corner of the pixels to copy
|
|
|
|
- areaToCopy.y = viewport.y + screenPositionPixels.y - 8; // vertical coordinate of the lower left corner of the pixels to copy
|
|
|
|
|
|
+ screenPositionPixels.x = viewport.x + ( screenPosition.x * halfViewportWidth ) + halfViewportWidth - 8;
|
|
|
|
+ screenPositionPixels.y = viewport.y + ( screenPosition.y * halfViewportHeight ) + halfViewportHeight - 8;
|
|
|
|
|
|
// screen cull
|
|
// screen cull
|
|
|
|
|
|
- if ( areaToCopy.x > 0 &&
|
|
|
|
- areaToCopy.x < ( viewport.z - 16 ) &&
|
|
|
|
- areaToCopy.y > 0 &&
|
|
|
|
- areaToCopy.y < ( viewport.w - 16 ) ) {
|
|
|
|
|
|
+ if ( validArea.containsPoint( screenPositionPixels ) === true ) {
|
|
|
|
|
|
// save current RGB to temp texture
|
|
// save current RGB to temp texture
|
|
|
|
|
|
@@ -260,7 +259,7 @@ THREE.LensFlarePlugin = function ( renderer, flares ) {
|
|
state.bindTexture( gl.TEXTURE_2D, null );
|
|
state.bindTexture( gl.TEXTURE_2D, null );
|
|
state.activeTexture( gl.TEXTURE1 );
|
|
state.activeTexture( gl.TEXTURE1 );
|
|
state.bindTexture( gl.TEXTURE_2D, tempTexture );
|
|
state.bindTexture( gl.TEXTURE_2D, tempTexture );
|
|
- gl.copyTexImage2D( gl.TEXTURE_2D, 0, gl.RGB, areaToCopy.x, areaToCopy.y, 16, 16, 0 );
|
|
|
|
|
|
+ gl.copyTexImage2D( gl.TEXTURE_2D, 0, gl.RGB, screenPositionPixels.x, screenPositionPixels.y, 16, 16, 0 );
|
|
|
|
|
|
|
|
|
|
// render pink quad
|
|
// render pink quad
|
|
@@ -279,7 +278,7 @@ THREE.LensFlarePlugin = function ( renderer, flares ) {
|
|
|
|
|
|
state.activeTexture( gl.TEXTURE0 );
|
|
state.activeTexture( gl.TEXTURE0 );
|
|
state.bindTexture( gl.TEXTURE_2D, occlusionTexture );
|
|
state.bindTexture( gl.TEXTURE_2D, occlusionTexture );
|
|
- gl.copyTexImage2D( gl.TEXTURE_2D, 0, gl.RGBA, areaToCopy.x, areaToCopy.y, 16, 16, 0 );
|
|
|
|
|
|
+ gl.copyTexImage2D( gl.TEXTURE_2D, 0, gl.RGBA, screenPositionPixels.x, screenPositionPixels.y, 16, 16, 0 );
|
|
|
|
|
|
|
|
|
|
// restore graphics
|
|
// restore graphics
|