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

[PBR extension] Specify formula to calculate BRDF inputs from material properties #810

Closed
bghgary opened this issue Jan 4, 2017 · 7 comments
Labels
2.0 extension PBR Physically Based Rendering resolved

Comments

@bghgary
Copy link
Contributor

bghgary commented Jan 4, 2017

The PBR spec does a good job of describing the two material models and their properties, but there is currently no information about how to calculate the BRDF inputs from the material properties, not even in the appendix. There is also little information about this on the web. I realize this math can be inferred from the example shaders, but I propose that we add this information explicitly since all implementations should be doing the same thing. The approximations for the BRDF can differ between implementations. Thoughts?

This is my understanding of the math. All values are in linear space.

BRDF Inputs

BRDF diffuse (RGBA)
BRDF specular (RGB)
BRDF roughness (float)

Specular-Glossiness

diffuse (RGBA)
specular (RGB)
glossiness (float)

where

BRDF diffuse = diffuse.rgb * (1 - max(specular.r, specular.g, specular.b))
BRDF specular = specular
BRDF roughness = max((1 - glossiness) ^ 2, epsilon)

Metallic-Roughness

baseColor (RGBA)
metallic (float)
roughness (float)

where

const dielectricSpecular = rgb(0.04, 0.04, 0.04)
const black = rgb(0, 0, 0)

BRDF diffuse = lerp(baseColor.rgb * (1 - dielectricSpecular.r), black, metallic)
BRDF specular = lerp(dieletricSpecular, baseColor.rgb, metallic)
BRDF roughness = max(roughness ^ 2, epsilon)

Is this information accurate?

(Updated: Removed A from specular in specular-glossiness and added .rgb to diffuse and baseColor)

@pjcozzi pjcozzi added extension PBR Physically Based Rendering labels Jan 4, 2017
@pjcozzi
Copy link
Member

pjcozzi commented Jan 4, 2017

@mlimper?

+1 from me for including this.

@javagl
Copy link
Contributor

javagl commented Jan 4, 2017

I already pinged @mlimper and @tsturm vial mail. In fact, this issue might be nearly a duplicate of #697 , which was also about an example implementation (but much more - admittedly, I didn't read it entirely...). In the end, some implementation of the shaders has to exist somewhere - the question might be whether the core (shader) code can be published as a reference implementation.

@mlimper
Copy link
Contributor

mlimper commented Jan 4, 2017

Thanks, this looks very very useful!

We'll put the shader code for a minimalistic example into the appendix as soon as the example implementation is ready - @moneimne is currently working on one.

The original idea for the way the spec works comes from @tsturm, he might be able to judge best if your proposal is accurate. Otherwise, I'd check this as soon as the example implementation is ready, to make sure everything is coherent and then let it check by other contributors that worked on actual implementations.

@bghgary
Copy link
Contributor Author

bghgary commented Jan 4, 2017

@mlimper Sounds good. Hoping someone can verify the math.

@javagl I think this should be separated out from #697 because the math above should be identical in all implementations. It's different than the BRDF equations because not all implementations will use the same approximations (due to complexity/performance of the equations). Or are we saying we want all implementations to use the same BRDF equations? I'm not sure that's realistic.

@pjcozzi
Copy link
Member

pjcozzi commented Jan 5, 2017

@bghgary set roughness to zero / glossiness to one, is it expected that the curves at the top of the spheres go in the opposite direction like they are mirrored? Makes it harder to compare.

image

@bghgary
Copy link
Contributor Author

bghgary commented Jan 5, 2017

Yes. The environment map depends on the position of the object. There should be a way to tweak the shaders so that they match.

@pjcozzi pjcozzi added the 2.0 label Jan 13, 2017
@sbtron
Copy link
Contributor

sbtron commented Feb 14, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.0 extension PBR Physically Based Rendering resolved
Projects
None yet
Development

No branches or pull requests

5 participants