Jump to content
  • Advertisement

Archived

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

Gammastrahler

Raytracing problem with Octree

This topic is 5202 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

Hi, i coded an octree, and it works for rendering. But for my main concern, to speed up shadow calculations for my radiosity processor, it fails... the problem is not the ray / polygon intersection (it is unchanged), shadow calculations worked before using the octree. maybe it is useful to post my code for the octree raytracer: To explain: The code returns the leaf node with the smallest box that intersects the ray. The leaf is then returned and its primitives are processed by the caller.
ZNode* raytrace_node(ZNode *node, const vec3 &rO, const vec3 &delta)
{
    if (!node->ray_intersect(rO, delta))
	return 0;

    if (node->_isLeaf)
    {
	return node;
    }
		
    for (int i = 0; i < 8; i++)
    {
	ZNode *thisNode = 0;

	if (node->_octants[i])
	{
	    thisNode = raytrace_node(node->_octants[i], rO, delta);

	    if (thisNode)
		return thisNode;
	}
    }
		
    return 0;
}

Thanks in advance!

greets
Gammastrahler

Share this post


Link to post
Share on other sites
Advertisement
How do you deal with situations where the ray intersects more than one node (i.e. the common case)? It looks like the code will just return the first leaf node it finds that intersects the ray.
In my code I find the leaf node containing the start of the ray, and then walk through the octree to find all the nodes it intersects. Also, I used to do it by breaking the ray up into smaller sections, calculating the AABB for each section, and then find the nodes that intersect with those AABBs (which was still pretty quick).
Sorry if I haven''t understood the problem though .

T

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!