Skip to main content
gamedev.net
🔒 Locked

Simple raytracing

Started by Deliverance 1 reply 550+ views
Original Post
Deliverance
Deliverance
I'm attempting to write a simple raytracer but I came across some problems when included planes in the raytracer. Here's what output I'm getting by raytracing a plane with normal = (0,1,0) and d = 1 Image Hosted by ImageShack.us
Shot at 2007-08-07 The function that's handling ray plane intersection tests is:

collisionInfo CPlane::IntersectRay(const tRay &ray)
{
	collisionInfo collInfo;
	collInfo.isCollision = false;
	float denominator    = Dot(ray.dir, normal);
	
	if (fabs(denominator)<EPSILON)
		return collInfo;
	
	float numerator = Dot(ray.origin, normal) + d;
	float t = -numerator / denominator;
	collInfo.isCollision  = true;
	collInfo.intersection = ray.origin+ray.dir*t;
	collInfo.t			  = t;
	collInfo.normal		  = normal;
	collInfo.material	  = &mat

	return collInfo;
}

I don't understand the weird output, what's going on?
JuNC
JuNC
At a rough guess you're not ignoring intersections for t < 0.0 (as rays which point upwards would have).

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.