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

Do not load prepass normals for transmissive materials #11140

Merged

Conversation

coreh
Copy link
Contributor

@coreh coreh commented Dec 30, 2023

Turns out whenever a normal prepass was active (which includes whenever you use SSAO) we were attempting to read the normals from the prepass for the specular transmissive material. Since transmissive materials don't participate in the prepass (unlike opaque materials) we were reading the normals from “behind” the mesh, producing really weird visual results.

Objective

Solution

  • We introduce a new READS_VIEW_TRANSMISSION_TEXTURE mesh pipeline key;
  • We set it whenever the material properties has the reads_view_transmission_texture flag set; (i.e. the material is transmissive)
  • If this key is set we prevent the reading of normals from the prepass, by not setting the LOAD_PREPASS_NORMALS shader def.

Changelog

Fixed

  • Specular transmissive materials no longer attempt to erroneously load prepass normals, and now work correctly even with the normal prepass active (e.g. when using SSAO)

@JMS55 JMS55 self-requested a review December 30, 2023 03:15
@JMS55 JMS55 added this to the 0.13 milestone Dec 30, 2023
@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior A-Rendering Drawing game state to the screen labels Dec 30, 2023
@JMS55 JMS55 added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Dec 30, 2023
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jan 1, 2024
Merged via the queue into bevyengine:main with commit c2ab3a0 Jan 1, 2024
22 checks passed
@coreh coreh deleted the transmission-do-not-load-prepass-normal branch January 2, 2024 04:59
@coreh coreh restored the transmission-do-not-load-prepass-normal branch January 14, 2024 17:55
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 S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SSAO Breaks Transmission
4 participants