-
-
Notifications
You must be signed in to change notification settings - Fork 27
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
Refraction #316
Refraction #316
Conversation
WalkthroughThis pull request enhances the PBR (Physically Based Rendering) shader by introducing a new "Refraction" section with advanced material properties. The changes include adding several new properties related to light transmission and material thickness, such as attenuation color, transmission, and texture mappings. These additions expand the shader's capabilities to handle more complex light interaction scenarios, specifically improving the rendering of transparent and translucent materials. Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command 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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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 (2)
packages/shaderlab/src/shaders/PBR.gs (2)
57-64
: Standardize property naming convention.The property names use inconsistent naming conventions:
material_attenuationColor
(snake_case)material_Thickness
(mixed case)Consider standardizing all property names to use snake_case for consistency with other sections.
- material_Thickness("Thickness", Float) = 0; - material_TransmissionTexture("TransmissionTexture", Texture2D); - material_ThicknessTexture("ThicknessTexture", Texture2D); + material_thickness("Thickness", Float) = 0; + material_transmission_texture("TransmissionTexture", Texture2D); + material_thickness_texture("ThicknessTexture", Texture2D);
59-59
: Consider extending attenuation distance range.The current range of 0-1 for
material_attenuationDistance
might be too limiting for materials with larger attenuation distances. Consider extending this range based on your use cases.- material_attenuationDistance("AttenuationDistance", Range(0, 1, 0.01)) = 0; + material_attenuationDistance("AttenuationDistance", Range(0, 10, 0.1)) = 0;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (7)
packages/shaderlab/src/shaders/Common.glsl
is excluded by!**/*.glsl
packages/shaderlab/src/shaders/shadingPBR/BRDF.glsl
is excluded by!**/*.glsl
packages/shaderlab/src/shaders/shadingPBR/BTDF.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/LightIndirectPBR.glsl
is excluded by!**/*.glsl
packages/shaderlab/src/shaders/shadingPBR/Refraction.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 (2)
packages/shaderlab/src/shaders/shadingPBR/index.ts (1)
11-12
: LGTM! Verify imported GLSL files exist.
The new imports and exports for refraction-related GLSL files are properly structured and maintain a logical grouping with related components.
Also applies to: 25-26
✅ Verification successful
Both imported GLSL files exist in the correct location
The verification confirms that both Refraction.glsl
and BTDF.glsl
files are present in the expected directory packages/shaderlab/src/shaders/shadingPBR/
, matching the import paths.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Verify the existence of the new GLSL files
fd -e glsl "Refraction.glsl|BTDF.glsl" packages/shaderlab/src/shaders/shadingPBR/
Length of output: 193
packages/shaderlab/src/shaders/PBR.gs (1)
57-64
: Verify integration with existing PBR workflow.
The new refraction properties look well-structured, but we should verify their integration with the existing metallic workflow defined in the shader.
✅ Verification successful
Let me analyze the search results to verify the integration of refraction properties with the metallic workflow.
Based on the comprehensive search results, I can now provide a final response about the integration of refraction properties with the existing metallic workflow:
Refraction properties are properly integrated with the metallic workflow
The codebase shows proper integration through:
- The refraction properties coexist with metallic workflow (
IS_METALLIC_WORKFLOW
) in PBR.gs - Refraction calculations in BTDF.glsl correctly handle the interaction with metallic properties through:
- Proper fresnel calculations considering both metallic and transmission properties
- Integration with the opaque texture sampling for refracted colors
- Transmission calculations that respect the metallic workflow's BRDF
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for metallic workflow integration points
rg -A 5 "IS_METALLIC_WORKFLOW|material_transmission|material_attenuationColor" packages/shaderlab/src/shaders/
Length of output: 4064
Script:
#!/bin/bash
# Let's check for any refraction-specific code paths or computations in the shader files
rg -A 10 "refraction|Refraction|IOR" packages/shaderlab/src/shaders/
Length of output: 27126
material_attenuationColor("AttenuationColor", Color ) = (0, 0, 0, 1); | ||
material_attenuationDistance("AttenuationDistance", Range(0, 1, 0.01)) = 0; | ||
material_transmission("Transmission", Range(0, 1, 0.01)) = 0; | ||
material_Thickness("Thickness", Float) = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add range constraints to material_Thickness.
The material_Thickness
property should have range constraints to prevent invalid values that could affect rendering calculations.
- material_Thickness("Thickness", Float) = 0;
+ material_Thickness("Thickness", Range(0, 100, 0.1)) = 0;
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
material_Thickness("Thickness", Float) = 0; | |
material_Thickness("Thickness", Range(0, 100, 0.1)) = 0; |
Please check if the PR fulfills these requirements
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
These enhancements improve the shader's capabilities for more realistic rendering.