Tuesday, September 25, 2007

Week 3 - oily shaders


We started looking at the oily shader, which we was to implement. The rough model without the shader, can be seen to the right.
It took some time to figure out, just how to do it, but eventually the implementation worked. The main idea behind it was, declare the colorRamp.tga as a texture in the glsl-file. From that on, it was possible to access it via a sampler2D in the frag-file. We first tried to use just a sampler1D, but for some reason it didn't work. Even though the f ile should just be a 1D picture(?). To get the right range of color we had a lookup variable, which was a vec2. It's y coordinate was set to 0.0 (again, doesn't this imply 1D?), and the x coordinate var derived from a constant, divided by the variable NdotL, which is the dot product between the normal and the normalized light direction.
The lookup was used in a texture2D, which was multiplied with the shininess of the material and the NdotHV raised to a power of 2.

This gave us this result:














There is a clear difference between the two, and there is no doubt, which one looks the best.

No comments: