• Advertisement

Archived

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

Ray Cylinder bug

This topic is 5098 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I''m writting a ray tracer from scratch and currently I''m trying to implement Cylinders as primitives. It''s working almost perfectly. My problem is that on the edges of the Cylinder there seems to be some sort of computational rounding error. It looks like the edges has been scratched or corrided. Normalizing all Vectors gave an improovement but it''s still visible. Any ideas? Thank you, JVFF

Share this post


Link to post
Share on other sites
Advertisement
I can think of a couple possibilities... are you using any trig functions in your intersection test? That might introduce some instability at the tangental cases, so instead you can use a closest distance between rays test. Also, numerical imprecision can cause you to slightly miscalculate the point of intersection, so the rays you spawn from that point re-intersect with the cylinder.

Share this post


Link to post
Share on other sites
I don''t know if this will help but here''s my code:

bool Cylinder::rayTrace(Point *ray)
{
Point p1 = ray->crossProduct(direction);

float a = p1.dotProduct(p1);

Point origToCenter = orig - center;

Point p2 = origToCenter.crossProduct(direction);

float b = 2 * p2.dotProduct(p1);
float c = p2.dotProduct(p2) - (radius * radius);

float determinant = (b * b) - 4 * a * c;

if(determinant < 0.f)
return false;

return true;
}

Anyway, it seems like normalizing all vectors (p1, p2, origToCenter) gives a lower noise, as stated before, but it''s still there. Direction is the normalized vector of the cylinder''s axis. I can''t seem to figure this one out. If anyone thinks of something, please tell me. Thank you,

JVFF

Share this post


Link to post
Share on other sites
Hello again,

It still doesn''t work. If I set EPSILON higher than 0.000001 the cylinder wouldn''t display. Lower than that it just gives an unoticable improovement. The noise still survives. But thank you for your replys.

JVFF

Share this post


Link to post
Share on other sites

  • Advertisement