writing shader - diffuse and alpha question

   3014   1   1
User Avatar
Member
1 posts
Joined: July 2005
Offline
Hi everyone,

I'm just learning about how to write shaders in VEX. I understand how the final pixel color is determined by the diffuse color, lighting, etc. But what I don't understand is how the shader handles the pixel color when it it is slightly transparent and there are other polygons behind it. If I have a box with transparency, does it execute the code twice and get the final color by getting the color for the front face of the box and adding the color for the back face of the box?

For example: I have a grid with a grey color on it and grey alpha. If I copy this grid a few times so that there are several that I'm looking through in a row, the final color gets brighter than the original grey. This happens with default VEX shaders like VEX Constant. But this seems incorrect. The color shouldn't be any brighter than my original diffuse color. How do I get the final value for Cf so that it doesn't get brighter when layered?

What I'm eventually trying to do is create a cloud using grids (like sprites) with puffy texture maps, all bunched together. Each grid has a greyish puff on it, but when they are bunched together, the cloud gets bright white and loses all its detail. I'm using “VEX decal2” by Side Effects, and figure that I'll have to modify it to get the effect I want.

Thanks!
Christine Smith
User Avatar
Member
4256 posts
Joined: July 2005
Offline
chrsmith2
For example: I have a grid with a grey color on it and grey alpha. If I copy this grid a few times so that there are several that I'm looking through in a row, the final color gets brighter than the original grey. This happens with default VEX shaders like VEX Constant. But this seems incorrect. The color shouldn't be any brighter than my original diffuse color. How do I get the final value for Cf so that it doesn't get brighter when layered?

Well….the bad news is that light is additive. A red light + blue light + green light = a white light.

In the case of the gray/grey/semi-white grids the math goes something like this.
First grid is gray….but lets 50%of the light gets passed through it…..so if you have a 3 girds stacked you get .5 + (.5 *1/2) + (.5*1/2 * 1/2)

Where .5 is the gray color of the grid…and the 1/2 is the amount of light that gets passed through. Only 25% of the third grid's light gets through because it has to pass through 2 grids with 50% opacity.

Ironically its this property that gives clouds their neat fluffy look. (That and self shadowing).

If your clouds are getting washed out and all white try reducing the intensity/opacity of each layer.

Another (and more fun) alternative is to check out i3d. Basically you create 3d texture maps which are used to make clouds.

Check out Techimages' contrail tutorials…they might help.

http://www.techimage.co.uk/products/houdini/houdini_tutorials.html [techimage.co.uk]

grumpy tired jim.
if(coffees<2,round(float),float)
  • Quick Links