Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/materials/nodes/NodeMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,12 @@ class NodeMaterial extends Material {

const materialLightsNode = [];

if ( builder.renderer.lighting.enabled === false ) {

return materialLightsNode;

}

//

const envNode = this.setupEnvironment( builder );
Expand Down
15 changes: 15 additions & 0 deletions src/renderers/common/Lighting.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@ const _weakMap = /*@__PURE__*/ new WeakMap();
*/
class Lighting {

/**
* Constructs a new lighting manager.
*/
constructor() {

/**
* Whether this lighting manager is enabled or not.
*
* @type {boolean}
* @default true
*/
this.enabled = true;

}

/**
* Creates a new lights node for the given array of lights.
*
Expand Down
11 changes: 10 additions & 1 deletion src/renderers/common/RenderList.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { DoubleSide } from '../../constants.js';

const _emptyArray = /*@__PURE__*/ Object.freeze( [] );

/**
* Default sorting function for opaque render items.
*
Expand Down Expand Up @@ -144,6 +146,13 @@ class RenderList {
*/
this.bundles = [];

/**
* The lighting management component.
*
* @type {Lighting}
*/
this.lighting = lighting;

/**
* The render list's lights node. This node is later
* relevant for the actual analytical light nodes which
Expand Down Expand Up @@ -384,7 +393,7 @@ class RenderList {

// update lights

this.lightsNode.setLights( this.lightsArray );
this.lightsNode.setLights( this.lighting.enabled ? this.lightsArray : _emptyArray );

// Clear references from inactive renderItems in the list

Expand Down
25 changes: 17 additions & 8 deletions src/renderers/common/nodes/NodeManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,8 @@ class NodeManager extends DataMap {
*/
getEnvironmentNode( scene ) {

if ( this.renderer.lighting.enabled === false ) return null;

this.updateEnvironment( scene );

let environmentNode = null;
Expand Down Expand Up @@ -590,16 +592,23 @@ class NodeManager extends DataMap {

if ( cacheKeyData.callId !== callId ) {

const environmentNode = this.getEnvironmentNode( scene );
const fogNode = this.getFogNode( scene );
_cacheKeyValues.push( this.renderer.getOutputRenderTarget() && this.renderer.getOutputRenderTarget().multiview ? 1 : 0 );
_cacheKeyValues.push( this.renderer.lighting.enabled ? 1 : 0 );

if ( lightsNode ) _cacheKeyValues.push( lightsNode.getCacheKey( true ) );
if ( environmentNode ) _cacheKeyValues.push( environmentNode.getCacheKey() );
if ( fogNode ) _cacheKeyValues.push( fogNode.getCacheKey() );
if ( this.renderer.lighting.enabled ) {

_cacheKeyValues.push( this.renderer.getOutputRenderTarget() && this.renderer.getOutputRenderTarget().multiview ? 1 : 0 );
_cacheKeyValues.push( this.renderer.shadowMap.enabled ? 1 : 0 );
_cacheKeyValues.push( this.renderer.shadowMap.type );
_cacheKeyValues.push( lightsNode.getCacheKey( true ) );

_cacheKeyValues.push( this.renderer.shadowMap.enabled ? 1 : 0 );
_cacheKeyValues.push( this.renderer.shadowMap.type );

const environmentNode = this.getEnvironmentNode( scene );
if ( environmentNode ) _cacheKeyValues.push( environmentNode.getCacheKey() );

}

const fogNode = this.getFogNode( scene );
if ( fogNode ) _cacheKeyValues.push( fogNode.getCacheKey() );

cacheKeyData.callId = callId;
cacheKeyData.cacheKey = hashArray( _cacheKeyValues );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ IncidentLight directLight;
#ifdef USE_LIGHT_PROBES_GRID

vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz;
vec3 probeWorldNormal = inverseTransformDirection( geometryNormal, viewMatrix );
vec3 probeWorldNormal = transformNormalByInverseViewMatrix( geometryNormal, viewMatrix );
irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal );

#endif
Expand Down
7 changes: 5 additions & 2 deletions test/e2e/puppeteer.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ async function preparePage( page, injection, builds, errorMessages ) {
async function checkFile( ctx, failedScreenshots, cleanPage, isMakeScreenshot, file ) {

const page = ctx.page;
const pageStart = performance.now();

try {

Expand Down Expand Up @@ -503,6 +504,8 @@ async function checkFile( ctx, failedScreenshots, cleanPage, isMakeScreenshot, f

}

const pageElapsed = ( performance.now() - pageStart ) / 1000;

const screenshot = ( await Image.read( await page.screenshot() ) ).scale( 1 / viewScale );

if ( page.error !== undefined ) throw new Error( page.error );
Expand Down Expand Up @@ -555,14 +558,14 @@ async function checkFile( ctx, failedScreenshots, cleanPage, isMakeScreenshot, f

if ( differentPixels < maxDifferentPixels ) {

console.green( `Diff ${ differentPixels.toFixed( 1 ) }% in file: ${ file }` );
console.green( `Diff ${ differentPixels.toFixed( 1 ) }% in file: ${ file } (${ pageElapsed.toFixed( 1 ) }s)` );

} else {

await screenshot.write( `test/e2e/output-screenshots/${ file }-actual.jpg`, jpgQuality );
await expected.write( `test/e2e/output-screenshots/${ file }-expected.jpg`, jpgQuality );
await diff.write( `test/e2e/output-screenshots/${ file }-diff.jpg`, jpgQuality );
throw new Error( `Diff wrong in ${ differentPixels.toFixed( 1 ) }% of pixels in file: ${ file }` );
throw new Error( `Diff wrong in ${ differentPixels.toFixed( 1 ) }% of pixels in file: ${ file } (${ pageElapsed.toFixed( 1 ) }s)` );

}

Expand Down