Skip to content

Commit

Permalink
[Fix] Fix to non-clustered omni shadow rendering (#4972)
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Valigursky <mvaligursky@snapchat.com>
  • Loading branch information
mvaligursky and Martin Valigursky authored Jan 12, 2023
1 parent d423e8a commit d352818
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
4 changes: 3 additions & 1 deletion examples/src/examples/graphics/lights.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ class LightsExample {
// @ts-ignore
pc.TextureHandler,
// @ts-ignore
pc.ContainerHandler
pc.ContainerHandler,
// @ts-ignore
pc.CubemapHandler
];

const app = new pc.AppBase(canvas);
Expand Down
8 changes: 7 additions & 1 deletion src/platform/graphics/webgl/webgl-graphics-device.js
Original file line number Diff line number Diff line change
Expand Up @@ -1866,7 +1866,10 @@ class WebglGraphicsDevice extends GraphicsDevice {
}
// #endif

continue; // Because unset constants shouldn't raise random errors
Debug.errorOnce(`Shader [${shader.label}] requires texture sampler [${samplerName}] which has not been set, while rendering [${DebugGraphics.toString()}]`);

// skip this draw call to avoid incorrect rendering / webgl errors
return;
}

if (samplerValue instanceof Texture) {
Expand Down Expand Up @@ -1920,6 +1923,9 @@ class WebglGraphicsDevice extends GraphicsDevice {
// Call the function to commit the uniform value
if (scopeId.value !== null) {
this.commitFunction[uniform.dataType](uniform, scopeId.value);
} else {
// commented out till engine issue #4971 is sorted out
// Debug.warnOnce(`Shader [${shader.label}] requires uniform [${uniform.scopeId.name}] which has not been set, while rendering [${DebugGraphics.toString()}]`);
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/scene/renderer/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,9 @@ class Renderer {

// update shadow / cookie atlas allocation for the visible lights. Update it after the ligthts were culled,
// but before shadow maps were culling, as it might force some 'update once' shadows to cull.
this.updateLightTextureAtlas(comp);
if (this.scene.clusteredLightingEnabled) {
this.updateLightTextureAtlas(comp);
}

// cull shadow casters for all lights
this.cullShadowmaps(comp);
Expand Down
4 changes: 3 additions & 1 deletion src/scene/renderer/shadow-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,9 @@ class ShadowRenderer {
light.shadowUpdateMode = SHADOWUPDATE_NONE;
}

this.renderer._shadowMapUpdates += light.numShadowFaces;
if (needs) {
this.renderer._shadowMapUpdates += light.numShadowFaces;
}

return needs;
}
Expand Down

0 comments on commit d352818

Please sign in to comment.