Transmittance

I had a request on writing a tutorial about Alpha maps using shaders, and this tutorial will be written tomorrow. But after yesterdays workshop, I had some thoughts about transparent objects, reflection and refraction.
 
We usually code a transparent object the following way: Set the color of the object to a desired color, and use blending/aplha to make the pixels located behind the object( relative to the camera ) get the color of the blended object + it’s normal pixel color. This works well in many cases, but what if I have a glassball I want to make transparent?
I could just make the whole sphere transparant using blending/alpha, but this would make it look rather flat. We all know that in the real world, all light-rays hitting a transparent object ( say a yellow glass sphere ) will be reflected and refracted. The refracted light will go through the object, and based on how far the light-ray travels before going out of on the opposite side, the more it will get the color of the transparent object its passing, in the case, yellow.
If the light goes trough a really thick part of the sphere, it will get much more affected of its color than a ray that just passes the side of it:
 
In this picture, lightrays outside the sphere is green. Once they are inside, the vector is red, and then green again when going out from the object. The longer the rays are inside( the length of the vector ), the more will the ray get colored by the object it’s transmitting.
 
So, in our shader, we want to modify the color all pixels we see trough our sphere, with the spheres color and thickness. I have a few challenges including how to find out how thick a object is at each given point and how the formula for coloring transmitting rays will work, but got an idea.
 
I will write this shader using DirectX 10, but once I get it working, I’ll write an XNA tutorial about it, so you can implement the same effect in your applications!
 
 
Anyway, this is for tomorrow. This evening went in the air on a NNUG user group about Silverlight and WPF, and some final reading before taking the MCTS Distributed Applications exam tomorrow.
Advertisements
This entry was posted in Graphics. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s