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 10 of 10

Thread: volume coloring

  1. #1
    Junior Member Regular Contributor
    Join Date
    Oct 2003
    Location
    Arlington, Tx, USA
    Posts
    179

    volume coloring

    i have a cube in a 3d space. when i zoom into it, i can c only the walls when im within the cube. is there ne way to fill the interiors of a cube? i mean the whole volume contained inside the cube should be colored as its walls. or is there ne other way that when im inside the cube i dont c the walls.
    thank u

  2. #2
    Senior Member OpenGL Pro
    Join Date
    May 2000
    Location
    Naarn, Austria
    Posts
    1,142

    Re: volume coloring

    It is not possible to directly fill the cube, but there may be a workaround.

    What exactly do you expect to see when the camera is inside the cube?

  3. #3
    Junior Member Regular Contributor
    Join Date
    Oct 2003
    Location
    Arlington, Tx, USA
    Posts
    179

    Re: volume coloring

    i dont want to c ne empty spaces inside. i just want it to be filled. i wanted it to be filled with the same color as its walls. it should give a solid feeling. not a hollow feel. the reason im doin this is cause when i move around in the 3d space and zoom into some of my objects, and when i get inside them, i can c only the polygon walls. i dont want that to happen.

    Originally posted by Overmind:
    It is not possible to directly fill the cube, but there may be a workaround.

    What exactly do you expect to see when the camera is inside the cube?

  4. #4
    Intern Contributor
    Join Date
    Jan 2001
    Posts
    87

    Re: volume coloring

    Is your cube textured?

    If no, and cube has one solid color, you can always disable lighting for back-facing polygons.

  5. #5
    Intern Newbie
    Join Date
    Apr 2000
    Posts
    44

    Re: volume coloring

    It sounds like you're wanting some sort of volume rendering thing going on (or something.)

    Let's get this straight:

    You move around, and when you pass through a polygon on the outside of a cube, you can see inside (and all the inside polys of the cube.) Now... what you *say* you want sounds like...
    Let's say the cube is red.
    As soon as you move inside of the cube, you want the viewport to be completely red...

    -Or- the cube is red.
    When you move inside of the cube, you want the cube to be "bored out" in the area/point the viewer is looking from.

    Unfortunately, openGL isn't made to do this automatically... I remember when I got into 3d stuff and it was such a let down to see that the stuff that looked so concrete was just a paper-wall looking structure internally. I wanted to know how to make solid objects.

    What you probably want as a solution, is to just not let the user enter into the 3d "solid" (how could they anyway if it's a solid?)
    This is how all the 3d shooters and games out there generally take care of this problem.

    You'll want to read up on collision detection. There are actually some libraries out there that will do what (it sounds like) you want. Some are very fully featured and calculate the physics in a dynamic environment. Others are more "bare-bones" and only do stuff like clipping a camera's position to be outside of an object.

    If you want to calculate it yourself, you'll probably want to search for infomation on.... nm, actually flipcode.com (www.flipcode.com) has a "code of the day" (right hand side of front page, below image of the day) that calculates the point of intersection between a sphere and a "polygon soup" (any weird old polygons - doesn't require special cases.)

    You'd want to use the camera as a sphere (so not to get too close to objects - hey, even my nose gets in the way once I'm and inch away from whatever I'm looking at... right?)

    Hope this helps,
    -Michael

    ps. If you're really trying to see inside the object (and want it solid) check into volume rendering, voxels, and medical imaging with voxels (www.google.com)

  6. #6
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,421

    Re: volume coloring

    You dont need volume rendering I think.

    You can always do the cap rendering trick (I dont know the official name).

    Basically, you render back faces by incrementing the stencil, then render front faces by decrementing the stencil.
    For the final pass, you render a fullscreen quad and use stencil testing to reject fragments when stencil=1 and pass if stencil is 0.

    Some CAD programs do this by rendering the cut face all red, but you can always texture it.
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

  7. #7
    Intern Contributor
    Join Date
    Dec 2000
    Location
    Redmond, WA
    Posts
    89

    Re: volume coloring

    Stencil capping is illustrated by the Rage128 Stencil Cap sample (assuming that's what you're after). Of course, this uses a user clip plane rather than the front plane, which you seem to be clipping your object against. I'm sure you could make it work that way too.

    -Jason

  8. #8
    Member Regular Contributor
    Join Date
    Jun 2000
    Location
    Cambridge, England
    Posts
    270

    Re: volume coloring

    IIRC there's an nVidia only depth clamp extension which could be used when the viewpoint is outside the box, but the near clipping plane intersects the box. If the viewpoint is inside the box then you can just use a full screen quad.

  9. #9
    Member Regular Contributor
    Join Date
    Jul 2000
    Location
    Augsburg, Germany
    Posts
    415

    Re: volume coloring

    Originally posted by V-man:

    You can always do the cap rendering trick (I dont know the official name).
    ...
    Some CAD programs do this by rendering the cut face all red, but you can always texture it.
    Hi,

    I do this trick for CAD rendering, but its very slow for complex models. You could do it much faster, depending on the structure of your 3d models in background. I have a BSP here, so it is very easy to throw my actual camera position into the BSP and get returned if I'm inside or outside. Then I would simply color the whole screen in the color of this object (like somebody said before).

    Kilam.

  10. #10
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,421

    Re: volume coloring

    Originally posted by Kilam Malik:
    Hi,

    I do this trick for CAD rendering, but its very slow for complex models. You could do it much faster, depending on the structure of your 3d models in background. I have a BSP here, so it is very easy to throw my actual camera position into the BSP and get returned if I'm inside or outside. Then I would simply color the whole screen in the color of this object (like somebody said before).
    If rendering twice is slow, then you could use that extension (double sided stencil?) plus make use of whatever else there is (like VBO).

    But since this is a per fragment operation, you have no choice but to render ALL front and back faces.
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

Posting Permissions

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