   transparent shadows
  Hi all,I am trying to get the semi-transparent shadow working, which is part of the assignment 4 of the MIT graphics course.Quote:Render semi-transparent shadows where the attenuation depends on the distance traveled in the transparent objectFor the following case,   Obj1   Obj2   +---+  +---+Hit --------->    |   |  |   |    -----> Light    Shdow Ray+---+  +---+transparent color:  c1c2travel distance:    d1d2my faulty algorithm calculate the shadow color like this:attenuation = c1 * exp(-d1) * c2 * exp(-d2);color += hit.getMaterial()->Shade(ray, hit, dirToLight, lightColor) * attenuation; and the shadows have colors, but they are darker compared to the correct output.If I calculate attenuation like this:// omitting multiplying transparency colorsattenuation = exp(-d1) * exp(-d2); then I get the similar output except the shadows don't have colors such as purple.I really want my program to output the same picture like the one in the class website and any help or advice will be greatly appreciated.Here is the code:int num_lights = scene->getNumLights();for(int i = 0; i < num_lights; i++) {    Light *light = scene->getLight(i);    Vec3f dirToLight, lightColor;    float distanceToLight;    light->getIllumination(hit.getIntersectionPoint(), dirToLight, lightColor, distanceToLight);    Ray ray2(hit.getIntersectionPoint(), dirToLight);    Hit hit2(distanceToLight, NULL, Vec3f(0,0,0));    Hit hit3(0, NULL, Vec3f(0,0,0));    Vec3f attenuation = Vec3f(1, 1, 1);    while(g->intersect(ray2, hit2, hit3.getT()+EPSILON)) {   Vec3f transparentColor = dynamic_cast<PhongMaterial*>   (hit2.getMaterial())->getTransparentColor();   if(transparentColor.Length() > 0) {  hit3 = Hit(distanceToLight, NULL, Vec3f(0,0,0));  if(g->intersect(ray2, hit3, hit2.getT()+EPSILON)) { attenuation *= transparentColor * exp(hit2.getT() - hit3.getT());  } else { attenuation *= transparentColor; break;  }   } else { // opaque object in the way attenuation = Vec3f(0, 0, 0); break;   }   hit2 = Hit(distanceToLight, NULL, Vec3f(0,0,0));    }    color += hit.getMaterial()->Shade(ray, hit, dirToLight, lightColor) * attenuation;}[Edited by - jamielie on September 29, 2008 8:15:59 AM]
  Stupid question: how do your lights falloff with distance? linear or exponential? Because if you don't use exponential falloff then you have the lights decrease too much faster while traversing the object than while traversing the space...   ;  I used the exponential function.I read this hint in the assignment Quote:Render semi-transparent shadows where the attenuation depends on the distance traveled in the transparent object and thought using "e^(-distance traveled inside the transparent object) * transparency_color" would work [depressed]In my implementation, the light attenuates only when it travels inside the transparent object.[Edited by - jamielie on September 30, 2008 7:54:57 AM]