Skip to content

Add shadowCascadeMask to the render component - #9195

Merged
mvaligursky merged 1 commit into
mainfrom
mv-render-cascade-mask
Aug 19, 2026
Merged

Add shadowCascadeMask to the render component#9195
mvaligursky merged 1 commit into
mainfrom
mv-render-cascade-mask

Conversation

@mvaligursky

@mvaligursky mvaligursky commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Exposes the per-mesh directional shadow cascade mask on the render component, so selecting which cascades an entity casts into no longer requires walking its mesh instances from a script. Fixes #9126.

Changes:

  • RenderComponent#shadowCascadeMask is assigned to every mesh instance the component manages, including ones created later by an asset load or a type change.
  • The property is part of the component's property list, so it is initialized from addComponent data and preserved when an entity is cloned.
  • Added render component tests covering the default value, initialization from component data, propagation to existing and to newly created mesh instances, and cloning.

API Changes:

  • Added RenderComponent#shadowCascadeMask, defaulting to SHADOW_CASCADE_ALL. Combine SHADOW_CASCADE_0 .. SHADOW_CASCADE_3 to select individual cascades, and note that this only filters the meshes per cascade - use castShadows to disable shadow casting completely.
// only cast shadows into the two cascades closest to the camera
entity.render.shadowCascadeMask = pc.SHADOW_CASCADE_0 | pc.SHADOW_CASCADE_1;

ModelComponent is deliberately left alone as it is legacy, and the gsplat component cannot support this in unified mode, where shadow casters are registered per placement and rendered through a single shared mesh instance.

Exposes MeshInstance#shadowCascadeMask on the render component, so selecting which directional shadow cascades an entity casts into no longer requires walking its mesh instances from a script.
@github-actions

Copy link
Copy Markdown

Public API report

This PR changes the public API surface (+2 / −0), per the docs' rules (@ignore / @Private / undocumented are excluded).

Show API diff
+RenderComponent.get shadowCascadeMask(): number
+RenderComponent.set shadowCascadeMask(value: number)

Informational only — this never fails the build.

@github-actions

Copy link
Copy Markdown

Build size report

This PR changes the size of the minified bundles.

Bundle Minified Gzip Brotli
playcanvas.min.js 2369.6 KB (+0.3 KB, +0.01%) 608.7 KB (+0.1 KB, +0.01%) 472.6 KB (−0.1 KB, −0.02%)
playcanvas.min.mjs 2366.9 KB (+0.3 KB, +0.01%) 607.6 KB (+0.0 KB, +0.01%) 471.9 KB (−0.3 KB, −0.06%)

@mvaligursky mvaligursky left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated PR review by Codex (GPT-5).

No actionable issues found.

Reviewed the change from the merge base for correctness, public API compatibility, component initialization and clone ordering, primitive and asset-driven mesh replacement, directional-shadow semantics, batching interactions, performance, documentation, and test coverage. The component-level value is retained independently of the current mesh instances and is consistently propagated through the shared meshInstances setter, so later primitive recreation and render-asset mesh updates inherit it. Adding the property to the ordered system property list also covers initialization and cloning without changing existing defaults.

Local verification on the exact head commit: the focused RenderComponent test suite passed (8 tests), ESLint passed for all changed files, generated TypeScript declarations include the new getter/setter, test:types passed, and git diff --check passed. All current GitHub checks are green.

@mvaligursky
mvaligursky merged commit ccaf05e into main Aug 19, 2026
10 checks passed
@mvaligursky
mvaligursky deleted the mv-render-cascade-mask branch August 19, 2026 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improvement shadowCascadeMask

1 participant