fix(emat): detect bad format textures#2032
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:
📝 WalkthroughWalkthroughBroadened the compile-time gating for the EMAT envmap path to Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Automated formatting by clang-format, prettier, and other hooks. See https://pre-commit.ci for details.
|
No actionable suggestions for changed features. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@package/Shaders/Lighting.hlsl`:
- Around line 1087-1095: The current detection samples envMaskTest via
TexEnvMaskSampler.SampleLevel(..., 15) and then uses its RGB to decide if the
texture is single-channel, but LOD 15 is over-averaged; change the logic to
sample RGB at a high-detail mip (e.g., SampleLevel with LOD 0) for the
RGB-similarity check while retaining the existing LOD 15 sample for the alpha
threshold test: call TexEnvMaskSampler.SampleLevel(SampEnvMaskSampler, uv, 0)
into a new local (e.g., envMaskDetail) and use envMaskDetail.x/y/z for the
abs(...) comparisons, keeping envMaskTest.w (from the LOD 15 sample) for the
complexMaterial alpha checks.
🪄 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
Run ID: 9cd5a222-5bee-4e00-bf18-6932c263484d
📒 Files selected for processing (1)
package/Shaders/Lighting.hlsl
|
✅ A pre-release build is available for this PR: |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@package/Shaders/Lighting.hlsl`:
- Line 1089: The HLSL scope operator is incorrect in the SampleBias call causing
compile failure; replace the single colon usage with the C++/HLSL scope
resolution operator so the call uses SharedData::MipBias; edit the line invoking
TexEnvMaskSampler.SampleBias (referencing SampEnvMaskSampler, uv and
SharedData::MipBias) to use SharedData::MipBias instead of SharedData:MipBias so
the shader compiles.
🪄 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
Run ID: 21b102a9-c844-4fb7-9205-47015260005a
📒 Files selected for processing (1)
package/Shaders/Lighting.hlsl
Automated formatting by clang-format, prettier, and other hooks. See https://pre-commit.ci for details.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Automated formatting by clang-format, prettier, and other hooks. See https://pre-commit.ci for details.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@package/Shaders/Lighting.hlsl`:
- Around line 1086-1114: When EnableComplexMaterial is false the code leaves
envMaskBase at 1.0 which disables ordinary envmask modulation; sample the env
mask unconditionally (e.g. call TexEnvMaskSampler.Sample(SampEnvMaskSampler, uv)
into envMaskSample before or outside the EnableComplexMaterial branch) and set
envMaskBase = envMaskSample.x in the non-complex-material path (while keeping
the existing complexMaterial branch and its logic for envMaskSample and
complexMaterialColor intact) so regular envmask modulation is preserved when
SharedData::extendedMaterialSettings.EnableComplexMaterial is false.
🪄 Autofix (Beta)
❌ Autofix failed (check again to retry)
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
Run ID: 94634b99-93a7-4916-a0ab-55b9160997c5
📒 Files selected for processing (1)
package/Shaders/Lighting.hlsl
…/skyrim-community-shaders into emat-detect-bad-textures
Automated formatting by clang-format, prettier, and other hooks. See https://pre-commit.ci for details.
|
Note Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it. Autofix skipped. No unresolved CodeRabbit review comments with fix instructions found. |
closes community-shaders#1969 (cherry picked from commit 48ba35f)
Detects _m textures which have been saved with multiple channels. Ignores the w channel in detection because sometimes transparency is baked into it.
The math is a bit messy because due to compression the channels are not truly the same.
bugged

fixed

Fixes #1969
Summary by CodeRabbit