Friday 11 April 2014

Cook Torrance




The implementation process for the Cook Torrance was very straight forward. The reason for this is because Cook Torrance is very popular even Pixar has a dedicated web page concerning how to create a Cook Torrance shader. All the common shader attributes are set in place the same as the old way of creating a RSL shader.
surface CookTorrance(
float Ka = 1; /* Ambient
float Ks = .8; /* Specular
float Kd = .2; /* Diffuse
float IOR = 1.3;
float roughness = .2;
color opacity = 1;
color specularColor = 1;
color diffuseColor = (.6, .6, .6);
float gaussConstant  = 100;

){
       
        //illuminance( P, Nn, PI/2 ){
        //      In this section the cook torrance brdf model is implemented
        //}
        Oi = opacity; Opacity for the shader
        Ci = diffuseColor * Oi; The overall sum of the shader colour.
}
First all the variables are declared for the Fresnel algorithm and the illuminance model. All the algorithm such as the Microfacet 
distribution and he geometric attenuation are created the same as their formula. 

16316_5950gif
http://ruh.li/images/CookTorranceGeometricAttenuation.png 
All of the contributions are then added together to be multiplied into surface colour, diffuse and the specular colour. The reflection model is a statement  that calculates the reflection colour for the shader and also gets the reflection direction to present it accurately.  

No comments:

Post a Comment