Skip to content

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

Merged
alandtse merged 1 commit into
devfrom
fix/emat-parallax-shadow-tbn-guard
Jun 3, 2026
Merged

fix(lighting): guard EMAT parallax shadow against undefined TBN#80
alandtse merged 1 commit into
devfrom
fix/emat-parallax-shadow-tbn-guard

Conversation

@alandtse

@alandtse alandtse commented Jun 2, 2026

Copy link
Copy Markdown
Owner

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

The EMAT parallax-shadow block reads tbn via
mul(refractedLightDirection, tbn), but tbn is only defined under
defined(SKINNED) || !defined(MODELSPACENORMALS). For the
MODELSPACENORMALS && !SKINNED permutations the block read an undefined
TBN, producing garbage parallax soft-shadow results. Gate the block on
the same condition that defines tbn, matching the idiom already used
elsewhere in this file.

Ported from ParticleTroned/skyrim-community-shaders.

Co-Authored-By: ParticleTroned <248299730+ParticleTroned@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 2, 2026 06:37
@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@alandtse, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 54 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6c2e6b50-58df-4355-821f-f0e88deb3897

📥 Commits

Reviewing files that changed from the base of the PR and between 629b1d2 and 58b3130.

📒 Files selected for processing (1)
  • package/Shaders/Lighting.hlsl
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/emat-parallax-shadow-tbn-guard

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Tightens the #if defined(EMAT) guard around the parallax-shadow block in Lighting.hlsl so it only compiles when tbn is defined (SKINNED || !MODELSPACENORMALS), fixing an undefined read in the MODELSPACENORMALS && !SKINNED permutation.

Changes:

  • Narrow EMAT parallax-shadow preprocessor guard to match tbn's definition condition.
  • Annotate matching #endif with the guard condition for readability.

@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown

No actionable suggestions for changed features.

@alandtse alandtse merged commit b223b75 into dev Jun 3, 2026
21 checks passed
@alandtse alandtse deleted the fix/emat-parallax-shadow-tbn-guard branch June 3, 2026 06:14
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.

2 participants