Skip to content
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

ShadowGenerator: add doNotSerialize #16105

Merged
merged 3 commits into from
Jan 24, 2025
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
13 changes: 13 additions & 0 deletions packages/dev/core/src/Lights/Shadows/shadowGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ export interface ICustomShaderOptions {
export interface IShadowGenerator {
/** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
id: string;

/**
* Specifies if the `ShadowGenerator` should be serialized, `true` to skip serialization.
* Note a `ShadowGenerator` will not be serialized if its light has `doNotSerialize=true`
*/
doNotSerialize?: boolean;

/**
* Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
* @returns The render target texture if present otherwise, null
Expand Down Expand Up @@ -267,6 +274,12 @@ export class ShadowGenerator implements IShadowGenerator {
*/
public onAfterShadowMapRenderMeshObservable = new Observable<Mesh>();

/**
* Specifies if the `ShadowGenerator` should be serialized, `true` to skip serialization.
* Note a `ShadowGenerator` will not be serialized if its light has `doNotSerialize=true`
*/
public doNotSerialize = false;

protected _bias = 0.00005;
/**
* Gets the bias: offset applied on the depth preventing acnea (in light direction).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,17 @@ export class ShadowGeneratorSceneComponent implements ISceneSerializableComponen
serializationObject.shadowGenerators = [];
const lights = this.scene.lights;
for (const light of lights) {
if (light.doNotSerialize) {
continue;
}
const shadowGenerators = light.getShadowGenerators();
if (shadowGenerators) {
const iterator = shadowGenerators.values();
for (let key = iterator.next(); key.done !== true; key = iterator.next()) {
const shadowGenerator = key.value;
if (shadowGenerator.doNotSerialize) {
continue;
}
serializationObject.shadowGenerators.push(shadowGenerator.serialize());
}
}
Expand Down