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

pbr sheen #312

Merged
merged 41 commits into from
Dec 12, 2024
Merged

pbr sheen #312

merged 41 commits into from
Dec 12, 2024

Conversation

hhhhkrx
Copy link
Contributor

@hhhhkrx hhhhkrx commented Dec 3, 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

  • New Features
    • Introduced a "Sheen" section in the shader editor, allowing for enhanced material properties including sheen effects.
    • Added five new material properties related to sheen, enhancing customization options for users.
  • Bug Fixes
    • Removed outdated LightProbe functionality, replacing it with LightIndirectFunctions for improved shader performance.

Copy link

coderabbitai bot commented Dec 3, 2024

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (3)
  • packages/shaderlab/src/shaders/shadingPBR/BRDF.glsl is excluded by !**/*.glsl
  • packages/shaderlab/src/shaders/shadingPBR/LightIndirectPBR.glsl is excluded by !**/*.glsl
  • packages/shaderlab/src/shaders/shadingPBR/ReflectionLobe.glsl is excluded by !**/*.glsl

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 in this pull request introduce a new "Sheen" section to the EditorProperties block of the PBR.gs shader file. This section adds five new material properties related to sheen, while the EditorMacros block has been completely removed. Additionally, the index.ts file in the shadingPBR directory has been updated to replace the import and export of LightProbe with LightIndirectFunctions, modifying the functionality available in the shader exports.

Changes

File Path Change Summary
packages/shaderlab/src/shaders/PBR.gs - Added ui_SheenIntensity, ui_SheenColor, material_SheenRoughness, material_SheenTexture, and material_SheenRoughnessTexture properties.
- Removed the EditorMacros block.
packages/shaderlab/src/shaders/shadingPBR/index.ts - Removed import of LightProbe and added import of LightIndirectFunctions.
- Updated export entry to replace LightProbe with LightIndirectFunctions.

Possibly related PRs

  • ShaderLab PBR support Iridescence #310: The changes in this PR also modify the PBR.gs shader file by adding new properties within the EditorProperties block, similar to the main PR's addition of properties in the same file.

Suggested reviewers

  • zhuxudong
  • GuoLei1990

🐇 "In the shader's glow, a sheen does appear,
With colors and textures, oh so dear!
Roughness and shine, a dance they perform,
In the world of PBR, a new norm!
Hopping along, we embrace the new light,
With each little change, our shaders take flight!" 🐇


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>, please review it.
    • 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 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 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 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. (Experiment)
  • @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.

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

🧹 Outside diff range and nitpick comments (1)
packages/shaderlab/src/shaders/PBR.gs (1)

50-56: Consider performance implications of sheen calculations

While the implementation is correct, sheen calculations can be computationally expensive, especially when using both color and roughness textures. Consider:

  1. Adding a note in the documentation about performance impact
  2. Implementing shader LOD (Level of Detail) variants for performance-critical scenarios
  3. Providing best practices for texture resolution and format choices

Also applies to: 80-82

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d2e966c and 99a6d8e.

⛔ Files ignored due to path filters (4)
  • packages/shaderlab/src/shaders/shadingPBR/BRDF.glsl is excluded by !**/*.glsl
  • packages/shaderlab/src/shaders/shadingPBR/FragmentPBR.glsl is excluded by !**/*.glsl
  • packages/shaderlab/src/shaders/shadingPBR/LightIndirectPBR.glsl is excluded by !**/*.glsl
  • packages/shaderlab/src/shaders/shadingPBR/ReflectionLobe.glsl is excluded by !**/*.glsl
📒 Files selected for processing (1)
  • packages/shaderlab/src/shaders/PBR.gs (2 hunks)
🔇 Additional comments (2)
packages/shaderlab/src/shaders/PBR.gs (2)

50-56: Well-structured implementation of Sheen properties!

The Sheen properties section follows the established pattern and includes all necessary parameters for a PBR sheen implementation. The property ranges, types, and default values are appropriate and consistent with industry standards.


80-82: Verify macro ordering impact on existing shaders

While the new Sheen macros follow the correct naming convention, they're inserted between feature macros and transparency macros. Please verify that the ordering doesn't affect any existing shader variants or compilation.

packages/shaderlab/src/shaders/PBR.gs Outdated Show resolved Hide resolved
packages/shaderlab/src/shaders/shadingPBR/BRDF.glsl Outdated Show resolved Hide resolved
packages/shaderlab/src/shaders/shadingPBR/FragmentPBR.glsl Outdated Show resolved Hide resolved
packages/shaderlab/src/shaders/shadingPBR/BRDF.glsl Outdated Show resolved Hide resolved
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

🧹 Outside diff range and nitpick comments (1)
packages/shaderlab/src/shaders/PBR.gs (1)

50-56: Add documentation for the Sheen properties

Consider adding comments to describe:

  • The visual effect of sheen on materials
  • Typical use cases (e.g., cloth, fabric materials)
  • How the roughness and color textures affect the final appearance

Example documentation:

       Header("Sheen"){
+        // Sheen creates a soft, fabric-like appearance often used for cloth materials
+        // Intensity: Controls the overall strength of the sheen effect
+        // Color: Tints the sheen reflection, usually kept subtle for realism
+        // Roughness: Affects the spread of the sheen reflection
         UI_SheenIntensity("Intensity", Range(0, 1, 0.01)) = 0;
         UI_SheenColor("Color", Color ) = (0, 0, 0, 0);
         material_SheenRoughness("Roughness", Range(0, 1, 0.01)) = 0;
         material_SheenTexture("ColorTexture", Texture2D);
         material_SheenRoughnessTexture("RoughnessTexture", Texture2D);
       }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 1e76033 and 58131a7.

⛔ Files ignored due to path filters (7)
  • packages/custom-material/src/advanced-shader/thinfilm/IridescenceIndirectLight.glsl is excluded by !**/*.glsl
  • packages/shaderlab/src/shaders/shadingPBR/BRDF.glsl is excluded by !**/*.glsl
  • packages/shaderlab/src/shaders/shadingPBR/FragmentPBR.glsl is excluded by !**/*.glsl
  • packages/shaderlab/src/shaders/shadingPBR/LightDirectPBR.glsl is excluded by !**/*.glsl
  • packages/shaderlab/src/shaders/shadingPBR/LightIndirectFunctions.glsl is excluded by !**/*.glsl
  • packages/shaderlab/src/shaders/shadingPBR/LightIndirectPBR.glsl is excluded by !**/*.glsl
  • packages/shaderlab/src/shaders/shadingPBR/ReflectionLobe.glsl is excluded by !**/*.glsl
📒 Files selected for processing (2)
  • packages/shaderlab/src/shaders/PBR.gs (1 hunks)
  • packages/shaderlab/src/shaders/shadingPBR/index.ts (2 hunks)
🔇 Additional comments (4)
packages/shaderlab/src/shaders/PBR.gs (2)

51-52: 🛠️ Refactor suggestion

Standardize property naming convention

The "UI_" prefix for sheen properties is inconsistent with other sections that use the "material_" prefix. Consider renaming:

  • UI_SheenIntensitymaterial_SheenIntensity
  • UI_SheenColormaterial_SheenColor

This aligns with the existing naming pattern seen in other properties like material_BaseColor, material_Metal, etc.

Note: As mentioned in a previous review, sheenIntensity should map to material_SheenColor.a in UIScript.


50-56: Verify shader implementation for sheen properties

The property declarations look correct, but we should verify their integration with the shader implementation.

✅ Verification successful

Sheen properties are properly implemented in the shader

The shader implementation in FragmentPBR.glsl correctly handles all the declared sheen properties:

  • Proper declaration of sheen color and roughness uniforms
  • Texture sampling for both sheen color and roughness textures
  • Correct gamma correction for sheen color texture
  • Integration with the surface data structure
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for sheen-related implementations in shader files
echo "Searching for sheen property usage in shader code..."
rg -l "material_(Sheen|UI_Sheen)" --glob "*.glsl"

# Check if ForwardPassPBR.glsl includes sheen calculations
echo "Checking ForwardPassPBR.glsl for sheen implementation..."
rg "sheen" "ForwardPassPBR.glsl"

Length of output: 439


Script:

#!/bin/bash
# Let's check the content of FragmentPBR.glsl for sheen implementation
echo "Checking sheen implementation in FragmentPBR.glsl..."
rg -A 10 "material_Sheen|UI_Sheen" "packages/shaderlab/src/shaders/shadingPBR/FragmentPBR.glsl"

# Let's also check for any other sheen-related code
echo "Checking for any other sheen-related implementations..."
rg -i "sheen" "packages/shaderlab/src/shaders/shadingPBR/FragmentPBR.glsl"

Length of output: 2545

packages/shaderlab/src/shaders/shadingPBR/index.ts (2)

3-3: Verify the migration from LightProbe to LightIndirectFunctions

The replacement of LightProbe with LightIndirectFunctions suggests a significant refactoring of the lighting calculation system.

✅ Verification successful

Let me check the actual content of these files to better understand the context of the LightProbe references.


No migration issues found - LightProbe references are function names

The occurrences of "LightProbe" in the codebase are actually function names (getLightProbeIrradiance and getLightProbeRadiance) that are still in use and are now properly defined in the new LightIndirectFunctions.glsl. This is not a breaking change as the functionality is preserved, just reorganized into a more appropriate location.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify complete migration from LightProbe to LightIndirectFunctions

# Check for any remaining references to LightProbe
echo "Checking for remaining LightProbe references:"
rg "LightProbe" -l

# Check for new LightIndirectFunctions usage
echo "Checking LightIndirectFunctions implementation:"
ast-grep --pattern 'import $_ from "./LightIndirectFunctions.glsl"'

Length of output: 683


Script:

#!/bin/bash
# Check content of files with LightProbe references
echo "Content of LightIndirectPBR.glsl:"
cat packages/shaderlab/src/shaders/shadingPBR/LightIndirectPBR.glsl

echo -e "\nContent of LightIndirectFunctions.glsl:"
cat packages/shaderlab/src/shaders/shadingPBR/LightIndirectFunctions.glsl

echo -e "\nContent of IridescenceIndirectLight.glsl:"
cat packages/custom-material/src/advanced-shader/thinfilm/IridescenceIndirectLight.glsl

echo -e "\nRelevant LightProbe references in fragment.ts:"
rg "LightProbe" -C 2 packages/custom-material/src/bake-pbr/fragment.ts

Length of output: 9555


21-21: Breaking Change: LightProbe replacement

The export entry follows the consistent pattern of other shader includes, but removing LightProbe is a breaking change that may affect existing implementations.

@GuoLei1990 GuoLei1990 merged commit 3bfc9c0 into galacean:dev/1.4 Dec 12, 2024
1 check failed
@hhhhkrx hhhhkrx linked an issue Dec 19, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sheen
3 participants