-
Notifications
You must be signed in to change notification settings - Fork 78
Update Tr2LightManager.cpp #113
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
Open
CCPNobody
wants to merge
2
commits into
main
Choose a base branch
from
PLAT-11658
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
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.
There are issues with this approach:
We have a limit on volumetric and shadowcasting lights. Volumetric lights outside the frustum now compete with lights inside the frustum.
So for starters, we will have less volumetric lights on the screen, as large lights outside the frustum may very well be prioritized over small lights inside the frustum.
But in particular, (volumetric) shadowcasting lights outside the frustum may be prioritized over shadowcasting lights inside the frustum.
However, look at Tr2VolumetricsRenderer::RenderFogIntoReflectionMap
It calls RenderFog with ShadowQuality::SHADOW_DISABLED
Due to that, RenderFog sets shadowType = SHADOWS_DISABLED;
And then it sets resources.calculateFroxels->SetOption with "SHADOWS_DISABLED"
So you end up evicting valid shadow casters with ones that aren't visible, neither in main frustum nor in reflections - but they do cost performance, as their shadow maps will be rendered and put into the atlas! So you pay the cost for rasterization, and atlas space. And the atlas space will affect visual quality, as other lights may have their shadow maps scaled down to make space, when the atlas gets pretty full.
Also, this line in particular causes volumetric lights to have another size calculated than non-volumetric lights, and therefore the dimming factor will be different. And this is not only affecting lights in reflections, but in main frustum too! And dimming affects light color, so stuff lit by the light will look different, too.
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.
All of your points are valid btw.
I would love suggestions, as I don't have a clear solution on how to solve these things (yet, still thinking)
Uh oh!
There was an error while loading. Please reload this page.
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.
Regarding 2: As it stands, shadow casting lights are not affecting reflections, so if they are outside the frustum, they are not visible anywhere. So, unless that is subject to change as well:
You can see me removing the shadow casting flag based on quality settings in Tr2LightManager::AddLight. Similarly, you could remove the flag if the light is volumetric and outside the frustum. Then those (former shadow casting) lights would not affect performance anymore.
Regarding 3: If you always use GetPixelSizeAccrossEst, regardless whether a light is volumetric or not, then it's not inconsistent anymore.
Regarding 1: Not sure myself yet. Maybe it requires a different approach altogether. Currently the volumetric lights are selected in Tr2LightManager::ResolveLightData and stored in m_volumetricLights. Maybe we need to create a list for main frustum, and a list for reflection probe. Or 6 lists for the 6 sides of the reflection probe... VolumetricsRenderer currently gets the lights in Tr2VolumetricsRenderer::UpdatePerObjectData by calling Tr2LightManager::GetVolumetricLights.