Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SSS Shader light leakage #297

Merged
merged 7 commits into from
Jul 24, 2024
Merged

Fix SSS Shader light leakage #297

merged 7 commits into from
Jul 24, 2024

Conversation

hhhhkrx
Copy link
Contributor

@hhhhkrx hhhhkrx commented Jul 24, 2024

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

What is the current behavior? (You can also link to an open issue here)

What is the new behavior (if this is a feature change)?

Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)

Other information:

Summary by CodeRabbit

  • Bug Fixes

    • Improved surface shading by adding a conditional check to prevent light leakage, ensuring more accurate shading calculations.
  • Style

    • Updated function naming conventions for consistency by changing MakeNormalizedSG to makeNormalizedSG.

Copy link

coderabbitai bot commented Jul 24, 2024

Walkthrough

The recent changes enhance code readability and robustness within the shader files. Specifically, naming conventions have been standardized by renaming a function to camelCase, while a conditional check has been added to improve shading calculations by preventing potential artifacts. These modifications ensure that the underlying logic remains intact, focusing on maintaining visual fidelity and code consistency.

Changes

File Path Change Summary
.../advanced-shader/sss/SSSFunction.glsl Renamed MakeNormalizedSG to makeNormalizedSG in sgdiffuseLighting, improving naming consistency.
.../advanced-shader/sss/SSSLightDirect.glsl Added a conditional check in surfaceShadingSSS to prevent light leakage by controlling specularLobe execution.

Poem

🐇 In the shader's dance, we make it bright,
With names that flow, like stars at night.
Conditions check, no leaks to see,
Code shines like gems, as it should be!
Hooray for change, let’s hop and cheer,
For smoother shades that bring us near! ✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @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.

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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e2acac5 and 40f01ad.

Files selected for processing (2)
  • packages/custom-material/src/advanced-shader/sss/SSSFunction.glsl (1 hunks)
  • packages/custom-material/src/advanced-shader/sss/SSSLightDirect.glsl (1 hunks)
Files skipped from review due to trivial changes (1)
  • packages/custom-material/src/advanced-shader/sss/SSSFunction.glsl
Additional comments not posted (1)
packages/custom-material/src/advanced-shader/sss/SSSLightDirect.glsl (1)

30-33: LGTM! But verify the value of EPSILON.

The added conditional check ensures that the specularLobe function is only called when surfaceData.dotNV is greater than EPSILON, which prevents potential light leakage.

However, ensure that the value of EPSILON is appropriately defined to avoid unintended side effects.

Verification successful

LGTM! The value of EPSILON is appropriately defined as 1e-6 in packages/shaderlab/src/shaders/Common.glsl.

The added conditional check ensures that the specularLobe function is only called when surfaceData.dotNV is greater than EPSILON, which prevents potential light leakage. This value is small enough to avoid significant unintended side effects.

  • packages/shaderlab/src/shaders/Common.glsl: #define EPSILON 1e-6
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the value of `EPSILON` in the codebase.

# Test: Search for the definition of `EPSILON`. Expect: The value should be appropriately defined.
rg --type glsl -A 5 $'EPSILON'

Length of output: 58


Script:

#!/bin/bash
# Description: Verify the value of `EPSILON` in the codebase.

# Test: Search for the definition of `EPSILON`. Expect: The value should be appropriately defined.
rg 'EPSILON'

Length of output: 571

@hhhhkrx hhhhkrx changed the title Fix sss Fix sss light leakage Jul 24, 2024
@hhhhkrx hhhhkrx changed the title Fix sss light leakage Fix SSS Shader light leakage Jul 24, 2024
@GuoLei1990 GuoLei1990 merged commit 5e1c58b into galacean:dev/1.3 Jul 24, 2024
1 check failed
@GuoLei1990 GuoLei1990 added the bug Something isn't working label Jul 24, 2024
@coderabbitai coderabbitai bot mentioned this pull request Nov 7, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants