Advertisement

Backface culling and portals

Started by February 10, 2000 01:20 PM
7 comments, last by nes8bit 25 years ago
A very confusing thing is culling. If you were to cull your poly''s yourself, how do you render them in D3D? I do not like the idea of multiple DrawPrimitives! How does Q3A do it in OpenGL? To get more in depth(and to make it harder), how will you render it with multiple textures? (In a 3d shooter engine) I am rendering about 10000 poly''s per scene.
The whole point behind culling is *not* drawing the polygons. If you cull the polygon then don''t send it down the pipeline. Seems straightforward to me.

Do you perhaps mean clipping?
Advertisement
There are many of ways of doing culling.

If you want to do backface culling (and you generally do) you''ll probably do best to let D3D or OpenGL drivers handle that. That way you don''t have to break up your objects and call multiple DrawPrimitives. If you absolutely must do your own backface culling then do a cullcheck on each triangle in the object and put all triangles that passed into one list and then call DrawIndexedPrimitive.

Object culling is when you don''t draw objects that are not visible. This is mostly done by checking if the boundingbox (or sphere) of the object is outside the viewfrustrum or not.
I know that, but I wanted to find an easier way of rendering *poly''s that need rendering* than looping through every vertex. Indicies sounds good to me.
the dx7 sdk says DrawIndexedPrimitive has to transform all the vertices in the array before it picks out the indexed ones. that could make it slower or faster depending on how you handle your vertex data. in most cases, it''ll be faster i guess. in my current engine i''m working on, it made it slower than with my custom visibility algorithms with multiple DrawPrimitives.
Carl "trixter"[email=carl@trixoft.com]carl@trixoft.com[/email]http://www.trixoft.com
If the major part of the vertices in the vertexbuffer will be culled by your portal, it would probably be faster to use DrawPrimitive() instead of DrawIndexedPrimitive(). The problem is to know when the major part is culled.

It''s safer to go with vertexbuffers and DrawIndexedPrimitive(). If your engine culls a lot of the vertices then break the vertexbuffer into smaller pieces and test if the whole vertexbuffer can be culled at once.

Also when drawing with either DrawPrimitive() or DrawIndexedPrimitive() try to pack as many triangles as possible into each call. In the DirectX Developer FAQ it''s stated that you should try to put at least 100 triangles into each call.
Advertisement
I decided that I will not cull my verticies and let D3D do it. My culling/hidden surface removal system was too slow. Either way, I will be using DrawPrimitive since I have to call it for every triangle. (I am using multiple texture maps) If someone can find a better way of combining everything more efficiently then I would like to read about it. Also, there was no big performance hit when I rendered each triangle one-by-one. It was only 3 frames. I have tried to pass one light map per scene, but if the scene gets large (which it will) then on certian cards it will not render. Also, I guess I have to use small sectors for rendering. BSP-trees and compilers are way too complex to implement.
Try to bunch together all triangles that have the same texture and render them all at once. Lightmaps are a little tricky with that since they are usually unique for each polygon, but if you can let several polygons share the same lightmap, they will just use different areas of the map.

Even if you must render each triangle one at a time, you should use DrawIndexedPrimitive() with vertexbuffers, otherwise DirectX has to transform every vertex multiple times.

I think it was you, Spellbound, that wrote that in another post, but my world is much too large to have a light map for all of the poly''s. Given that I sort them correctly, I still have possible envorinment maps and if I get creative, bump maps. Intensive hardware needed? yes. Theat is beyond the point though, what I originally wanted is to be able to "portal", cull, clip, sort from front to back, then render them according to texture. Vertex Buffers aren''t that hard and everyone wants me to use them. Sounds good to me. I think it will be easier to clip my poly''s and sort them.

This topic is closed to new replies.

Advertisement