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

Reference PBR Implementation is not Physically Based because it loses Energy due to bad Fresnel used on Diffuse #1853

Closed
devshgraphicsprogramming opened this issue Aug 17, 2020 · 6 comments

Comments

@devshgraphicsprogramming
Copy link

devshgraphicsprogramming commented Aug 17, 2020

The section here is not Physically Based
https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#appendix-b-brdf-implementation

That "reference" implementation makes the same errors as learnopengl.com and it results in severe energy loss.

(Disclaimer, its not my project, but of a developer I've helped out)
image
vs.
image

The Diffuse component cannot be weighted by 1 minus the Fresnel given by the angle between the half vector (same as used for the specular), it actually needs two weights of Fresnel transmittance computed with angles between normal and view direction or light direction respectively (its not exact integral, but a very good approximation).

For details c.f. Earl Hammon's GDC presentation on PBR in Titanfall
https://twvideo01.ubm-us.net/o1/vault/gdc2017/Presentations/Hammon_Earl_PBR_Diffuse_Lighting.pdf
or this stackexchange post (less authoritative)
https://computergraphics.stackexchange.com/questions/2285/how-to-properly-combine-the-diffuse-and-specular-terms
or a snapshot of a discussion I've had
https://docs.google.com/document/d/1ZLT1-fIek2JkErN9ZPByeac02nWipMbO89oCW2jxzXo/edit

@snagy @UX3D-nopper @McNopper you've authored this, am I correct?

P.S. Hammon computed his correction factor of 1.05 for multiple internal scatter of diffuse using the Schlick's approximation which only works for materials with IoR 1.33.... ( so you're always stuck with a "glass coating" assumption). We've computed the proper correction factor for a range of IoR in [0.5,2.5] derived from the full Fresnel equations (equally mixed polarization) and fitted a rational polynomial with a few coefficients to it (n is IoR, and n2 is IoR squared)
https://github.com/buildaworldnet/IrrlichtBAW/blob/shader_pipeline/include/irr/builtin/glsl/bxdf/brdf/diffuse/fresnel_correction.glsl
as expected, its valued exactly 1.0 for IoR 1.0 (very important if we do not want a specular coating at all) and around 1.05 for an IoR of 1.33... in line with Hammon's.

@devshgraphicsprogramming
Copy link
Author

@proog128 you might be interested.

@emackey
Copy link
Member

emackey commented Aug 18, 2020

Thanks @devshgraphicsprogramming, have you seen @proog128's #1717? It's a work-in-progress on a revised Appendix B.

@proog128
Copy link
Contributor

@devshgraphicsprogramming Since the recent update, #1717 describes some of the issues regarding physical accuracy of the
reference sample implementation. I think the most problematic issue in the context of physically-based rendering is the fact that the Fresnel-based mix in the sample implementation produces energy (it reflects more energy than is incoming). For now, the model is unchanged, but the flaws are described in the text. If you are interested in a more physically-based diffuse-specular model, you may have a look at "Revisiting Physically Based Shading at Imageworks" from 2017 or at the Enterprise PBR material, esp. Sec. 6.2.1.

@devshgraphicsprogramming
Copy link
Author

devshgraphicsprogramming commented Aug 19, 2020

I think the most problematic issue in the context of physically-based rendering is the fact that the Fresnel-based mix in the sample implementation produces energy (it reflects more energy than is incoming).

Yes sometimes it produces, sometimes it loses energy.

If you are interested in a more physically-based diffuse-specular model, you may have a look at "Revisiting Physically Based Shading at Imageworks" from 2017 or at the Enterprise PBR material, esp. Sec. 6.2.1.

I've already got this covered in my framework (I'll probably upgrade to Enterprise PBR for the multiscatter compensation), I'd like to see glTF address that problem, because the current "PBR" model is really off the mark from ground truth, its not a matter of just simply losing some energy that would be accounted for in multiple scattering, but using the completely wrong fresnel transmission weight with no physical justification for the diffuse surface underneath the specular.

@lexaknyazev
Copy link
Member

@proog128 @emackey
Any actions left here?

@UX3D-nopper
Copy link
Contributor

Think this can be closed, as it has been revisited in PBR next and the latest implementation of the glTF Sample Viewer.

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

No branches or pull requests

5 participants