PBR With COOK TORRANCE FOR MONOGAME

Hi guys,

just wanna post some progress: Gamma-corrected Shading with CookTorrance BRDF :)

image

I changed the basic specular calculation for my game from the basic Phong to a more realistic implementation of CookTorrance, which is the de facto standard for most engines right now.

Obviously I didn’t reimplement the wheel here, there are so many recources on this stuff on the web that it was really easy to implement.

Some of the stuff which was really useful and easy to understand:

To add to this I thought about some form of environment mapping, but I decided against Cubemaps since just two diffuse lights from top (sky blue) and bottom (desert red) plus the ambient term seemed good enough for some GI approximation.

PBR2

Here is another shot with different roughness and F0 values for the cubes.

The BRDF rendering and the added environment lighting is a little bit more complicated/expensive than the usual Phong shading, but as of now it really is a non-factor, the real blockades lie elsewhere still.

Top is new, bottom picture is the old system.

PBR_perf

Non_PBR_perf

Note that the milliseconds per frame are fluctuating a bit, while Fraps is smoothing its FPS counter so that’s more indicative in that case. Also note that the material parameters are different:

CookTorrance relies on Roughness and general reflectiveness of light (which can have several subparameters) of the surface. The less rough a surface is the more it will have a strong small highlight (think marble floor vs rocky ground). The other parameter indicates how much the surface reflect light at all (think mirror vs cloth).

Phong just uses “Shininess” which can range from 1 to infinite, and the progression in terms of result doesn’t make sense and the output is multiplied with a specularIntensity multiplier. Yeah…

So… it’s not reeeaaally PBR. I get that. Since for that the textures would have to be correct as well. This is not something I will strive for. However, having light behave in a natural fashion with some nice energy conservation is pretty good, too, and closer to physical reality than it was before.

I hope you like it :)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s