Skip to content

refactor(hair): enhance hair specular visual, change default hair settings and feature info#1203

Merged
alandtse merged 8 commits into
community-shaders:devfrom
jiayev:hair_dualspecular
Jun 26, 2025
Merged

refactor(hair): enhance hair specular visual, change default hair settings and feature info#1203
alandtse merged 8 commits into
community-shaders:devfrom
jiayev:hair_dualspecular

Conversation

@jiayev
Copy link
Copy Markdown
Collaborator

@jiayev jiayev commented Jun 25, 2025

Now at default settings hair specular would not look overbright, and won't stray too far from vanilla look.

Summary by CodeRabbit

  • New Features

    • Added a "Transmission" parameter for hair rendering, allowing users to adjust light transmission through hair.
    • Introduced a new slider for "Transmission" in the hair specular settings UI.
  • Improvements

    • Enhanced hair shading with more realistic specular highlights and refined tangent-based light interaction.
    • Increased the maximum value for the "Glossiness" slider for finer control.
    • Updated default settings for glossiness, saturation, and base color for improved visual results.
    • Revised feature summary text for clarity.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 25, 2025

"""

Walkthrough

The changes refactor and extend the hair shading system by integrating a BRDF module, updating the hair specular and diffuse lighting models, and adding a transmission parameter. Default parameter values are adjusted, new functions and struct members are introduced, and the user interface is updated to support the new transmission control.

Changes

File(s) Change Summary
features/Hair Specular/Shaders/Hair/Hair.hlsli Refactored hair shading: integrated BRDF module, revised Scheuermann and Marschner models, added new diffuse and specular calculations, updated function signatures, and cleaned up legacy code.
package/Shaders/Common/SharedData.hlsli Renamed and updated members in HairSpecularSettings struct; replaced pad with Transmission.
src/Features/HairSpecular.cpp Added Transmission to serialization, extended "Glossiness" slider range, and added "Transmission" slider in UI.
src/Features/HairSpecular.h Updated feature summary and highlights, changed default values in Settings, removed pad, added Transmission member.

Sequence Diagram(s)

sequenceDiagram
    participant UI
    participant Settings
    participant Shader
    participant BRDF

    UI->>Settings: User adjusts "Glossiness" or "Transmission"
    Settings->>Shader: Pass updated Settings (including Transmission)
    Shader->>BRDF: Compute specular/diffuse using BRDF functions
    Shader->>Shader: Select Scheuermann or Marschner model
    Shader-->>UI: Render updated hair shading
Loading

Possibly related PRs

Poem

A whisk of light on silky hair,
With BRDF, we shade with flair.
Transmission shines, a slider new,
Glossy locks in every hue.
Marschner or Scheuermann, pick your way—
The rabbit hops, and shaders play!
🐇✨
"""


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 08e9bfa and 55eff45.

⛔ Files ignored due to path filters (1)
  • package/Shaders/Lighting.hlsl is excluded by !**/*.hlsl
📒 Files selected for processing (2)
  • features/Hair Specular/Shaders/Hair/Hair.hlsli (6 hunks)
  • package/Shaders/Common/SharedData.hlsli (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • package/Shaders/Common/SharedData.hlsli
  • features/Hair Specular/Shaders/Hair/Hair.hlsli
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Validate shader compilation (Flatrim, .github/configs/shader-validation.yaml)
  • GitHub Check: Validate shader compilation (VR, .github/configs/shader-validation-vr.yaml)
  • GitHub Check: Build plugin and addons
  • GitHub Check: Feature Version Audit (PR)

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.

@github-actions
Copy link
Copy Markdown

Using provided base ref: f19e63a
Using base ref: f19e63a
Base commit date: 2025-06-25T09:07:06+01:00 (Wednesday, June 25, 2025 09:07 AM)
No actionable suggestions for changed features.

Copy link
Copy Markdown
Contributor

@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: 2

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f19e63a and 3b4c831.

⛔ Files ignored due to path filters (1)
  • package/Shaders/Lighting.hlsl is excluded by !**/*.hlsl
📒 Files selected for processing (4)
  • features/Hair Specular/Shaders/Hair/Hair.hlsli (6 hunks)
  • package/Shaders/Common/SharedData.hlsli (1 hunks)
  • src/Features/HairSpecular.cpp (1 hunks)
  • src/Features/HairSpecular.h (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Validate shader compilation (VR, .github/configs/shader-validation-vr.yaml)
  • GitHub Check: Validate shader compilation (Flatrim, .github/configs/shader-validation.yaml)
  • GitHub Check: Build plugin and addons
🔇 Additional comments (10)
package/Shaders/Common/SharedData.hlsli (1)

162-162: Good use of padding space for the new transmission parameter.

Replacing the padding field with a meaningful Transmission parameter is a clean way to extend functionality without changing the struct size or alignment.

src/Features/HairSpecular.cpp (3)

17-18: LGTM! Serialization correctly updated for the new parameter.

The serialization macro properly includes the new Transmission parameter, maintaining consistency with the struct definition.


23-23: Verify the extended glossiness range is intentional.

The maximum glossiness value has been increased from 100.0f to 256.0f, which is a significant change (2.56x). This aligns with the increased default value in the header file but may affect existing user configurations.

Please confirm this range extension is intentional and that the shader calculations handle values up to 256 correctly without precision issues.


30-30: Transmission slider properly implemented.

The new transmission slider with range [0.0, 1.0] is appropriately added and matches the default value of 0.5f defined in the header.

src/Features/HairSpecular.h (1)

50-50: New transmission parameter properly defined.

The addition of the Transmission parameter with a default value of 0.5f is well-integrated into the settings structure.

features/Hair Specular/Shaders/Hair/Hair.hlsli (5)

38-38: Function signatures properly updated with vertex normal parameter.

The addition of the VN (vertex normal) parameter to the lighting functions enables proper horizon occlusion calculations, improving the physical accuracy of the hair shading.

Also applies to: 181-181


60-60: Correct change from Load to Sample for texture access.

Switching from Load to Sample for the tangent shift texture is the correct approach as it enables texture filtering, providing smoother results for the hair tangent shifts.

Also applies to: 199-199, 226-226, 277-277


48-74: Improved Scheuermann implementation with transmission support.

The refactored Scheuermann lighting model now includes:

  • Proper wrapped diffuse lighting
  • Transmission effects with Fresnel-based scattering
  • Better integration with the BRDF module

The implementation looks mathematically sound and the addition of transmission enhances the realism of hair rendering.


78-80: Fixed Gaussian distribution calculation.

The Hair_g function now correctly uses the two-pi normalization factor Math::TAU instead of the hardcoded value, improving mathematical accuracy.


84-147: Enhanced Marschner model with TRT lobe.

The Marschner implementation has been significantly improved:

  • Added the third specular lobe (TRT) for more accurate hair rendering
  • Corrected mathematical formulations
  • Proper integration with the transmission parameter

These changes bring the implementation closer to the original Marschner paper.

Comment on lines +40 to +50
float HairGlossiness = 80.0f;
float SpecularMult = 1.0f;
float DiffuseMult = 1.0f;
uint EnableTangentShift = true;
float PrimaryTangentShift = 0.5f;
float SecondaryTangentShift = -0.25f;
float HairSaturation = 1.25f;
float HairSaturation = 1.0f;
float SpecularIndirectMult = 1.0f;
float DiffuseIndirectMult = 1.0f;
float BaseColorMult = 1.5f;
float pad;
float BaseColorMult = 1.0f;
float Transmission = 0.5f;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Default value changes may affect existing users.

The following default values have been significantly modified:

  • HairGlossiness: 60.0f → 80.0f (33% increase)
  • HairSaturation: 1.25f → 1.0f (20% decrease)
  • BaseColorMult: 1.5f → 1.0f (33% decrease)

While these changes align with the PR objective of maintaining closer resemblance to vanilla appearance, they constitute breaking changes for existing users who haven't customized these values.

Would you like me to generate a migration note or changelog entry to inform users about these default value changes?

🤖 Prompt for AI Agents
In src/Features/HairSpecular.h around lines 40 to 50, the default values for
HairGlossiness, HairSaturation, and BaseColorMult have been changed
significantly, which may break existing user setups. To fix this, create a
migration note or changelog entry clearly documenting these default value
changes and their impact, so users are informed and can adjust their
configurations accordingly.

#include "Common/Math.hlsli"

#define MARSCHNER false
// #define MARSCHNER
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Default lighting model changed from Marschner to Scheuermann.

By making Marschner opt-in with // #define MARSCHNER, the default hair lighting model has been changed to Scheuermann. This is a significant change that will affect the visual appearance of all hair rendering.

Ensure this change is documented in release notes as it may significantly alter the appearance of hair for existing users.

🤖 Prompt for AI Agents
In features/Hair Specular/Shaders/Hair/Hair.hlsli at line 7, the default hair
lighting model was changed from Marschner to Scheuermann by commenting out the
Marschner define. This change affects hair rendering appearance. Update the
release notes to document this change clearly, explaining that Marschner is now
opt-in and the default is Scheuermann, so users are aware of the visual impact.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 26, 2025

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

Comment thread src/Features/HairSpecular.h
@jiayev jiayev requested a review from alandtse June 26, 2025 06:33
@alandtse
Copy link
Copy Markdown
Collaborator

@coderabbitai please propose an appropriate commit given the changes and the github 50 char limit.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 26, 2025

Tip

For best results, initiate chat on the files or code changes.

@alandtse Based on the changes in this PR, here's an appropriate commit message within the 50 character limit:

refactor(hair): enhance specular with transmission

This commit message (46 characters) captures:

  • Type: refactor - accurately reflects the major shader code restructuring and BRDF integration
  • Scope: hair - clearly identifies the affected system
  • Description: enhance specular with transmission - highlights both the visual improvements and the key new transmission parameter

Alternative options if you prefer different emphasis:

  • refactor(hair): add transmission & improve spec (47 chars)
  • refactor: improve hair specular with transmission (49 chars)

The first option best summarizes the comprehensive changes while staying well under the character limit.

@alandtse alandtse merged commit b60270e into community-shaders:dev Jun 26, 2025
13 checks passed
alandtse pushed a commit to alandtse/open-shaders that referenced this pull request Jul 20, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Aug 6, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Sep 23, 2025
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.

2 participants