mercoledì 8 febbraio 2012

Physically based rendering in “Anna”

While analyzing the rendering needs for “Anna”, I was trying to find a good solution to provide the required amount of realism and a simple tuning.

As we know, there are many approximations to light behavior: we have the Lambert model, the Phong model, the Blinn-Phong model and so on.

All these models are fine, but I needed something better to provide a distinctive look to “Anna”.

So I chose a set of physically based models. I chose the “Oren-Nayar” reflectance model for the diffuse light and the Phong model, with a Fresnel approximation made by Schlick.

Oren-Nayar reflectance model

Oren-Nayar model tries to approximate the diffuse light behavior with rough surfaces, as the Lambert model (the most used model for diffuse light) will not provide a good enough approximation. An example of rough surfaces are concrete, stone, wood and fabric.

A good example of a rough surface is the moon:

It's possible to notice that the amount of scattered light does not really decrease much from the various points on the surface, even at the border. In technical terms, there's almost no “limb darkening”.

As opposite example, limb darkening is well visible on a bowling ball:

It's clearly possible to see limb darkening on the Sun (and other stars), but that's for a completely different reason.

Most of the objects in “Anna” are made of rough stone and wood, so Oren Nayar seems to fit exactly our needs.

This model works to provide this kind of curve (Wikipedia):

It's possible to notice how Oren-Nayar model gets a lot closer to measurements (which is real life) than regular Lambert model.

It's important to say that with no roughness, Lambert model and Oren-Nayar model behaves in the same way, as smooth objects have a behavior similar to the Lambert model.

Phong model with Schlick Fresnel

Phong model is widely used. The alternative is the Blinn-Phong model, which uses a half-vector and is less expensive. For “Anna” I decided to use the Phong model, as I think it provides a nice specular.

Schlick Fresnel is an approximation of the full Fresnel calculation: it's less expensive than the full calculation, but still provides a great looking Fresnel, which is physically accurate, as it will conserve the energy.

Here's a couple example:

This image is with Oren-Nayar and Phong with Fresnel approximation: you can notice the small specular hilight (I selected a Fresnel behavior which is fine for dielectric materials) and little limb darkening. This is how that material would behave in real life.

This is with regular Lambert calculation and no Fresnel approximation:

You can see how it gets unnaturally lit.

To better understand the Fresnel approximation and the energy conservation, let's have a look from behind:

Notice how the specular hilight becomes strong: this is what would happen in real life looking an object from that angle.

Without using the fresnel approximation, the light does not behave in a Physically correct way, as a lot of energy gets lost.

This is it for this week: next week we'll provide more screenshots and some new informations about the game!
Release Date

Anna” has now a release date! Well, almost, but we're almost there: it will be released during April 2012! Get ready, then, for some psychological horror!

Dreampainters team

1 commento:

  1. Interesting post. I hope there will be more and more post about rendering techniques adopted in Anna.