Thread: Voxel Rendering (Beginner)

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    45

    Voxel Rendering (Beginner)

    Hi,

    Im trying to build a voxel renderer, however im going to need some help as I am a total beginner to this.

    Im going to use the ray casting technique, and im going to cast through every pixel on my view plane. My question is given my 3D Array of pixel values (R,G,B) how do I cast the ray and find which voxel (element in 3d array) the ray hits?

    Many Thanks
    -Alex

  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Something like this? (And following pages.) http://www.permadi.com/tutorial/raycast/rayc4.html
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  3. #3
    Registered User
    Join Date
    Aug 2006
    Posts
    45
    Yes, something like that.

    However, that takes shortcuts and uses strips and other optimizations that I don't want. I ideally want it to cast through every pixel on the view plane and calculate the colour of that pixel based on the intercept of the ray and an actual voxel.

    Sorry If Im not making any sense, im really new to this

    Cheers
    -Alex

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    So . . . you want a ray that passes through every pixel in your 3D space? What do you mean?

    BTW, I probably shouldn't be helping you with this, I'm newer than you are.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  5. #5
    Registered User
    Join Date
    Aug 2006
    Posts
    45
    Quote Originally Posted by dwks View Post
    So . . . you want a ray that passes through every pixel in your 3D space? What do you mean?

    BTW, I probably shouldn't be helping you with this, I'm newer than you are.
    No.

    There is a view Plane (The eventual image you see). You shoot a ray from a constant point through each pixel on the view plane. Follow the ray through until it hits the closest voxel in its path.

    I just don't know how to find the intercept of the ray and voxel mathematically/programming.

    Cheers
    -Alex

  6. #6
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    I really have no idea. The only thing I can suggest is to keep looking. Perhaps the tutorial I posted has the answer to your question later on, such as here: http://www.permadi.com/tutorial/raycast/rayc7.html
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  7. #7
    Registered User
    Join Date
    Aug 2006
    Posts
    45
    Quote Originally Posted by dwks View Post
    I really have no idea. The only thing I can suggest is to keep looking. Perhaps the tutorial I posted has the answer to your question later on, such as here: http://www.permadi.com/tutorial/raycast/rayc7.html
    Yeah,

    Had a look through it. Not really what I wanted, it seems to cut many corners to get a good frame rate.

    All I want really is an algorithm (simple not optimised) to calculate the closest voxel intersection along a ray.

    Cheers
    -Alex

  8. #8
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    How about this hit from here?

    The basic algorithm looks pretty simple.
    Code:
    loop {
        if(tMaxX < tMaxY) {
            tMaxX= tMaxX + tDeltaX;
            X= X + stepX;
        }
        else {
            tMaxY= tMaxY + tDeltaY;
            Y= Y + stepY;
        }
        NextVoxel(X,Y);
    }
    It probably glosses over a lot of details, though.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  9. #9
    Registered User Frobozz's Avatar
    Join Date
    Dec 2002
    Posts
    546
    Ken Silverman released the source code to his voxel library if you want to check it out. His coding tends to be messy though.

    http://www.advsys.net/ken/voxlap/voxlap05.htm

  10. #10
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    If you are casting a ray from the viewer through every pixel on the screen you are not doing voxel rendering, you are doing ray tracing.

    Voxel rendering is an approximation using volumes and does not require that you ray-cast the entire screen. There are several methods of rendering voxels but the ray-casting method is more suited to terrain than it is 3D objects.

  11. #11
    Registered User
    Join Date
    Aug 2006
    Posts
    45
    Quote Originally Posted by Bubba View Post
    If you are casting a ray from the viewer through every pixel on the screen you are not doing voxel rendering, you are doing ray tracing.

    Voxel rendering is an approximation using volumes and does not require that you ray-cast the entire screen. There are several methods of rendering voxels but the ray-casting method is more suited to terrain than it is 3D objects.

    Ok i only got the ray casting idea from a voxel terrain tutorial. Could you please explain further the proper technique?

    Thanks
    -Alex

  12. #12
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    In one post? Hehe. No way.

    Google it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. scene graph rendering techniques
    By ichijoji in forum Game Programming
    Replies: 7
    Last Post: 03-19-2006, 12:17 AM
  2. Terrain engine idea
    By VirtualAce in forum Game Programming
    Replies: 15
    Last Post: 04-03-2004, 01:30 AM
  3. Manual rendering disappears
    By Magos in forum Windows Programming
    Replies: 7
    Last Post: 02-29-2004, 09:25 PM
  4. voxel based rendering
    By Silvercord in forum Game Programming
    Replies: 1
    Last Post: 03-20-2003, 05:14 PM
  5. For doubleanti, Voxel algorithms - very long
    By VirtualAce in forum Game Programming
    Replies: 4
    Last Post: 12-17-2001, 01:34 PM