fix: [Graphics] Fix light component API #2215
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Details
LightComponent.Light.Shadow
is an abstractLightShadowMap
shared across all light types, the light rendering logic expects specific combination of shadow types per light types. So, users could setLightPointShadowMapRendererCubeMap
on a Directional Light for example, leading to unexpected rendering issue or exceptions.This change ensures that each light's shadow can only be set to a supported shadow map type.
Motivation and Context
Fixes poor usage of inheritance and composition principles. There's more work on the
XShadowMapRenderer
side, but while that logic isn't that well written, it won't crash on us.Types of changes
DirectLightBase
as that type has been removed, I could resurrect it as long as it doesn't implementIDirectLight
, but it wouldn't be very useful then.Checklist