Friday, 18 April 2014

Displacement and adding the pattern





The Displacement is a straightforward equation of noise and RSL transform function which transforms the point P from the coordinate system fromspace to coordinate system tospace.  A variable(in this case HUMP variable ) is created for the FOR loop to work and then at the end feeded into the P variable to calculate the new normal of the geometry. This algorithm is basically just a noise distortion for the surface then the loop derives the amount of distortion and strength of the displace Normals.

 
This is the result adding the pattern from the ST coloration. this was a simple geometric shape. 

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.