OK, as you can see this may well not be all that basic, but if you have already used my sky box sample then you have already used an Environment map (as a result of this have found that my sky box shader is still in correct..sorry, fixed in this post though). In this post I hope to show the NVIDIA Glass shader.
The NVIDIA Glass Shader
This shader comes with a nice Fresnel function, now I had never hear of Fresnel (to my shame) until I started to play with shaders, but the Fresnel Term is useful for reflective surfaces as it calculates the ratio between reflected and refracted rays and so the surface becomes more reflective the angle of view changes. I have given 3 examples of the glass shader, the first calculates it's own Fresnel term, the second is passed a texture to emulate the Fresnel term and the last uses no Fresnel term at all.
As you will see the shaders are drawn in the following order from top to bottom, self calculating Fresnel Term, Fresnel texture passed and then no Fresnel used. I have also added a tint parameter so the class can be coloured.
I am not going to give an explanation of the NVIDIA glass shader as I don't feel qualified to having not written it myself, but I will show what we need to pass to the shader to get this effect working.
We need to pass a World, World Inverse Transpose, World View Projection and an Inverse View matrix to the shader like this:
We also need to pass the environment map to the shader to as well as the Fresnel texture to use (if the shader needs it) I have also added a "tint" variable so the glass can be coloured. The environment map is the same one that has been passed to the sky box
My next post will again be on environment maps using a reflection and refraction method.
You can download the solution here.