Skip to content

perf(extended translucency): enable only on alpha blended materials#1249

Merged
alandtse merged 7 commits into
devfrom
extended-translucency-fix
Jul 15, 2025
Merged

perf(extended translucency): enable only on alpha blended materials#1249
alandtse merged 7 commits into
devfrom
extended-translucency-fix

Conversation

@doodlum
Copy link
Copy Markdown
Collaborator

@doodlum doodlum commented Jul 12, 2025

Prevents running useless code when alpha blending is off. Fixes ForceDisabled being the wrong value on the CPU.

@ArcEarth

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 12, 2025

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • package/Shaders/Lighting.hlsl is excluded by !**/*.hlsl

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes update the logic in BSLightingShader_SetupGeometry to require that geometry must have an alpha property with blending enabled before processing anisotropic alpha material extra data. Additionally, the ForceDisabled enum value in MaterialModel is changed from 7 to 4 to align with the disabled state threshold.

Changes

File(s) Change Summary
src/Features/ExtendedTranslucency.cpp Added a check for alpha property with blending before processing anisotropic alpha material extra data in BSLightingShader_SetupGeometry. Logic for feature descriptor assignment updated accordingly.
src/Features/ExtendedTranslucency.h Changed the value of MaterialModel::ForceDisabled from 7 to 4 to match the disabled state threshold.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant Geometry
    participant ExtendedTranslucency

    Caller->>ExtendedTranslucency: BSLightingShader_SetupGeometry(Geometry)
    ExtendedTranslucency->>Geometry: GetRuntimeProperty()
    alt Has alpha property with blending enabled
        ExtendedTranslucency->>Geometry: GetExtraData(AnisotropicAlphaMaterial)
        alt Extra data present
            ExtendedTranslucency->>ExtendedTranslucency: Extract and mask material value
            ExtendedTranslucency->>ExtendedTranslucency: Set feature descriptor accordingly
        else Extra data missing
            ExtendedTranslucency->>ExtendedTranslucency: Set feature descriptor to ForceDisabled
        end
    else No alpha property or blending disabled
        ExtendedTranslucency->>ExtendedTranslucency: Set feature descriptor to ForceDisabled
    end
Loading

Possibly related issues

Poem

In the shader's gentle haze,
Alpha blending now sets the phase.
No more stray materials slip through—
Only with blending may features debut!
Enum values realigned with care,
Rabbits hop in code-aware air.
🐇✨


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.

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.

@doodlum doodlum marked this pull request as draft July 12, 2025 22:26
pre-commit-ci Bot and others added 2 commits July 12, 2025 22:26
@github-actions
Copy link
Copy Markdown

Using provided base ref: 803ba41
Using base ref: 803ba41
Base commit date: 2025-07-12T22:51:17+08:00 (Saturday, July 12, 2025 10:51 PM)
No actionable suggestions for changed features.

@doodlum doodlum marked this pull request as ready for review July 12, 2025 22:41
Automated formatting by clang-format, prettier, and other hooks.
See https://pre-commit.ci for details.
@github-actions
Copy link
Copy Markdown

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

@doodlum doodlum changed the title fix(extended translucency): only enable on alpha blended materials perf(extended translucency): only enable on alpha blended materials Jul 13, 2025
@alandtse
Copy link
Copy Markdown
Collaborator

This looks good to me, but we can give a few days to see if we get a comment from @ArcEarth.

Comment thread src/Features/ExtendedTranslucency.cpp
@ArcEarth
Copy link
Copy Markdown
Contributor

Looks amazing to me, always want to do this from the beginning but don't know how with my bad re ability 🤣
Will give this build a try later and let you know if I notice anything 😀

@alandtse
Copy link
Copy Markdown
Collaborator

I assume this isn't related to the other bug you're chasing right?

@doodlum
Copy link
Copy Markdown
Collaborator Author

doodlum commented Jul 13, 2025

I assume this isn't related to the other bug you're chasing right?

Yes unrelated. It's just something I found whilst looking at the code.

@alandtse alandtse changed the title perf(extended translucency): only enable on alpha blended materials perf(extended translucency): enable only on alpha blended materials Jul 15, 2025
@alandtse alandtse merged commit dceab55 into dev Jul 15, 2025
21 checks passed
@alandtse alandtse deleted the extended-translucency-fix branch July 15, 2025 07:00
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