-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Fix material readiness to gate on light texture readiness #18255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -243,13 +243,16 @@ export class LightBlock extends NodeMaterialBlock { | |||||
| lightmapMode: false, | ||||||
| shadowEnabled: false, | ||||||
| specularEnabled: false, | ||||||
| lightTexturesReady: true, | ||||||
| }; | ||||||
|
|
||||||
| PrepareDefinesForLight(scene, mesh, this.light, this._lightId, defines, true, state); | ||||||
|
|
||||||
| if (state.needRebuild) { | ||||||
| defines.rebuild(); | ||||||
| } | ||||||
|
|
||||||
| defines._areLightTexturesReady = state.lightTexturesReady; | ||||||
|
||||||
| defines._areLightTexturesReady = state.lightTexturesReady; | |
| defines._areLightTexturesReady = defines._areLightTexturesReady !== false && state.lightTexturesReady; |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -834,13 +834,16 @@ export class PBRMetallicRoughnessBlock extends NodeMaterialBlock { | |||||
| lightmapMode: false, | ||||||
| shadowEnabled: false, | ||||||
| specularEnabled: false, | ||||||
| lightTexturesReady: true, | ||||||
| }; | ||||||
|
|
||||||
| PrepareDefinesForLight(scene, mesh, this.light, this._lightId, defines, true, state); | ||||||
|
|
||||||
| if (state.needRebuild) { | ||||||
| defines.rebuild(); | ||||||
| } | ||||||
|
|
||||||
| defines._areLightTexturesReady = state.lightTexturesReady; | ||||||
|
||||||
| defines._areLightTexturesReady = state.lightTexturesReady; | |
| defines._areLightTexturesReady = (defines._areLightTexturesReady ?? true) && state.lightTexturesReady; |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1194,6 +1194,10 @@ export abstract class PBRBaseMaterial extends PBRBaseMaterialBase { | |||||||||||||||||||||||||
| const lightDisposed = defines._areLightsDisposed; | ||||||||||||||||||||||||||
| const effect = this._prepareEffect(mesh, subMesh.getRenderingMesh(), defines, this.onCompiled, this.onError, useInstances, null); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| if (defines._areLightTexturesReady === false) { | ||||||||||||||||||||||||||
| return false; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
Comment on lines
1195
to
+1200
|
||||||||||||||||||||||||||
| const effect = this._prepareEffect(mesh, subMesh.getRenderingMesh(), defines, this.onCompiled, this.onError, useInstances, null); | |
| if (defines._areLightTexturesReady === false) { | |
| return false; | |
| } | |
| if (defines._areLightTexturesReady === false) { | |
| return false; | |
| } | |
| const effect = this._prepareEffect(mesh, subMesh.getRenderingMesh(), defines, this.onCompiled, this.onError, useInstances, null); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -667,6 +667,7 @@ export function PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, define | |
| lightmapMode: false, | ||
| shadowEnabled: false, | ||
| specularEnabled: false, | ||
| lightTexturesReady: true, | ||
| }; | ||
|
|
||
| if (scene.lightsEnabled && !disableLighting) { | ||
|
|
@@ -682,6 +683,7 @@ export function PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, define | |
|
|
||
| defines["SPECULARTERM"] = state.specularEnabled; | ||
| defines["SHADOWS"] = state.shadowEnabled; | ||
| defines._areLightTexturesReady = state.lightTexturesReady; | ||
|
|
||
| // Resetting all other lights if any | ||
| const maxLightCount = Math.max(maxSimultaneousLights, defines["MAXLIGHTCOUNT"] || 0); | ||
|
|
@@ -899,6 +901,7 @@ export function PrepareDefinesForLight( | |
| shadowEnabled: boolean; | ||
| specularEnabled: boolean; | ||
| lightmapMode: boolean; | ||
| lightTexturesReady: boolean; | ||
| } | ||
| ) { | ||
| state.needNormals = true; | ||
|
|
@@ -918,6 +921,10 @@ export function PrepareDefinesForLight( | |
|
|
||
| light.prepareLightSpecificDefines(defines, lightIndex); | ||
|
|
||
| if (!light.areLightTexturesReady()) { | ||
| state.lightTexturesReady = false; | ||
| } | ||
|
Comment on lines
921
to
+926
|
||
|
|
||
| // FallOff. | ||
| defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = false; | ||
| defines["LIGHT_FALLOFF_GLTF" + lightIndex] = false; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This readiness check uses
isReady(), which ignoresBaseTexture.isBlockingsemantics used elsewhere in material readiness (viaisReadyOrNotBlocking()). To avoid unexpectedly blockingscene.executeWhenReady()for explicitly non-blocking projection/IES textures, consider usingisReadyOrNotBlocking()here (or otherwise documenting/justifying why light textures should always be blocking).