Raytracing Transparancy
I''m trying to write a ray-tracer in C++. I''ve been stuck on setting the direction of refracted rays for days, I''m wondering if anyone has any ideas on why the following does not work.
...
Ray refractedRay;
Point3 adjustedStart(-e * normal.x + hitPoint.x, -e * normal.y + hitPoint.y, -e * normal.z + hitPoint.z); // Point3 holds xyz coordinates. I assume the hit point is correct, as reflection and shading work correctly
ray.dir.normalize();
Vector direction;
GLfloat ni = normal.dot(v); // v is the direction to the camera eye
GLfloat eta = obj->mtrl.transparency; // transparency varies between 0 and 1
dir = normal * (eta * ni - sqrt(1.0 - eta * eta * (1 - ni * ni))) + ray.dir * eta;
dir.normalize();
refractedRay.start = adjustedStart;
refractedRay.dir = dir;
refractedRay.recurseLevel = ray.recurseLevel + 1;
// recursive call to this shading method follows
...
Hope this is the right forum for this question. Thanks in advance.
I think you will find that this is in fact impossible!!
[edited by - jmaceee on March 5, 2003 8:19:48 PM]
[edited by - jmaceee on March 5, 2003 8:19:48 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement