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

Add iri/sheen/rafraction in glsl version #2518

Merged
merged 4 commits into from
Jan 20, 2025

Conversation

zhuxudong
Copy link
Member

@zhuxudong zhuxudong commented Jan 20, 2025

Summary by CodeRabbit

  • New Features
    • Enhanced shader library with additional GLSL imports for advanced rendering techniques.
  • Improvements
    • Expanded PBR (Physically Based Rendering) module with new shader definitions for more complex light interactions.
  • Refactor
    • Updated naming conventions for material properties in the Thin Film Iridescence shader for consistency.

Copy link

coderabbitai bot commented Jan 20, 2025

Walkthrough

This pull request introduces two new GLSL imports, btdf and refraction, to the PBR (Physically Based Rendering) shader library module. The changes expand the module's shader definitions by adding these imports and updating the export object to include the new entries. The modification ensures that the new shader components are available for use across the application while maintaining the existing shader functionality. Additionally, several material property names in the shader code have been updated for consistency.

Changes

File Change Summary
packages/core/src/shaderlib/pbr/index.ts - Added import for btdf from ./btdf.glsl
- Added import for refraction from ./refraction.glsl
- Updated export object to include btdf and refraction
packages/shader-shaderlab/src/shaders/PBR.gs - Renamed properties: material_Iridescence to iridescence, material_IridescenceIOR to iridescenceIOR, and material_IridescenceRange to iridescenceRange

Possibly related PRs

  • PBR shader support Iridescence #2425: This PR adds support for iridescence in the PBRMaterial class, which is directly related to the new btdf and refraction imports added in the main PR, enhancing the shader's capabilities.
  • shaderlab pbr support refraction #2470: This PR introduces new properties related to transmission in the PBR.gs shader, which aligns with the new refraction functionality added in the main PR.
  • pbr support transmission #2478: This PR enhances the PBRMaterial class with properties for transmission and refraction, which are relevant to the changes made in the main PR regarding the refraction import.

Suggested labels

enhancement, shader, glTF, material

Suggested reviewers

  • GuoLei1990
  • hhhhkrx

Poem

🐰 Shader magic, new and bright,
Imports dancing in the light,
BTDF and refraction join the scene,
PBR's power now more keen!
Rendering dreams, pixel by pixel,
A rabbit's code, simply magical! 🌈


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. (Beta)
  • @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.

@zhuxudong zhuxudong added the Rendering Rendering related functions label Jan 20, 2025
@zhuxudong zhuxudong self-assigned this Jan 20, 2025
@zhuxudong zhuxudong added this to the 1.4 milestone Jan 20, 2025
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

🧹 Nitpick comments (1)
packages/core/src/shaderlib/pbr/index.ts (1)

22-25: Consider grouping related shader components.

The export object could benefit from logical grouping of related shader components. Consider organizing the exports by functionality (e.g., grouping transmission-related components like btdf and refraction together).

 export default {
   pbr_frag_define,
   pbr_helper,
   brdf,
   direct_irradiance_frag_define,
   ibl_frag_define,
   pbr_frag,
-
-  btdf,
-  refraction
+  // Transmission components
+  btdf,
+  refraction
 };
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d3cf162 and de7148f.

⛔ Files ignored due to path filters (11)
  • packages/core/src/shaderlib/common.glsl is excluded by !**/*.glsl
  • packages/core/src/shaderlib/extra/pbr.fs.glsl is excluded by !**/*.glsl
  • packages/core/src/shaderlib/pbr/brdf.glsl is excluded by !**/*.glsl
  • packages/core/src/shaderlib/pbr/btdf.glsl is excluded by !**/*.glsl
  • packages/core/src/shaderlib/pbr/direct_irradiance_frag_define.glsl is excluded by !**/*.glsl
  • packages/core/src/shaderlib/pbr/ibl_frag_define.glsl is excluded by !**/*.glsl
  • packages/core/src/shaderlib/pbr/pbr_frag.glsl is excluded by !**/*.glsl
  • packages/core/src/shaderlib/pbr/pbr_frag_define.glsl is excluded by !**/*.glsl
  • packages/core/src/shaderlib/pbr/pbr_helper.glsl is excluded by !**/*.glsl
  • packages/core/src/shaderlib/pbr/refraction.glsl is excluded by !**/*.glsl
  • packages/shader-shaderlab/src/shaders/shadingPBR/LightIndirectPBR.glsl is excluded by !**/*.glsl
📒 Files selected for processing (1)
  • packages/core/src/shaderlib/pbr/index.ts (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: e2e (22.x)
  • GitHub Check: codecov
🔇 Additional comments (2)
packages/core/src/shaderlib/pbr/index.ts (2)

Line range hint 1-25: Verify IBL BRDF fix implementation.

The PR objectives mention a fix for IBL BRDF in LightIndirectPBR.glsl, but this file isn't included in the changes. Please ensure this fix has been implemented.

Let's verify the IBL BRDF changes:


11-12: Verify missing shader imports for complete feature set.

The PR objectives mention adding iri and sheen features, but these imports are missing. Additionally, clarify if the btdf import is related to the transmission feature mentioned in the objectives.

Let's check for the presence of these shader files:

Copy link

codecov bot commented Jan 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.57%. Comparing base (393f8e3) to head (cd445fb).
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2518      +/-   ##
==========================================
- Coverage   68.58%   68.57%   -0.01%     
==========================================
  Files         957      957              
  Lines      100052   100068      +16     
  Branches     8566     8560       -6     
==========================================
+ Hits        68617    68626       +9     
- Misses      31179    31186       +7     
  Partials      256      256              
Flag Coverage Δ
unittests 68.57% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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: 1

🧹 Nitpick comments (1)
packages/shader-shaderlab/src/shaders/PBR.gs (1)

47-49: Consider standardizing property naming conventions across all material features.

The codebase appears to be transitioning away from the material_ prefix, but this transition is incomplete. Some sections (like Sheen) mix both conventions:

  • sheenColor vs material_SheenRoughness
  • iridescence vs material_IridescenceTexture

Consider creating a tracking issue to standardize the naming convention across all material properties. This would improve code maintainability and reduce confusion. Would you like me to help create this issue?

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between de7148f and cd445fb.

📒 Files selected for processing (1)
  • packages/shader-shaderlab/src/shaders/PBR.gs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: build (22.x, windows-latest)
  • GitHub Check: codecov
  • GitHub Check: e2e (22.x)
🔇 Additional comments (1)
packages/shader-shaderlab/src/shaders/PBR.gs (1)

47-49: Verify the complete iridescence implementation.

The PR objectives mention adding "iri" from engine toolkit PR #310, but these changes only show property renames.

Let's verify the complete implementation:

✅ Verification successful

Implementation verified - iridescence is fully implemented

The changes in PBR.gs are part of a complete iridescence implementation that includes:

  • Full thin-film interference BRDF implementation in shader files
  • Material property system integration
  • GLTF loader support via KHR_materials_iridescence
  • Proper texture handling for both iridescence and thickness maps
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for iridescence-related shader implementations
rg -t glsl "iridescence" --glob '!*.gs'

# Search for any new shader includes that might contain the implementation
ast-grep --pattern 'include "$_"'

Length of output: 104


Script:

#!/bin/bash
# Find all shader-related files
echo "=== Shader Files ==="
fd -e shader -e cginc -e hlsl -e compute

# Search for iridescence in these files
echo -e "\n=== Iridescence Implementation ==="
rg -A 5 "iridescence" --ignore-case

# Look for includes in shader files
echo -e "\n=== Shader Includes ==="
rg "^[[:space:]]*#include" --type-add 'shader:*.{shader,cginc,hlsl,compute}' -t shader

Length of output: 46771

Comment on lines +47 to +49
iridescence("Iridescence", Range(0, 1, 0.01)) = 0;
iridescenceIOR("IOR", Range(1, 5, 0.01)) = 1.3;
iridescenceRange("ThicknessRange", Vector2) = (100, 400);
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Maintain consistent property naming convention within the iridescence group.

While the properties have been renamed to remove the material_ prefix, related texture properties still use the old prefix. This creates an inconsistent naming pattern within the same feature group.

Consider updating the texture properties as well for consistency:

        iridescence("Iridescence", Range(0, 1, 0.01)) = 0;
        iridescenceIOR("IOR", Range(1, 5, 0.01)) = 1.3;
        iridescenceRange("ThicknessRange", Vector2) = (100, 400);
-       material_IridescenceThicknessTexture("ThicknessTexture", Texture2D);
-       material_IridescenceTexture("IridescenceTexture", Texture2D);
+       iridescenceThicknessTexture("ThicknessTexture", Texture2D);
+       iridescenceTexture("IridescenceTexture", Texture2D);

Committable suggestion skipped: line range outside the PR's diff.

@GuoLei1990 GuoLei1990 merged commit b274e2e into galacean:main Jan 20, 2025
9 checks passed
@GuoLei1990 GuoLei1990 added the ignore for release ignore for release label Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ignore for release ignore for release Rendering Rendering related functions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants