Skip to content

fix(extended translucency): fix default material model not applied#1305

Merged
doodlum merged 2 commits into
community-shaders:devfrom
ArcEarth:dev
Jul 24, 2025
Merged

fix(extended translucency): fix default material model not applied#1305
doodlum merged 2 commits into
community-shaders:devfrom
ArcEarth:dev

Conversation

@ArcEarth
Copy link
Copy Markdown
Contributor

@ArcEarth ArcEarth commented Jul 24, 2025

This was accidentally broken in #1249
The code's logic is a little convoluted >_<

  1. AlphaMaterialModel = Nif setting or force-disabled for non alpha blending mesh (in extra feature descriptor)
  2. If AlphaMaterialModel == 0, use global default material settings
  3. If AlphaMaterialModel == 1, 2, 3, do the math to change the alpha

Summary by CodeRabbit

  • New Features

    • Added a new setting to control whether the Extended Translucency effect applies only to skinned meshes.
    • Introduced a user interface checkbox with a tooltip for toggling this setting.
  • Settings

    • The new option is now saved to and loaded from the configuration, ensuring user preferences are retained.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 24, 2025

Walkthrough

A new boolean setting, SkinnedOnly, was added to the ExtendedTranslucency feature to control whether the translucency effect applies only to skinned meshes. Associated logic, UI, and settings persistence were updated to support toggling and saving/loading this option.

Changes

File(s) Change Summary
src/Features/ExtendedTranslucency.cpp Added SkinnedOnly logic to effect application, updated UI to include a checkbox, and modified settings load/save to handle the new flag.
src/Features/ExtendedTranslucency.h Added bool SkinnedOnly = true; member variable to the ExtendedTranslucency struct.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI
    participant ExtendedTranslucency
    participant Geometry

    User->>UI: Open settings
    UI->>ExtendedTranslucency: Display SkinnedOnly checkbox
    User->>UI: Toggle SkinnedOnly
    UI->>ExtendedTranslucency: Update SkinnedOnly value

    Geometry->>ExtendedTranslucency: Request translucency effect
    ExtendedTranslucency->>Geometry: Apply effect if (has skin OR SkinnedOnly is false)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Suggested reviewers

  • alandtse
  • doodlum

Poem

A checkbox appears, a flag set anew,
Translucent or not? The mesh must queue.
Skinned or unskinned, the choice is now yours,
With settings that save through JSON's doors.
A hop and a toggle, the rabbit approves—
For code that adapts, and softly improves! 🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 89b32f7 and d96414c.

