-
Notifications
You must be signed in to change notification settings - Fork 2k
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
fix disabled shadow inconsistency #17337
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d67a878
fix disabled shadow inconsistency
star-e 6f59730
Merge branch 'v3.8.4' into v3.8.4-fix-disabled-shadow
star-e ffa5479
Merge branch 'v3.8.4' into v3.8.4-fix-disabled-shadow
star-e b84099e
change planar shadow order
star-e 10f5d91
Revert "change planar shadow order"
star-e 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,6 @@ | |
#include "cocos/renderer/pipeline/PipelineSceneData.h" | ||
#include "cocos/renderer/pipeline/custom/LayoutGraphTypes.h" | ||
#include "cocos/renderer/pipeline/custom/NativePipelineTypes.h" | ||
#include "cocos/renderer/pipeline/custom/NativeTypes.h" | ||
#include "cocos/renderer/pipeline/custom/NativeUtils.h" | ||
#include "cocos/renderer/pipeline/custom/RenderGraphTypes.h" | ||
#include "cocos/renderer/pipeline/custom/details/GslUtils.h" | ||
|
@@ -792,47 +791,24 @@ void setLightUBO( | |
} | ||
} | ||
|
||
const BuiltinCascadedShadowMap *getBuiltinShadowCSM( | ||
const PipelineRuntime &pplRuntime, | ||
const scene::Camera &camera, | ||
const scene::DirectionalLight *mainLight) { | ||
const auto &ppl = dynamic_cast<const NativePipeline &>(pplRuntime); | ||
// no main light | ||
if (!mainLight) { | ||
return nullptr; | ||
} | ||
// not attached to a node | ||
if (!mainLight->getNode()) { | ||
return nullptr; | ||
} | ||
const pipeline::PipelineSceneData &pplSceneData = *pplRuntime.getPipelineSceneData(); | ||
auto &csmLayers = *pplSceneData.getCSMLayers(); | ||
const auto &shadows = *pplSceneData.getShadows(); | ||
// shadow not enabled | ||
if (!shadows.isEnabled()) { | ||
return nullptr; | ||
} | ||
// shadow type is planar | ||
if (shadows.getType() == scene::ShadowType::PLANAR) { | ||
return nullptr; | ||
} | ||
|
||
// find csm | ||
const BuiltinCascadedShadowMapKey key{&camera, mainLight}; | ||
auto iter = ppl.builtinCSMs.find(key); | ||
if (iter != ppl.builtinCSMs.end()) { | ||
return &iter->second; | ||
} | ||
namespace { | ||
|
||
const BuiltinCascadedShadowMap *addBuiltinCSMInfo( | ||
const NativePipeline &ppl, | ||
const pipeline::PipelineSceneData &pplSceneData, | ||
const scene::Camera &camera, | ||
const scene::DirectionalLight *mainLight, | ||
const BuiltinCascadedShadowMapKey &key, | ||
pipeline::CSMLayers& csmLayers) { | ||
// add new csm info | ||
bool added = false; | ||
std::tie(iter, added) = ppl.builtinCSMs.emplace( | ||
auto res = ppl.builtinCSMs.emplace( | ||
std::piecewise_construct, | ||
std::forward_as_tuple(key), | ||
std::forward_as_tuple()); | ||
CC_ENSURES(added); | ||
CC_ENSURES(res.second); | ||
|
||
auto &csm = iter->second; | ||
auto &csm = res.first->second; | ||
|
||
// update csm layers | ||
csmLayers.update(&pplSceneData, &camera); | ||
|
@@ -873,6 +849,51 @@ const BuiltinCascadedShadowMap *getBuiltinShadowCSM( | |
return &csm; | ||
} | ||
|
||
} // namespace | ||
|
||
const BuiltinCascadedShadowMap *getBuiltinShadowCSM( | ||
const PipelineRuntime &pplRuntime, | ||
const scene::Camera &camera, | ||
const scene::DirectionalLight *mainLight) { | ||
const auto &ppl = dynamic_cast<const NativePipeline &>(pplRuntime); | ||
// no main light | ||
if (!mainLight) { | ||
return nullptr; | ||
} | ||
// not attached to a node | ||
if (!mainLight->getNode()) { | ||
return nullptr; | ||
} | ||
|
||
const pipeline::PipelineSceneData &pplSceneData = *pplRuntime.getPipelineSceneData(); | ||
auto &csmLayers = *pplSceneData.getCSMLayers(); | ||
const auto &shadows = *pplSceneData.getShadows(); | ||
|
||
// shadow type is planar | ||
if (shadows.getType() == scene::ShadowType::PLANAR) { | ||
return nullptr; | ||
} | ||
|
||
const BuiltinCascadedShadowMap *result = nullptr; | ||
{ // find or create csm info | ||
const BuiltinCascadedShadowMapKey key{&camera, mainLight}; | ||
auto iter = ppl.builtinCSMs.find(key); | ||
if (iter != ppl.builtinCSMs.end()) { | ||
result = &iter->second; | ||
} else { | ||
result = addBuiltinCSMInfo(ppl, pplSceneData, camera, mainLight, key, csmLayers); | ||
} | ||
} | ||
CC_ENSURES(result); | ||
|
||
// shadow not enabled | ||
if (!shadows.isEnabled()) { | ||
return nullptr; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can also check it as soon as possible. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check shadow not enabled earlier caused the mismatch. When doing the rendering, csm info is always needed. |
||
|
||
return result; | ||
} | ||
|
||
const geometry::Frustum &getBuiltinShadowFrustum( | ||
const PipelineRuntime &pplRuntime, | ||
const scene::Camera &camera, | ||
|
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.
Always insert csm info.