Skip to content

fix(lighting): guard EMAT parallax shadow against undefined TBN#2462

Merged
SkrubbySkrubInAShrub merged 1 commit into
community-shaders:devfrom
SkrubbySkrubInAShrub:alandtse-lift-4
Jun 3, 2026
Merged

fix(lighting): guard EMAT parallax shadow against undefined TBN#2462
SkrubbySkrubInAShrub merged 1 commit into
community-shaders:devfrom
SkrubbySkrubInAShrub:alandtse-lift-4

Conversation

@SkrubbySkrubInAShrub

@SkrubbySkrubInAShrub SkrubbySkrubInAShrub commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

The EMAT parallax-shadow block in Lighting.hlsl reads the tangent-space basis tbn via mul(refractedLightDirection, tbn), but tbn is only defined under defined(SKINNED) || !defined(MODELSPACENORMALS). For MODELSPACENORMALS && !SKINNED permutations, the block read an undefined tbn, producing garbage parallax soft-shadow results.

This gates the block on the same condition that defines tbn, matching the idiom already used elsewhere in the file (e.g. the EMAT normal-mapping block and the tbn definition itself).

Change

package/Shaders/Lighting.hlsl — two lines: tighten #if defined(EMAT)#if defined(EMAT) && (defined(SKINNED) || !defined(MODELSPACENORMALS)) around the parallax-shadow block (and annotate the matching #endif).

The guard only removes the block from permutations where tbn was undefined, so it cannot introduce a compile error — only fix the latent undefined read. CI shader validation covers the affected permutations.

Attribution

Ported from ParticleTroned/skyrim-community-shaders (fix(lighting): guard EMAT parallax shadow TBN use).

🤖 Generated with Claude Code

Cherrypicked from open shaders

Summary by CodeRabbit

  • Bug Fixes
    • Adjusted parallax shadow rendering to activate only under specific rendering configurations.

…unity-shaders#80)

Co-authored-by: ParticleTroned <248299730+ParticleTroned@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 3e6a9d82-2e12-49cf-adcf-f17841c8de61

📥 Commits

Reviewing files that changed from the base of the PR and between 8465329 and 86b2ce7.

📒 Files selected for processing (1)
  • package/Shaders/Lighting.hlsl

📝 Walkthrough

Walkthrough

This PR refines shader compilation by narrowing the conditional guard for EMAT parallax shadow logic in Lighting.hlsl. The block now compiles only when EMAT is defined and the shader uses skinning or does not rely on model-space normals.

Changes

EMAT parallax shadow conditional guard

Layer / File(s) Summary
Narrow EMAT parallax shadow guard
package/Shaders/Lighting.hlsl
The preprocessor condition at line 2908 changes from defined(EMAT) to defined(EMAT) && (defined(SKINNED) || !defined(MODELSPACENORMALS)), and the matching #endif at line 2938 is updated to close the narrowed block, preventing EMAT parallax shadow execution in certain shader variant combinations.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

Suggested reviewers

  • davo0411
  • alandtse

Poem

🐰 A guard grows wise, with sharper sight,
Not all EMAT shades shall see the light.
When model-space normals dance alone,
This shadow stays in shadow's zone. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: guarding an EMAT parallax shadow code block against undefined TBN (tangent-space basis), which is the core bug fix in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown

No actionable suggestions for changed features.

@SkrubbySkrubInAShrub SkrubbySkrubInAShrub merged commit 4d66c32 into community-shaders:dev Jun 3, 2026
13 checks passed
@SkrubbySkrubInAShrub SkrubbySkrubInAShrub deleted the alandtse-lift-4 branch June 3, 2026 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants