fix: vegetation issues#2303
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThis PR removes the ChangesGrass Lighting and Collision Refactor
Sequence Diagram (high-level interaction between traversal, queue, update, GPU, and shaders): sequenceDiagram
participant Traversal
participant Queues
participant Update
participant GPU
participant Shader
Traversal->>Queues: stage bounding boxes & collisions
Update->>Queues: read queued data and sizes
Update->>GPU: upload structured buffers (if non-empty)
GPU->>Shader: shaders read updated buffers at draw time
🎯 4 (Complex) | ⏱️ ~60 minutes Possibly Related PRs
Suggested Reviewers
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Comment |
|
No actionable suggestions for changed features. |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
package/Shaders/RunGrass.hlsl (1)
619-623: 💤 Low valueRedundant
saturate()call.The
wrappedDirLightis already guaranteed to be in [0,1] range since the numerator usessaturate()and the denominator is ≥1. The outersaturate()on line 622 is unnecessary.♻️ Suggested simplification
float wrapAmount = saturate(input.VertexNormal.w * 10.0) * 0.5; float wrappedDirLight = saturate(dirLightAngle + wrapAmount) / (1.0 + wrapAmount); - lightsDiffuseColor += dirLightColor * dirDetailedShadow * saturate(wrappedDirLight) * Color::VanillaNormalization(); + lightsDiffuseColor += dirLightColor * dirDetailedShadow * wrappedDirLight * Color::VanillaNormalization();🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@package/Shaders/RunGrass.hlsl` around lines 619 - 623, The call to saturate on wrappedDirLight is redundant because wrappedDirLight is computed from saturate(dirLightAngle + wrapAmount) / (1.0 + wrapAmount) which already produces a value in [0,1]; remove the outer saturate and use wrappedDirLight directly in the multiply that updates lightsDiffuseColor (the expression involving wrappedDirLight, dirLightColor, dirDetailedShadow, and Color::VanillaNormalization())—adjust the line that currently multiplies by saturate(wrappedDirLight) to multiply by wrappedDirLight instead.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/Features/GrassCollision.cpp`:
- Line 191: The variable `context` (initialized from `globals::d3d::context`) is
declared twice in the same scope causing a redefinition error; remove the
duplicate declaration and reuse the existing `context` variable instead (either
delete the later `auto context = globals::d3d::context;` or delete this earlier
one and ensure all uses reference the single consolidated `context`), updating
any subsequent usages in the `GrassCollision` function so they refer to the
single `context` identifier.
---
Nitpick comments:
In `@package/Shaders/RunGrass.hlsl`:
- Around line 619-623: The call to saturate on wrappedDirLight is redundant
because wrappedDirLight is computed from saturate(dirLightAngle + wrapAmount) /
(1.0 + wrapAmount) which already produces a value in [0,1]; remove the outer
saturate and use wrappedDirLight directly in the multiply that updates
lightsDiffuseColor (the expression involving wrappedDirLight, dirLightColor,
dirDetailedShadow, and Color::VanillaNormalization())—adjust the line that
currently multiplies by saturate(wrappedDirLight) to multiply by wrappedDirLight
instead.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: e5d2d346-92cb-445e-9f16-5761f5e4c3ab
📒 Files selected for processing (9)
package/Shaders/Common/LightingCommon.hlslipackage/Shaders/Common/LightingEval.hlslipackage/Shaders/Common/SharedData.hlslipackage/Shaders/Lighting.hlslpackage/Shaders/RunGrass.hlslsrc/Features/GrassCollision.cppsrc/Features/GrassCollision.hsrc/Features/GrassLighting.cppsrc/Features/GrassLighting.h
💤 Files with no reviewable changes (1)
- src/Features/GrassLighting.cpp
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
♻️ Duplicate comments (1)
src/Features/GrassCollision.cpp (1)
191-212:⚠️ Potential issue | 🔴 Critical | ⚡ Quick winRemove the duplicated collision-upload wrapper.
There’s an extra
if (!queuedCollisions.empty()) {here. That leaves the braces unbalanced and pushes the latercontextdeclaration into the wrong scope, so this version ofUpdate()will not compile.Proposed fix
- if (!queuedCollisions.empty()) { - auto context = globals::d3d::context; - D3D11_MAPPED_SUBRESOURCE mapped; - - if (!queuedCollisions.empty()) { + auto context = globals::d3d::context; + + if (!queuedCollisions.empty()) { D3D11_MAPPED_SUBRESOURCE mapped; DX::ThrowIfFailed(context->Map(collisionInstances->resource.get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped)); size_t bytes = sizeof(float4) * queuedCollisions.size(); memcpy_s(mapped.pData, bytes, queuedCollisions.data(), bytes); context->Unmap(collisionInstances->resource.get(), 0); @@ queuedBoundingBoxes.clear(); queuedCollisions.clear();🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/Features/GrassCollision.cpp` around lines 191 - 212, The duplicate if wrapper around queuedCollisions should be removed so braces and scope are correct: delete the extra "if (!queuedCollisions.empty()) {" and its unmatched brace so the single collision upload block uses the already-declared context and maps collisionInstances correctly; ensure the block that maps collisionInstances (using DX::ThrowIfFailed(context->Map(collisionInstances->resource.get(), ...))) is the only check for queuedCollisions, and that the subsequent mapping of collisionBoundingBoxes (using collisionBoundingBoxes, perFrameData.BoundingBoxCount, queuedBoundingBoxes) remains intact before clearing queuedBoundingBoxes and queuedCollisions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Duplicate comments:
In `@src/Features/GrassCollision.cpp`:
- Around line 191-212: The duplicate if wrapper around queuedCollisions should
be removed so braces and scope are correct: delete the extra "if
(!queuedCollisions.empty()) {" and its unmatched brace so the single collision
upload block uses the already-declared context and maps collisionInstances
correctly; ensure the block that maps collisionInstances (using
DX::ThrowIfFailed(context->Map(collisionInstances->resource.get(), ...))) is the
only check for queuedCollisions, and that the subsequent mapping of
collisionBoundingBoxes (using collisionBoundingBoxes,
perFrameData.BoundingBoxCount, queuedBoundingBoxes) remains intact before
clearing queuedBoundingBoxes and queuedCollisions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 470558b2-bee2-4d59-a888-11bab92cfb3f
📒 Files selected for processing (1)
src/Features/GrassCollision.cpp
|
✅ A pre-release build is available for this PR: |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@package/Shaders/Lighting.hlsl`:
- Around line 2896-2901: The DisableTerrainVertexColors branch is applied too
late and only removes tint after vertexAO/skylightingDiffuse have already been
derived from the original vertexColor; move the terrain-vertex-color override
(the SharedData::lodBlendingSettings.DisableTerrainVertexColors check that sets
vertexColor = 1 or normalizes it) to before the skylight AO/sky lighting diffuse
calculations (where vertexAO and skylightingDiffuse are computed, under
LANDSCAPE and SKYLIGHTING permutations), or alternatively ensure
vertexAO/skylightingDiffuse are recomputed from the modified vertexColor
immediately after this branch so skylight darkening respects
DisableTerrainVertexColors.
In `@package/Shaders/RunGrass.hlsl`:
- Around line 750-752: The soft-light/subsurface term is being tinted by albedo
twice (subsurfaceColor * albedo on line with subsurfaceColor, then whole
diffuseColor *= albedo), causing albedo² darkening; fix by applying albedo only
once — either remove the * albedo from the subsurface addition (change
"diffuseColor += subsurfaceColor * albedo" to "diffuseColor += subsurfaceColor")
or move the final albedo multiplication so it only multiplies the intended base
diffuse contribution rather than re-tinting the subsurface term (adjust use of
diffuseColor *= albedo accordingly), referencing the diffuseColor,
directionalAmbientColor, subsurfaceColor and albedo symbols.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 03e7b54d-66cd-4af9-9cab-0a31dfaf975d
📒 Files selected for processing (3)
package/Shaders/Lighting.hlslpackage/Shaders/RunGrass.hlslsrc/Features/GrassLighting.h
|
what is the reason to remove the wrapped lighting toggle? |
soft lighting is the vanilla form of wrapped lighting |
alandtse
left a comment
There was a problem hiding this comment.
Please add the VR offset and should be good.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Summary by CodeRabbit
Bug Fixes
Changes
Chores