⛔ Files ignored due to path filters (1)
  • package/Shaders/Lighting.hlsl is excluded by !**/*.hlsl
📒 Files selected for processing (2)
  • src/Features/ExtendedTranslucency.cpp (3 hunks)
  • src/Features/ExtendedTranslucency.h (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: alandtse
PR: doodlum/skyrim-community-shaders#0
File: :0-0
Timestamp: 2025-06-24T07:17:36.604Z
Learning: When reviewing PRs, always clarify the scope if there are multiple related features or dependencies. WeatherPicker was a separate PR that was already merged, while this PR focuses specifically on WetnessEffects climate preset system enhancements.
Learnt from: jiayev
PR: doodlum/skyrim-community-shaders#0
File: :0-0
Timestamp: 2025-07-18T15:21:03.641Z
Learning: In the skyrim-community-shaders rendering pipeline, materials with alpha < 1 or alpha blending enabled are rendered in non-deferred mode rather than deferred mode. This means issues with dynamic cubemaps on transparent materials are actually non-deferred rendering issues.
Learnt from: alandtse
PR: doodlum/skyrim-community-shaders#0
File: :0-0
Timestamp: 2025-07-05T05:20:45.823Z
Learning: In the skyrim-community-shaders repository, file deletion error handling improvements that replace existence checks and try-catch blocks with std::filesystem::remove error-code-based approaches are considered bug fixes rather than refactoring, as they address inadequate error handling and misleading log messages.
src/Features/ExtendedTranslucency.h (2)

Learnt from: alandtse
PR: #577
File: src/Features/WetnessEffects.h:36-36
Timestamp: 2025-06-08T11:25:14.536Z
Learning: In the skyrim-community-shaders project, boolean flags in C++ structs that interface with HLSL shaders use uint type instead of bool for compatibility reasons. This ensures consistent size, alignment, and cross-platform compatibility when passing data to shader constant buffers.

Learnt from: alandtse
PR: #577
File: src/Features/WetnessEffects.h:36-36
Timestamp: 2025-06-08T11:25:14.536Z
Learning: In the skyrim-community-shaders project, boolean flags in C++ structs that interface with HLSL shaders use uint type instead of bool for compatibility reasons. This ensures consistent 4-byte size, proper 16-byte alignment in constant buffers, and cross-platform compatibility when passing data between C++ and HLSL shaders.

src/Features/ExtendedTranslucency.cpp (2)

Learnt from: alandtse
PR: #577
File: src/Features/WetnessEffects.h:36-36
Timestamp: 2025-06-08T11:25:14.536Z
Learning: In the skyrim-community-shaders project, boolean flags in C++ structs that interface with HLSL shaders use uint type instead of bool for compatibility reasons. This ensures consistent size, alignment, and cross-platform compatibility when passing data to shader constant buffers.

Learnt from: jiayev
PR: doodlum/skyrim-community-shaders#0
File: :0-0
Timestamp: 2025-07-18T15:21:03.641Z
Learning: In the skyrim-community-shaders rendering pipeline, materials with alpha < 1 or alpha blending enabled are rendered in non-deferred mode rather than deferred mode. This means issues with dynamic cubemaps on transparent materials are actually non-deferred rendering issues.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Validate shader compilation (Flatrim, .github/configs/shader-validation.yaml)
  • GitHub Check: Validate shader compilation (VR, .github/configs/shader-validation-vr.yaml)
  • GitHub Check: Build plugin and addons
🔇 Additional comments (5)
src/Features/ExtendedTranslucency.h (1)

54-54: No shader usage detected for SkinnedOnly; bool is appropriate

I searched all references to SkinnedOnly and found only C++ usages (control flow in ExtendedTranslucency.cpp, ImGui checkbox, and JSON serialization). There are no HLSL/GLSL occurrences or constant-buffer bindings for this flag, so it isn’t passed to shaders. Keeping it as a bool aligns with project conventions for C++-only flags.

src/Features/ExtendedTranslucency.cpp (4)

28-30: Verify the logic change aligns with PR objectives.

The condition now includes !feature->SkinnedOnly to allow the effect on non-skinned meshes when the flag is disabled. However, the PR objectives mention fixing "default material model not applied" rather than adding a SkinnedOnly feature.

The changes appear to add new functionality rather than fix the described bug. Please verify this is the intended fix:

#!/bin/bash
# Search for previous implementation to understand what was actually broken
git log --oneline -n 10 --grep="default material model\|ExtendedTranslucency" 
# Also search for any references to the original bug from PR #1249
rg -A 5 -B 5 "1249\|default material model" 

Likely an incorrect or invalid review comment.


98-103: Well-implemented UI addition.

The checkbox implementation follows established patterns and includes a helpful tooltip explaining when users should enable this option. The integration with the existing UI structure is clean and consistent.


135-135: Proper settings persistence with backward compatibility.

The LoadSettings implementation correctly handles the new setting with a sensible default value, ensuring backward compatibility with existing configurations.


141-141: Consistent settings persistence.

The SaveSettings implementation properly persists the new SkinnedOnly setting using consistent JSON key naming.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 generate unit tests to generate unit tests for 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.

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.

@github-actions
Copy link
Copy Markdown

Using provided base ref: 89b32f7
Using base ref: 89b32f7
Base commit date: 2025-07-24T11:36:49+01:00 (Thursday, July 24, 2025 11:36 AM)
No actionable suggestions for changed features.

@alandtse
Copy link
Copy Markdown
Collaborator

@doodlum can you check the path features that the rabbit mentions to see if we need to adjust to allow hlsl review? We can turn it off if the hlsl is bad.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jul 24, 2025

✅ A pre-release build is available for this PR:
Download

Adding this as an option, default on.
Works well excluding waters and waves :)
@ArcEarth
Copy link
Copy Markdown
Contributor Author

Yes, the artifacts in water is gone ;)
Skinned Mesh Only OFF
skinned_only_off
Skinned Mesh Only ON (Default)
skinned_only_on

@doodlum doodlum merged commit fe85986 into community-shaders:dev Jul 24, 2025
15 checks passed
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