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

Treat specular less than 0.02 as occlusion #63587

Merged
merged 1 commit into from
Aug 1, 2022

Conversation

clayjohn
Copy link
Member

@clayjohn clayjohn commented Jul 28, 2022

Closes: godotengine/godot-proposals#4818

This is a very common hack used in almost all PBR renderers to allow removing specular contribution in dielectric materials.

Filament calls it "Pre-baked Specular Occlusion". Essentially, a specular value of less than 0.02 is outside the realm of physical quantities, so that range is reused to signify occlusion. In effect, this makes the specular fade out when very low values are used and it does nothing when normal range values are used.

Importantly, this PR matches the behaviour with Blender, Unreal, and Unity.

Specular = 1.0

Before

Screenshot from 2022-07-28 11-23-59

After

Screenshot from 2022-07-28 11-26-32

Specular = 0.5

Before

Screenshot from 2022-07-28 11-23-56

After

Screenshot from 2022-07-28 11-26-35

Specular = 0.0

Before

Screenshot from 2022-07-28 11-23-54

After

Screenshot from 2022-07-28 11-26-39

@mindinsomnia
Copy link

You have my eternal gratitude!

@Calinou
Copy link
Member

Calinou commented Jul 28, 2022

Nice work 🙂

The class reference should be updated to mention two things:

  • metallic_specular's behavior when its value is lower than 0.02, disabling both specular lobes and IBL. The documentation should also mention that for most realistic use cases, you don't need to change metallic_specular.
  • How the Disabled specular mode differs from setting metallic_specular below 0.02. IIRC, the Disabled specular mode will only disable the specular lobes, not IBL.

Also, it might be worth discussing for a future PR whether we should add a specular map property to BaseMaterial3D.

@BraqueDown
Copy link

The image for Specular = 0.0 Before is wrong. It's set to 1.0 instead.

This is a very common hack used in almost all PBR renderers to allow removing specular contribution in dielectric materials
@clayjohn clayjohn force-pushed the specular-occlusion branch from c7cae19 to 0c65ed3 Compare July 31, 2022 22:45
@clayjohn clayjohn requested a review from a team as a code owner July 31, 2022 22:45
@clayjohn
Copy link
Member Author

The class reference should be updated to mention two things:

  • metallic_specular's behavior when its value is lower than 0.02, disabling both specular lobes and IBL. The documentation should also mention that for most realistic use cases, you don't need to change metallic_specular.
  • How the Disabled specular mode differs from setting metallic_specular below 0.02. IIRC, the Disabled specular mode will only disable the specular lobes, not IBL.

Done!

The image for Specular = 0.0 Before is wrong. It's set to 1.0 instead.

Fixed :) thanks for letting me know

@akien-mga akien-mga merged commit 677f565 into godotengine:master Aug 1, 2022
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants