Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Transparency and speed of rendering

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2001
    Location
    Ukraine
    Posts
    8

    Transparency and speed of rendering

    Hi all,
    I implemented the transparency in OpenGL (all triangles in my figure are semitransparent)using the depth sorting, but I have to rebuild the bsp tree after each rotation and I draw them with
    glBegin(GL_TRIANGLES);
    glEnd();
    It's very slow. 40 times drop in speed comparing to the version where I used no transparency. I tried to make each time the array to use glVertexPointer, glDrawArrays and other stuff,but it became even slower.
    Please could you tell me how to increase the speed of rendering.
    Thank you in advance.

  2. #2
    Junior Member Regular Contributor
    Join Date
    Mar 2000
    Location
    Germany
    Posts
    237

    Re: Transparency and speed of rendering

    Hi!
    I guess rebuilding the bsp every frame is the problem. Why do you do that? Is your scene not static? If it is static there´s no need to rebuild the bsp every frame and if it is not static you should try another algo or sort your array of transparent polys simply with qsort() or something like that.

    Greets, XBTC!

  3. #3
    Junior Member Newbie
    Join Date
    Jan 2001
    Location
    Burnaby, BC, Canada
    Posts
    14

    Re: Transparency and speed of rendering

    Originally posted by XBCT:
    Hi!
    I guess rebuilding the bsp every frame is the problem. Why do you do that? Is your scene not static? If it is static there´s no need to rebuild the bsp every frame and if it is not static you should try another algo or sort your array of transparent polys simply with qsort() or something like that.

    Greets, XBTC!
    XBCT's right. Rebuilding a BSP/Octree is almost certainly unbearably slow. You should probably only use the BSP for static geometry (i.e. level data) and use another method, such as bounding sphere/frustum culling for dynamic object data. I use a static Octree + the sphere/frustum culling and it's quite fast... I think stuffing all the data each frame into the Octree would give me nightmares

    [This message has been edited by soupnazi (edited 02-01-2001).]
    No soup for you!

  4. #4
    Junior Member Newbie
    Join Date
    Jan 2001
    Location
    Ukraine
    Posts
    8

    Re: Transparency and speed of rendering

    Actually my point of view is staic while objects move in the world but the relation between objects, number of objects and other stuff doesn't change. So after each rotation I have to rebuild the bsp tree because I don't know how to make minor changes in the bsp-tree and make it correct again for depth sorting.I understand that probably it's the main reason for drop in speed but how can I reuse the depth sorted triangles in previous frame for next frame?

  5. #5
    Junior Member Newbie
    Join Date
    Jan 2001
    Location
    Ukraine
    Posts
    8

    Re: Transparency and speed of rendering

    BTW I build the bsp-tree using stl multimaps and depth sort them by using as a key the distance from the centre of medians to the point of view. Is it correct?

  6. #6
    Senior Member OpenGL Pro
    Join Date
    May 2000
    Location
    Hannover, Germany
    Posts
    1,258

    Re: Transparency and speed of rendering

    I don't know how you build your bsp, but I could imagine that this would mean to allocate memory dynamically etc.
    If you simply sort them every frame (build a list of indices) that could be done faster I think. There were some discussions running about depth testing here, you can take a look at them. This would not mean to dynamically create a linked tree every frame, which should be a lot faster. The only problem is that this would lead to errors when two transparent faces intersect.
    - Michael Steinberg

  7. #7
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    3,115

    Re: Transparency and speed of rendering

    So, your objects moves around a static viewpoint. The relation between all objects are always the same. Isn't this EXACTLY the same as a fix scene with a moving viewpoint?

    Think of it, moving the viewpoint towards an object, is the same as moving the object away from the viewpoint.

    A scene can be static even though it moves. A static scene is a scene that never moves internally. A spaceship for example. It's interior is always looking the same, even though it's not moving, moving at near-light speed, turning, docking with another spaceship, and so on.

    As long as there is no eathquake that modifies the way the scene look, you shouldn't have to rebuild the tree, if done correctly that is.

  8. #8
    Junior Member Newbie
    Join Date
    Jan 2001
    Location
    Ukraine
    Posts
    8

    Re: Transparency and speed of rendering

    OK I build one time bsp tree but and traversing the tree from back to front I can achieve the proper transparency, but what should I do when I rotate the scene. The bsp tree that I build for previous frame basing on the transformed coordinates of rotation and translation matrices is no longer valid because the matrices are now different. So I have to recalculate the distances and rebuild the bsp tree.
    How can I reuse the bsp tree built for one rotation and translation matrices for other matrices?

  9. #9
    Senior Member OpenGL Pro
    Join Date
    May 2000
    Location
    Hannover, Germany
    Posts
    1,258

    Re: Transparency and speed of rendering

    I don't really understand. The scene is static, but the camera moves. A BSP only has info about the relative position between the polys.
    You want to traverse the tree this way:

    1. Go to root node
    2. Look if you're looking from the front or the back on the root face (plane)
    3. If from back, take the relative front child node, if from front take relative back of childnode
    4. Do that (recursively) until you reach the least node
    5. Start drawing

    As you can see, I'm not totally into that BSP stuff. What's the trick to draw the stuff depth sorted?
    - Michael Steinberg

  10. #10
    Senior Member OpenGL Pro
    Join Date
    Jun 2000
    Location
    Shreveport, LA, USA
    Posts
    1,757

    Re: Transparency and speed of rendering

    Just curious, are you rotating the model or the view? If you are rotating the model, then I could see why you would need to rebuild the tree. But if you are rotating the view, then there is no need to rebuild the tree. So, if you are rotating the model, stop doing so. Instead rotate the view.

Posting Permissions

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