Skip to content

Fix anisotropy not working when material is lit by environment map light #20077

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

Merged
merged 1 commit into from
Jul 14, 2025

Conversation

marlyx
Copy link
Contributor

@marlyx marlyx commented Jul 10, 2025

Fixes objects being lit by environment map light not having the anisotropy effect applied correctly. The contribution of light from the environment map with anisotropy is calculated but immediately discarded. Instead what is applied is the regular environment map contribution (calculated without anisotropy) that happen right after.

This patch fixes the logic here to what I think is the intended one. Only calculate contribution once, with or without anisotropy depending on shader specialization.

Solution

  • Properly apply normal modification if anisotropy is enabled.
  • Remove duplicate environment map light calculation

Testing

Tested this by running the anisotropy example and comparing main vs PR results. See images below.


Showcase

Main:
Main-AnisoEnabled

PR:
WithFix-AnisoEnabled

* Remove duplicate env map light calculation
@marlyx
Copy link
Contributor Author

marlyx commented Jul 10, 2025

Since this patch is basically based on what I think is the intended behavior I would love some feedback from someone with more knowledge about these things

@hukasu hukasu added A-Rendering Drawing game state to the screen S-Needs-Review Needs reviewer attention (from anyone!) to move forward M-Deliberate-Rendering-Change An intentional change to how tests and examples are rendered labels Jul 10, 2025
@alice-i-cecile alice-i-cecile added this to the 0.17 milestone Jul 10, 2025
@alice-i-cecile alice-i-cecile added X-Uncontroversial This work is generally agreed upon D-Straightforward Simple bug fixes and API improvements, docs, test and examples labels Jul 11, 2025
Copy link
Contributor

@atlv24 atlv24 left a comment

Choose a reason for hiding this comment

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

good find, thanks. i believe this is correct

@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it C-Bug An unexpected or incorrect behavior and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jul 14, 2025
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jul 14, 2025
Merged via the queue into bevyengine:main with commit 7db64a7 Jul 14, 2025
47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior D-Straightforward Simple bug fixes and API improvements, docs, test and examples M-Deliberate-Rendering-Change An intentional change to how tests and examples are rendered S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it X-Uncontroversial This work is generally agreed upon
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants