Sign in to follow this  
Kaiyum

Theory of PBR lighting model[and maths too]

Recommended Posts

Hi,

I have been doing self study on many lighting models. I have been through a really tough time understanding PBR shaders. It looks like that I need some theory along with some maths. Consider my graduations out of anything near CS/CSE. I have got the book stated here.

 

But I am having tough time swallowing that book. I know some c++, and prominently I write on java/c#. But a language agnostic resource is a good candidate for me. I just want to know this "PBR thing", in detail enough to implement it, on my own environment.

 

Any light of respective theory and math, to understand the in-out of PBR would highly help me, anyone? :)

Share this post


Link to post
Share on other sites

The math in that book is physically based, which means some prior background in physics would be good. More specifically Rays and Optics. There's a few very specific take aways that you would need to understand this.

A. Light bounces are always equal to the incident angle of the normal.

C. Every surface is usually born of microfaucets, which are tiny mirrors.
B. Diffuse reflection is when a surface is so rough that light is often scattered about.

D. Specular reflection is normally what causes mirrors. That is to say that you can think of every object as a mirror, and that most objects in life are just really shitty mirrors. And objects with really good speculars are just smoother than the normal diffuse object.

Then for math background.

It's a mix of calculus and linear algebra that supplements most of the logic. And then in a few key areas it's a mixture of statistics, and probability.

Edited by Tangletail

Share this post


Link to post
Share on other sites

I am familiar with these ideas, though they are high school physics topics, lets test my nostalgia  :)

 

A. Applicable only for mirror like surface. For rough surface, the angle of incident and the angle of reflection will not be same, is it?

C. True that

B. True that

D. True that too! 

 

For calculus I know how to differentiate and integrate. Differentiation is like trying to obtain a change of certain property with respect to another property. Differentiation of velocity with respect to time is called force(actually force * constant, F = ma). Integration is one kind of addition over certain property. Addition of bread slices over its length is the whole yammy bread cake.  :D

 

The partial differential comes into the scene when a property changes depending upon many properties simultaneously. For example, a game's success depends upon art, gameplay programming, graphics programming, marketing, engine programming etc. X is dependent of Y and Z and T. Though I forgot how to obtain differentials, in this case. taking Y and Z constant and make T variable + taking Y and T constant and make Z variable......something like that.

 

I had a rough journey over probability too, the bayes theorem, combination and permutations, nPr, nCr.......

 

I sense the whole book is about generating rays at the camera, and shooting them towards the scene and letting them to propagate. And calculate the final pixel value when it hits back the camera. The idea is, we see things only when the light comes into our eyes? So the ray must come into our camera, camera is our eyes. Is this the scheme of the whole book?

 

Then I must say, it has near zero practical value to my field as I will have to implement it on GPU. I know how fragment-vertex shader works roughly. I also know how we can GPGPU things via direct compute. But to implement a lighting model I have to understand the model. Lambartian lighting model is easy, but this PBR is making my life hell  :mellow:

 

The book describe the whole system in its weird language, not event c++, --- ramsey(can't remember the name). I do not want the codes. I just want the theory to be explained in a nice manner so that I can implement this on the engine of my choice, platform of my choice, graphics library of my choice. 

Share this post


Link to post
Share on other sites

A. Applicable only for mirror like surface. For rough surface, the angle of incident and the angle of reflection will not be same, is it?


Right. In traditional microfacet theory, a "rough" surface is assumed to be made up of microscopic mirrors that point in different directions. The rougher the surface, the more likely that a given microfacet will not point in the same direction as the surface normal, which means that the reflections become "blurrier" since light does not reflect uniformly off the surface. 
 

I sense the whole book is about generating rays at the camera, and shooting them towards the scene and letting them to propagate. And calculate the final pixel value when it hits back the camera. The idea is, we see things only when the light comes into our eyes? So the ray must come into our camera, camera is our eyes. Is this the scheme of the whole book?
 
Then I must say, it has near zero practical value to my field as I will have to implement it on GPU. I know how fragment-vertex shader works roughly. I also know how we can GPGPU things via direct compute. But to implement a lighting model I have to understand the model. Lambartian lighting model is easy, but this PBR is making my life hell  :mellow:


Yes, that particular book is aimed at offline rendering and always uses ray-tracing techniques, primarily path tracing. In that regard it's probably not the best resource for someone looking to learn real-time rendering, although a lot of the concepts are still applicable (or might be in the future). If you're looking to get started right away with real-time techniques then Real-Time Rendering 3rd edition is probably a better choice, although it's a bit out of date at this point. It covers some of the same ground as the PBR book, but always does it from the perspective of rasterization and real-time performance constraints. If you do decide to switch books I would recommend coming back to the PBR book at some point once you have a better grasp of the basics: I think you'll find that learning the offline techniques can give you a more holistic understanding of the general problesm being solved, and can open your horizons a bit. Plus I think it's fun to do a bit of offline work every once in a while, where you don't have to worry about cramming all of your lighting into a few milliseconds. :)
 

The book describe the whole system in its weird language, not event c++, --- ramsey(can't remember the name). I do not want the codes. I just want the theory to be explained in a nice manner so that I can implement this on the engine of my choice, platform of my choice, graphics library of my choice.


It uses what's called "literate programming". The code is all C++, and the whole working project is all posted on GitHub. The literate programming language just lets them interleave the code with their text, and put little markers into the code that tell you how the code combines into a full program.

Share this post


Link to post
Share on other sites

I am familiar with these ideas, though they are high school physics topics, lets test my nostalgia  :)

 

A. Applicable only for mirror like surface. For rough surface, the angle of incident and the angle of reflection will not be same, is it?

 

It is actually, part of the laws of reflection :P. But due to visual reasons, we approximate micro-faucets. Which is why a probability distribution function is introduced. It represents the probability of running into a microfaucet along a given surface. So physically, the angle of reflection is always equal to the angle of incident across the representative normal. But we bend this rule to get a result that's more to life with limited data.

 

But yeah, that book is aligned for giving you concepts of physically based rendering for things like pixar's renderman. It won't help you to implement anything to the GPU.

To do that, you'd want to take a preexisting BRDF. I'm trying to use Pixar's BRDF, however I haven't optimized it well enough (not at all), so my frames are shit.

Edited by Tangletail

Share this post


Link to post
Share on other sites

 

I am familiar with these ideas, though they are high school physics topics, lets test my nostalgia  :)

 

A. Applicable only for mirror like surface. For rough surface, the angle of incident and the angle of reflection will not be same, is it?

 

It is actually, part of the laws of reflection :P. But due to visual reasons, we approximate micro-faucets. Which is why a probability distribution function is introduced. It represents the probability of running into a microfaucet along a given surface. So physically, the angle of reflection is always equal to the angle of incident across the representative normal. But we bend this rule to get a result that's more to life with limited data.

 

But yeah, that book is aligned for giving you concepts of physically based rendering for things like pixar's renderman. It won't help you to implement anything to the GPU.

To do that, you'd want to take a preexisting BRDF. I'm trying to use Pixar's BRDF, however I haven't optimized it well enough (not at all), so my frames are shit.

 

 

Well what both you an OP are probably looking for, at least for GPU stuff, is the Disney BRDF: https://disney-animation.s3.amazonaws.com/library/s2012_pbs_disney_brdf_notes_v2.pdf

 

Which most everyone seems to use a variation of now, plugin things like GGX/smith geometry term, other optimizations. In fact the above offers a lot of things most don't use, usually concentrating on the metalness/roughness. I've not seen a lot of the sheen/etc. stuff done. Besides you'd want to optimize that out to save registers/G-buffer space/etc. anyway.

 

This, specifically the UE4/Black Ops 2 stuff, offers a more GPU centric view of PBR: http://blog.selfshadow.com/publications/s2013-shading-course/

Edited by Frenetic Pony

Share this post


Link to post
Share on other sites

Thanks guys :) I have got the RTR book, I am so in love with it! :rolleyes: Onto the forth chapter, the book is so nice explaining the things in a nice manner! So far, its a good read. I will come back after I finish it shortly :P. 

Share this post


Link to post
Share on other sites

 

 

I am familiar with these ideas, though they are high school physics topics, lets test my nostalgia  :)

 

A. Applicable only for mirror like surface. For rough surface, the angle of incident and the angle of reflection will not be same, is it?

 

It is actually, part of the laws of reflection :P. But due to visual reasons, we approximate micro-faucets. Which is why a probability distribution function is introduced. It represents the probability of running into a microfaucet along a given surface. So physically, the angle of reflection is always equal to the angle of incident across the representative normal. But we bend this rule to get a result that's more to life with limited data.

 

But yeah, that book is aligned for giving you concepts of physically based rendering for things like pixar's renderman. It won't help you to implement anything to the GPU.

To do that, you'd want to take a preexisting BRDF. I'm trying to use Pixar's BRDF, however I haven't optimized it well enough (not at all), so my frames are shit.

 

 

Well what both you an OP are probably looking for, at least for GPU stuff, is the Disney BRDF: https://disney-animation.s3.amazonaws.com/library/s2012_pbs

 

_disney_brdf_notes_v2.pdf

 

Which most everyone seems to use a variation of now, plugin things like GGX/smith geometry term, other optimizations. In fact the above offers a lot of things most don't use, usually concentrating on the metalness/roughness. I've not seen a lot of the sheen/etc. stuff done. Besides you'd want to optimize that out to save registers/G-buffer space/etc. anyway.

 

This, specifically the UE4/Black Ops 2 stuff, offers a more GPU centric view of PBR: http://blog.selfshadow.com/publications/s2013-shading-course/

 

 

 

I am using disney's BRDF XD. I keep mistaking that Pixar isn't Disney anymore.

 

But I just never bothered to optimize the math for it, so it runs like a fat man in the olympics.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this