fix(terrain-helper): restore parallax vs TruePBR#2401
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughTerrainHelper reorders hook installation by adding a new Load() lifecycle method to install the TESObjectLAND detour earlier (moved from PostPostLoad). PostPostLoad now only installs the BSLightingShader::SetupMaterial vfunc hook. The TESObjectLAND thunk now invokes TerrainHelper::TESObjectLAND_SetupMaterial when the original call succeeds and terrainHelper.loaded is true (removing the TruePBR flag check). ChangesTerrainHelper Hook Installation and Timing
Sequence Diagram(s)sequenceDiagram
participant TerrainHelper
participant HookInstaller
participant BSLightingShader
TerrainHelper->>HookInstaller: TerrainHelper::Load() installs TESObjectLAND_SetupMaterial detour
TerrainHelper->>BSLightingShader: PostPostLoad installs BSLightingShader::SetupMaterial vfunc hook
sequenceDiagram
participant TH_TESObjectLAND_SetupMaterial
participant TerrainHelper
TH_TESObjectLAND_SetupMaterial->>TerrainHelper: call TerrainHelper::TESObjectLAND_SetupMaterial(land) when result==true && terrainHelper.loaded
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
No actionable suggestions for changed features. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/Features/TerrainHelper.cpp (1)
227-233: ⚡ Quick winRework: TerrainHelper::Load TESObjectLAND hook VR gating is likely consistent with TruePBR
TerrainHelper::Load()unconditionally installsstl::detour_thunk<TH_TESObjectLAND_SetupMaterial>(REL::RelocationID(18368, 18791))(src/Features/TerrainHelper.cpp:227-233), and the feature is included in VR viaTerrainHelper::SupportsVR() == true+ VR feature filtering (src/Features/TerrainHelper.h:43, src/Feature.cpp:260).- The same TESObjectLAND detour target (
REL::RelocationID(18368, 18791)) is already used unconditionally byTruePBR::TESObjectLAND_SetupMaterial(src/TruePBR.cpp:1508-1510), so the relocation pair is already treated as VR-compatible by the codebase.- Optional: add a short comment in
TerrainHelper::Load()pointing out this intentional alignment withTruePBR(only addREL::Module::IsVR()gating if VR offsets are known to diverge for this callsite).🤖 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/TerrainHelper.cpp` around lines 227 - 233, TerrainHelper::Load currently installs the TESObjectLAND detour unconditionally using stl::detour_thunk<TH_TESObjectLAND_SetupMaterial>(REL::RelocationID(18368, 18791)), which mirrors the same relocation used by TruePBR::TESObjectLAND_SetupMaterial; update TerrainHelper::Load to keep the existing unconditional detour but add a short clarifying comment that this is intentionally aligned with TruePBR's detour (same REL::RelocationID(18368, 18791)) and therefore does not require additional REL::Module::IsVR() gating here unless VR offsets diverge in the future.
🤖 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.
Nitpick comments:
In `@src/Features/TerrainHelper.cpp`:
- Around line 227-233: TerrainHelper::Load currently installs the TESObjectLAND
detour unconditionally using
stl::detour_thunk<TH_TESObjectLAND_SetupMaterial>(REL::RelocationID(18368,
18791)), which mirrors the same relocation used by
TruePBR::TESObjectLAND_SetupMaterial; update TerrainHelper::Load to keep the
existing unconditional detour but add a short clarifying comment that this is
intentionally aligned with TruePBR's detour (same REL::RelocationID(18368,
18791)) and therefore does not require additional REL::Module::IsVR() gating
here unless VR offsets diverge in the future.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 32c1d4b2-4a65-49af-9ce5-8d97b9a60b47
📒 Files selected for processing (2)
src/Features/TerrainHelper.cppsrc/Features/TerrainHelper.h
|
✅ A pre-release build is available for this PR: |
bb6460d
into
community-shaders:dev
Summary
TESObjectLANDhook was installed inPostPostLoad(), whichruns after TruePBR (feature index 0) had already installed its own hook. With
stl::detour_thunk, last-installed is outermost, so the call chain wasengine → TH_thunk → PBR_thunk → vanilla. TH calledfunc(land)first,which let PBR replace the geometry's
shaderPropertywith a newBSLightingShaderMaterialPBRLandscapeand setOBJ_LAND::Flag(8). TH'sflag-8 guard then skipped the cell, leaving
extendedSlotsempty andparallax never activating — even on vanilla land — whenever a mod supplies
the
DefaultPBRLandEDID (which causes TruePBR to claim all default-texturedquads as PBR).
TESObjectLANDhook install toLoad(), which runs atDLL-load time before any feature's
PostPostLoad(). TH is now the innerhook (
engine → PBR_thunk → TH_thunk → vanilla). TH reads the vanillamaterial's
hashKeybefore TruePBR replaces theshaderProperty, storesparallax data for that key, and returns. TruePBR then runs and may replace
the material with a PBR one. For PBR land,
BSLightingShader::SetupMaterialis called with the PBR material's
hashKey, which doesn't match TH's storedvanilla key → TH does nothing. For vanilla land, the key matches → parallax
activates correctly.
OBJ_LAND::Flag(8)guard from the hook thunk — flag 8is never set at the point TH runs in the new order.
Summary by CodeRabbit
Bug Fixes
Chores