mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-03 08:03:50 +00:00
Fix shadows not rendering until player moves by deferring shadow pass until character position is set
This commit is contained in:
parent
639df4815e
commit
6fc2c36dae
1 changed files with 8 additions and 0 deletions
|
|
@ -3705,7 +3705,13 @@ glm::mat4 Renderer::computeLightSpaceMatrix() {
|
||||||
// Keep a stable shadow focus center and move it smoothly toward the player
|
// Keep a stable shadow focus center and move it smoothly toward the player
|
||||||
// to avoid visible shadow "state jumps" during movement.
|
// to avoid visible shadow "state jumps" during movement.
|
||||||
glm::vec3 desiredCenter = characterPosition;
|
glm::vec3 desiredCenter = characterPosition;
|
||||||
|
// Don't initialize shadow center until the player has a real world position.
|
||||||
|
// characterPosition starts at (0,0,0) and gets set once the server places us.
|
||||||
if (!shadowCenterInitialized) {
|
if (!shadowCenterInitialized) {
|
||||||
|
if (glm::dot(desiredCenter, desiredCenter) < 1.0f) {
|
||||||
|
// Position not set yet — skip shadow rendering this frame.
|
||||||
|
return glm::mat4(0.0f);
|
||||||
|
}
|
||||||
shadowCenter = desiredCenter;
|
shadowCenter = desiredCenter;
|
||||||
shadowCenterInitialized = true;
|
shadowCenterInitialized = true;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -3860,6 +3866,8 @@ void Renderer::renderShadowPass() {
|
||||||
|
|
||||||
// Compute and store light space matrix; write to per-frame UBO
|
// Compute and store light space matrix; write to per-frame UBO
|
||||||
lightSpaceMatrix = computeLightSpaceMatrix();
|
lightSpaceMatrix = computeLightSpaceMatrix();
|
||||||
|
// Zero matrix means character position isn't set yet — skip shadow pass entirely.
|
||||||
|
if (lightSpaceMatrix == glm::mat4(0.0f)) return;
|
||||||
uint32_t frame = vkCtx->getCurrentFrame();
|
uint32_t frame = vkCtx->getCurrentFrame();
|
||||||
auto* ubo = reinterpret_cast<GPUPerFrameData*>(perFrameUBOMapped[frame]);
|
auto* ubo = reinterpret_cast<GPUPerFrameData*>(perFrameUBOMapped[frame]);
|
||||||
if (ubo) {
|
if (ubo) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue