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

Use “specular occlusion” term to consistently extinguish fresnel on Ambient and Environment Map lights #10182

Merged

Conversation

coreh
Copy link
Contributor

@coreh coreh commented Oct 19, 2023

Objective

Even at reflectance == 0.0, our ambient and environment map light implementations still produce fresnel/specular highlights.

Such a low reflectance value lies outside of the physically possible range and is already used by our directional, point and spot light implementations (via the fresnel() function) to enable artistic control, effectively disabling the fresnel "look" for non-physically realistic materials. Since ambient and environment lights use a different formulation, they were not honoring this same principle.

This PR aims to bring consistency to all light types, offering the same fresnel extinguishing control to ambient and environment lights.

Thanks to @nathanf for pointing out the Filament docs section about this.

Solution

  • We use the same formulation already used by the fresnel() function in bevy_pbr::lighting to modulate the F90, to modulate the specular component of Ambient and Environment Map lights.

Comparison

⚠️ Modified version of the PBR example for demo purposes, that shows reflectance (NOT part of this PR) ⚠️

Also, keep in mind this is a very subtle difference (look for the fresnel highlights on the lower left spheres, you might need to zoom in.

Before

Screenshot 2023-10-18 at 23 02 25

After

Screenshot 2023-10-18 at 23 01 43

Changelog

  • Ambient and Environment Map lights will now honor values of reflectance that are below the physically possible range (⪅ 0.35) by extinguishing their fresnel highlights. (Just like point, directional and spot lights already did.) This allows for more consistent artistic control and for non-physically realistic looks with all light types.

Migration Guide

  • If Fresnel highlights from Ambient and Environment Map lights are no longer visible in your materials, make sure you're using a higher, physically plausible value of reflectance (⪆ 0.35).

@alice-i-cecile alice-i-cecile added C-Docs An addition or correction to our documentation A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior C-Usability A simple quality-of-life change that makes Bevy easier to use and removed C-Docs An addition or correction to our documentation labels Oct 19, 2023
Copy link

@Diddykonga Diddykonga left a comment

Choose a reason for hiding this comment

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

LGTM, although I am no graphics wizard, just that it literally looks good to me.

@JMS55 JMS55 added this to the 0.12 milestone Oct 23, 2023
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Oct 23, 2023
@alice-i-cecile alice-i-cecile 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 Oct 23, 2023
Merged via the queue into bevyengine:main with commit e59085a Oct 23, 2023
27 checks passed
ameknite pushed a commit to ameknite/bevy that referenced this pull request Nov 6, 2023
…mbient and Environment Map lights (bevyengine#10182)

# Objective

Even at `reflectance == 0.0`, our ambient and environment map light
implementations still produce fresnel/specular highlights.

Such a low `reflectance` value lies outside of the physically possible
range and is already used by our directional, point and spot light
implementations (via the `fresnel()` function) to enable artistic
control, effectively disabling the fresnel "look" for non-physically
realistic materials. Since ambient and environment lights use a
different formulation, they were not honoring this same principle.

This PR aims to bring consistency to all light types, offering the same
fresnel extinguishing control to ambient and environment lights.

Thanks to `@nathanf` for [pointing
out](https://discord.com/channels/691052431525675048/743663924229963868/1164083373514440744)
the [Filament docs section about
this](https://google.github.io/filament/Filament.md.html#lighting/occlusion/specularocclusion).

## Solution

- We use [the same
formulation](https://github.com/bevyengine/bevy/blob/ffc572728fb7874996a13c31a82e86ef98515995/crates/bevy_pbr/src/render/pbr_lighting.wgsl#L99)
already used by the `fresnel()` function in `bevy_pbr::lighting` to
modulate the F90, to modulate the specular component of Ambient and
Environment Map lights.

## Comparison

⚠️ **Modified version of the PBR example for demo purposes, that shows
reflectance (_NOT_ part of this PR)** ⚠️

Also, keep in mind this is a very subtle difference (look for the
fresnel highlights on the lower left spheres, you might need to zoom in.

### Before
<img width="1392" alt="Screenshot 2023-10-18 at 23 02 25"
src="https://github.com/bevyengine/bevy/assets/418473/ec0efb58-9a98-4377-87bc-726a1b0a3ff3">

### After
<img width="1392" alt="Screenshot 2023-10-18 at 23 01 43"
src="https://github.com/bevyengine/bevy/assets/418473/a2809325-5728-405e-af02-9b5779767843">

---

## Changelog

- Ambient and Environment Map lights will now honor values of
`reflectance` that are below the physically possible range (⪅ 0.35) by
extinguishing their fresnel highlights. (Just like point, directional
and spot lights already did.) This allows for more consistent artistic
control and for non-physically realistic looks with all light types.

## Migration Guide

- If Fresnel highlights from Ambient and Environment Map lights are no
longer visible in your materials, make sure you're using a higher,
physically plausible value of `reflectance` (⪆ 0.35).
rdrpenguin04 pushed a commit to rdrpenguin04/bevy that referenced this pull request Jan 9, 2024
…mbient and Environment Map lights (bevyengine#10182)

# Objective

Even at `reflectance == 0.0`, our ambient and environment map light
implementations still produce fresnel/specular highlights.

Such a low `reflectance` value lies outside of the physically possible
range and is already used by our directional, point and spot light
implementations (via the `fresnel()` function) to enable artistic
control, effectively disabling the fresnel "look" for non-physically
realistic materials. Since ambient and environment lights use a
different formulation, they were not honoring this same principle.

This PR aims to bring consistency to all light types, offering the same
fresnel extinguishing control to ambient and environment lights.

Thanks to `@nathanf` for [pointing
out](https://discord.com/channels/691052431525675048/743663924229963868/1164083373514440744)
the [Filament docs section about
this](https://google.github.io/filament/Filament.md.html#lighting/occlusion/specularocclusion).

## Solution

- We use [the same
formulation](https://github.com/bevyengine/bevy/blob/ffc572728fb7874996a13c31a82e86ef98515995/crates/bevy_pbr/src/render/pbr_lighting.wgsl#L99)
already used by the `fresnel()` function in `bevy_pbr::lighting` to
modulate the F90, to modulate the specular component of Ambient and
Environment Map lights.

## Comparison

⚠️ **Modified version of the PBR example for demo purposes, that shows
reflectance (_NOT_ part of this PR)** ⚠️

Also, keep in mind this is a very subtle difference (look for the
fresnel highlights on the lower left spheres, you might need to zoom in.

### Before
<img width="1392" alt="Screenshot 2023-10-18 at 23 02 25"
src="https://github.com/bevyengine/bevy/assets/418473/ec0efb58-9a98-4377-87bc-726a1b0a3ff3">

### After
<img width="1392" alt="Screenshot 2023-10-18 at 23 01 43"
src="https://github.com/bevyengine/bevy/assets/418473/a2809325-5728-405e-af02-9b5779767843">

---

## Changelog

- Ambient and Environment Map lights will now honor values of
`reflectance` that are below the physically possible range (⪅ 0.35) by
extinguishing their fresnel highlights. (Just like point, directional
and spot lights already did.) This allows for more consistent artistic
control and for non-physically realistic looks with all light types.

## Migration Guide

- If Fresnel highlights from Ambient and Environment Map lights are no
longer visible in your materials, make sure you're using a higher,
physically plausible value of `reflectance` (⪆ 0.35).
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 C-Usability A simple quality-of-life change that makes Bevy easier to use 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.

None yet

5 participants