Skip to content

fix: terrain variation broken parallax shadows & incorrect mipmapping.#1124

Merged
doodlum merged 1 commit into
community-shaders:devfrom
davo0411:tv-hotfixes
Jun 8, 2025
Merged

fix: terrain variation broken parallax shadows & incorrect mipmapping.#1124
doodlum merged 1 commit into
community-shaders:devfrom
davo0411:tv-hotfixes

Conversation

@davo0411
Copy link
Copy Markdown
Collaborator

@davo0411 davo0411 commented Jun 8, 2025

Hotfix for two issues introduced by original terrain variation merge.

These will carry through to the rewrite, but are important to get in so other dev builds don't have these issues.

No failed shaders, fixed shadow issues in interiors for parallax shadows.

Summary by CodeRabbit

  • Bug Fixes
    • Improved texture sampling for terrain variation when the tiling fix is disabled, resulting in more accurate rendering in certain scenarios.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 8, 2025

Walkthrough

The update alters the fallback texture sampling method in the terrain variation shader. Specifically, it changes the sampling from SampleLevel with a fixed mip level to SampleGrad using explicit gradients when the tiling fix feature is disabled. No other logic or public declarations are modified.

Changes

File(s) Change Summary
features/Terrain Variation/Shaders/TerrainVariation/TerrainVariation.hlsli Changed fallback texture sampling from SampleLevel to SampleGrad with explicit gradients in the StochasticEffect function.

Poem

A hop, a skip, a gradient new,
The shader learns a sampling view.
Where once a level fixed the scene,
Now gradients dance, crisp and clean.
Terrain refreshed beneath the sun—
Another shader tweak is done!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d22a4c4 and 9ebdc18.

⛔ Files ignored due to path filters (1)
  • package/Shaders/Lighting.hlsl is excluded by !**/*.hlsl
📒 Files selected for processing (1)
  • features/Terrain Variation/Shaders/TerrainVariation/TerrainVariation.hlsli (1 hunks)
🔇 Additional comments (2)
features/Terrain Variation/Shaders/TerrainVariation/TerrainVariation.hlsli (2)

69-70: Excellent fix for sampling consistency.

This change correctly aligns the early exit sampling method with the approach used in the main stochastic logic. The switch from SampleLevel to SampleGrad addresses the mipmap issues mentioned in line 86's comment and ensures consistent behavior regardless of whether the tiling fix is enabled or disabled.


85-91: Good context for the fix above.

The comment on line 86 provides valuable context explaining why SampleGrad is preferred over SampleLevel when parallax is disabled. This same rationale applies to the early exit path fix on line 70, creating consistent behavior throughout the function.


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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@alandtse alandtse requested a review from Copilot June 8, 2025 11:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Hotfix for terrain variation parallax shadows and correct texture sampling when the tiling fix is disabled.

  • Re-enables parallax shadow calculations under the EMAT pipeline with the appropriate shadow and parallax flags.
  • Switches to SampleGrad for stochastic terrain variation sampling when tiling fix is turned off.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
package/Shaders/Lighting.hlsl Added an #if defined(EMAT) block to restore parallax shadow calculations for various material modes.
features/Terrain Variation/Shaders/TerrainVariation/TerrainVariation.hlsli Changed fallback sampling from SampleLevel to SampleGrad when tiling fix is disabled.
Comments suppressed due to low confidence (2)

features/Terrain Variation/Shaders/TerrainVariation/TerrainVariation.hlsli:70

  • The variables dx and dy are not declared or passed into StochasticEffect. Add them to the function signature or compute derivatives inside before calling SampleGrad.
return tex.SampleGrad(samp, uv, dx, dy);

package/Shaders/Lighting.hlsl:2541

  • The variable mipLevels is likely incorrect here—other calls use mipLevel (singular). This mismatch can cause unintended behavior or compilation errors.
parallaxShadow = ExtendedMaterials::GetParallaxSoftShadowMultiplierTerrain(input, uv, mipLevels, lightDirectionTS, sh0, parallaxShadowQuality, screenNoise, displacementParams, sharedOffset, dx, dy, viewDistance);

@doodlum doodlum merged commit 324a1fd into community-shaders:dev Jun 8, 2025
6 checks passed
soda3000 pushed a commit to soda3000/skyrim-community-shaders that referenced this pull request Jun 8, 2025
soda3000 added a commit to soda3000/skyrim-community-shaders that referenced this pull request Jun 8, 2025
soda3000 added a commit to soda3000/skyrim-community-shaders that referenced this pull request Jun 9, 2025
soda3000 added a commit to soda3000/skyrim-community-shaders that referenced this pull request Jun 9, 2025
soda3000 added a commit to soda3000/skyrim-community-shaders that referenced this pull request Jun 9, 2025
soda3000 added a commit to soda3000/skyrim-community-shaders that referenced this pull request Jun 10, 2025
@davo0411 davo0411 deleted the tv-hotfixes branch July 1, 2025 08:40
alandtse pushed a commit to alandtse/open-shaders that referenced this pull request Jul 20, 2025
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