Archived

This topic is now archived and is closed to further replies.

g___a___r___y

Raytracing Transparancy

Recommended Posts

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.

Share this post


Link to post
Share on other sites