Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7905499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:30:20+00:00 2026-06-03T10:30:20+00:00

I’m looking for a good ray-octree intersection algorithm, which gives me the leafs the

  • 0

I’m looking for a good ray-octree intersection algorithm, which gives me the leafs the ray passes through in an iterative way. I’m planning on implementing it on the CPU, since I do not want to dive into CUDA just yet 🙂

At the moment, my Voxel raycaster just does 3D DDA (Amanatides/Woo version) on a non-hierarchic array of XxYxZ voxels. You can imagine that this is pretty costly when there’s a lot of empty space, as demonstrated in the following picture (brighter red = more work 🙂 ):

Workload for dumb 3D DDA - red = more work

I’ve already figured out that there are two kinds of algorithms for this task: bottom-up, which works from the leafs back upwards, and top-down, which is basicly depth-first search.

I’ve already found Revelles’ algorithm from 2000, called An efficient parametric algorithm for octree traversal, which looks interesting, but is quite old. This is a top-down algorithm.

The most popular bottom-up approach seems to be K. Sung, A DDA Octree Traversal Algorithm for Ray Tracing, Eurographics’91, North Holland-Elsevier, ISBN 0444 89096 3, p. 73-85. Problem is that most DDA Octree traversal algorithms expect the octree to be of equal depth, which I do not want – empty subtrees should just be a null pointer or something similar.

In the more recent literature about Sparse Voxel Octrees I’ve managed to read through, (most notably Laine’s work on SVO’s, they all seem to be based on some kind of GPU-implemented version of DDA (Amanatides/Woo style).

Now, here’s my question: does anybody have any experience implementing a basic, no-frills ray-octree intersection algorithm? What would you recommend?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T10:30:21+00:00Added an answer on June 3, 2026 at 10:30 am

    For the record, this is my implementation of the Revelles paper I ended up using:

    #include "octree_traversal.h"
    
    using namespace std;
    
    unsigned char a; // because an unsigned char is 8 bits
    
    int first_node(double tx0, double ty0, double tz0, double txm, double tym, double tzm){
    unsigned char answer = 0;   // initialize to 00000000
    // select the entry plane and set bits
    if(tx0 > ty0){
        if(tx0 > tz0){ // PLANE YZ
            if(tym < tx0) answer|=2;    // set bit at position 1
            if(tzm < tx0) answer|=1;    // set bit at position 0
            return (int) answer;
        }
    }
    else {
        if(ty0 > tz0){ // PLANE XZ
            if(txm < ty0) answer|=4;    // set bit at position 2
            if(tzm < ty0) answer|=1;    // set bit at position 0
            return (int) answer;
        }
    }
    // PLANE XY
    if(txm < tz0) answer|=4;    // set bit at position 2
    if(tym < tz0) answer|=2;    // set bit at position 1
    return (int) answer;
    }
    
    int new_node(double txm, int x, double tym, int y, double tzm, int z){
    if(txm < tym){
        if(txm < tzm){return x;}  // YZ plane
    }
    else{
        if(tym < tzm){return y;} // XZ plane
    }
    return z; // XY plane;
    }
    
    void proc_subtree (double tx0, double ty0, double tz0, double tx1, double ty1, double tz1, Node* node){
    float txm, tym, tzm;
    int currNode;
    
    if(tx1 < 0 || ty1 < 0 || tz1 < 0) return;
    if(node->terminal){
        cout << "Reached leaf node " << node->debug_ID << endl;
        return;
    }
    else{ cout << "Reached node " << node->debug_ID << endl;}
    
    txm = 0.5*(tx0 + tx1);
    tym = 0.5*(ty0 + ty1);
    tzm = 0.5*(tz0 + tz1);
    
    currNode = first_node(tx0,ty0,tz0,txm,tym,tzm);
    do{
        switch (currNode)
        {
        case 0: { 
            proc_subtree(tx0,ty0,tz0,txm,tym,tzm,node->children[a]);
            currNode = new_node(txm,4,tym,2,tzm,1);
            break;}
        case 1: { 
            proc_subtree(tx0,ty0,tzm,txm,tym,tz1,node->children[1^a]);
            currNode = new_node(txm,5,tym,3,tz1,8);
            break;}
        case 2: { 
            proc_subtree(tx0,tym,tz0,txm,ty1,tzm,node->children[2^a]);
            currNode = new_node(txm,6,ty1,8,tzm,3);
            break;}
        case 3: { 
            proc_subtree(tx0,tym,tzm,txm,ty1,tz1,node->children[3^a]);
            currNode = new_node(txm,7,ty1,8,tz1,8);
            break;}
        case 4: { 
            proc_subtree(txm,ty0,tz0,tx1,tym,tzm,node->children[4^a]);
            currNode = new_node(tx1,8,tym,6,tzm,5);
            break;}
        case 5: { 
            proc_subtree(txm,ty0,tzm,tx1,tym,tz1,node->children[5^a]);
            currNode = new_node(tx1,8,tym,7,tz1,8);
            break;}
        case 6: { 
            proc_subtree(txm,tym,tz0,tx1,ty1,tzm,node->children[6^a]);
            currNode = new_node(tx1,8,ty1,8,tzm,7);
            break;}
        case 7: { 
            proc_subtree(txm,tym,tzm,tx1,ty1,tz1,node->children[7^a]);
            currNode = 8;
            break;}
        }
    } while (currNode<8);
    }
    
    void ray_octree_traversal(Octree* octree, Ray ray){
    a = 0;
    
    // fixes for rays with negative direction
    if(ray.direction[0] < 0){
        ray.origin[0] = octree->center[0] * 2 - ray.origin[0];//camera origin fix
        ray.direction[0] = - ray.direction[0];
        a |= 4 ; //bitwise OR (latest bits are XYZ)
    }
    if(ray.direction[1] < 0){
        ray.origin[1] = octree->center[1] * 2 - ray.origin[1];
        ray.direction[1] = - ray.direction[1];
        a |= 2 ; 
    }
    if(ray.direction[2] < 0){
        ray.origin[2] = octree->center[2] * 2 - ray.origin[2];
        ray.direction[2] = - ray.direction[2];
        a |= 1 ; 
    }
    
    double divx = 1 / ray.direction[0]; // IEEE stability fix
    double divy = 1 / ray.direction[1];
    double divz = 1 / ray.direction[2];
    
    double tx0 = (octree->min[0] - ray.origin[0]) * divx;
    double tx1 = (octree->max[0] - ray.origin[0]) * divx;
    double ty0 = (octree->min[1] - ray.origin[1]) * divy;
    double ty1 = (octree->max[1] - ray.origin[1]) * divy;
    double tz0 = (octree->min[2] - ray.origin[2]) * divz;
    double tz1 = (octree->max[2] - ray.origin[2]) * divz;
    
    if( max(max(tx0,ty0),tz0) < min(min(tx1,ty1),tz1) ){
        proc_subtree(tx0,ty0,tz0,tx1,ty1,tz1,octree->root);
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I am trying to loop through a bunch of documents I have to put
I would like to count the length of a string with PHP. The string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.