Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 7 of 7

Thread: how to rendering bouding box for ray casting ?

  1. #1
    Intern Newbie
    Join Date
    Sep 2010
    Posts
    36

    how to rendering bouding box for ray casting ?

    Hi guys,

    I having a problem, I write a shader for gpu raycasting, but, I dont now how exactly how to "render the bounding box of volume", will be the 8 faces of cube rendered ?, I am confused with a image plane.

    Thanks

  2. #2
    Member Regular Contributor strattonbrazil's Avatar
    Join Date
    Jun 2007
    Location
    Los Angeles, CA
    Posts
    305

    Re: how to rendering bouding box for ray casting ?

    Hey Kal,

    First a box or cube typically has six sides. Basically you just have to draw some geometry on the screen, which will start the ray casting on the fragment shader. One method is to just draw a quad over your screen. A more efficient method is to just draw the three closest faces of the volume. This is the preferred way for me as I can do vertex interpolation in the vertex shader and know in world-position where the ray is pointing from my camera. Then just start marching.

  3. #3
    Intern Newbie
    Join Date
    Sep 2010
    Posts
    36

    Re: how to rendering bouding box for ray casting ?

    I am sorry, (cube = six faces, eight vertex and...).

    And how to render if I navigating into the volume, example, virtual colonoscopy ?

  4. #4
    Member Regular Contributor strattonbrazil's Avatar
    Join Date
    Jun 2007
    Location
    Los Angeles, CA
    Posts
    305

    Re: how to rendering bouding box for ray casting ?

    If you go into the cube, then you have to have to use a near clipping plane instead of the closest faces. Then if any part of the plane is outside of the box, move the ray to start at the box.

  5. #5
    Intern Newbie
    Join Date
    Sep 2010
    Posts
    36

    Re: how to rendering bouding box for ray casting ?

    Hi guys, sorry all

    Somebody have any example o see good tutorial ?

    I must to begin to work, doesn't speech.

  6. #6
    Advanced Member Frequent Contributor
    Join Date
    Apr 2003
    Posts
    669

    Re: how to rendering bouding box for ray casting ?

    And how to render if I navigating into the volume, example, virtual colonoscopy ?
    so-called "depth clamping" might help you here; read:
    http://www.opengl.org/registry/specs...epth_clamp.txt

    The idea is, that instead of opening up the cube due to clipping, the cube will still produce fragments at the clipped parts of the cube. Their depth value will be clamped to 0.0 which should help you to create correct rays.

  7. #7
    Intern Newbie
    Join Date
    Sep 2010
    Posts
    36

    Re: how to rendering bouding box for ray casting ?

    My basic idea was,

    At CPU
    1.Compute the nearest vertex of bounding box and the farthest vertex for determine the maximum distance for the ray traversal.
    2.Send the Min and Man values

    At GPU
    1.In the shader, I am recovering the position the camera, then I calculate the ray direction as

    vec3 dir= camera.xyz gl_TexCoord[0].xyz;

    and advance a positon along the ray.

    2.Composite the final color


    My problem is how to rendering the plane of image, I doing as,

    glBegin(GL_QUADS);


    glTexCoord2f(0.0, 0.0 );
    glVertex2f(-1.0, -1.0);

    glTexCoord2f(1.0, 0.0 );
    glVertex2f(1.0, -1.0);

    glTexCoord2f(1.0, 1.0 );
    glVertex2f(1.0, 1.0);

    glTexCoord2f(0.0, 1.0, );
    glVertex2f(-1.0, 1.0) ;


    glEnd();


    but noting see a image.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •