Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

3DXD

Rendering Optimization Question with Quads.

This topic is 5223 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Firstly, thanks to all who have helped me with my other questions, and I did search and read alot of other posts before asking this, but I guess sometimes your own question doesn''t seem to make sense unless you ask it :-(. I have a little application that I am learning DirectX on. I have a dynamically generated "dungeon". Now, what it really does it take the max depth/max width and divide it by the (width of each tile) and created a large square(floor and ceiling) filled with "4 walled cubes". Now I turned off my collision detection so I can walk through the walls and everything works great. Now I have culling Off, so it was rendering back and front all the time. Another thing it was doing was that for every "square" the square next to it would share its left wall with the right wall of the previous square. The Row above it would share its "front" wall with the previous rows back wall. Now of course this wasn''t very optimized especially with culling off. So I wrote it to be smart enough NOT to create Quads for those walls that are duplicated and it cut my Quads and total vertices in about half which was nice. Now my questions relate to optimizing it a little more please. 1. Lets Say that I have now gone through and removed all the walls to create the "path" to the stairs to the next level. So now there are missing walls as needed. My problem is that I now have lets say 100 quads left. The Walls can have different textures applied to give them a little different look. This appears to force me to render each wall in its own "cycle" So I am doing this. 1. Set the vertex buffer 2. Set the texture 3. Set the texture states 4. Draw primitive This would happen say 100 times(or however many "walls" I have). Now "if" I knew which walls were assigned the same texture, then maybe I could create a vertex buffer that had all those quads, and so on and so on so its didn''t have 100 calls. But aside from that, am I doing the most efficient things here, or should I merely create one quad(in memory), set the vertexbuffer, THEN loop through, changing the texture, change the world matrix(I believe this is correct) for that wall and then call drawprimitive for each wall. Or am I just way off. I was even thinking of having the engine be smart enough to figure out what walls are "next" to each other and then make them one quad instead of multiples, however, I then have the problem that I have to "stretch" the texture, which, although I would it would be stretched "N" times = "N" walls. 1. But my question there is. Does "stretching" a texture "cost" more performance then just have multiple quads that are rendered independently? I notice that stretching a texture across each individual "tile" may or may not cost in performance I haven''t really been able to totally figure it out. So for instance my floor tiles. I used to use one giant quad, however then my "texture" was horribly distorted. So I decided to go one quad per "cube". My texure still looked a little "small", so I decided to add code that would allow me to dynamically assign a max value to duplicate the texture. When I stretch it 4 times the floor looks fabulous, but of course I can''t assume this is good practice. I am so confused lol. If you can help make my mind relax a bit I would be grateful Thanks!!

Share this post


Link to post
Share on other sites
Advertisement
The best optimization you can make is to keep all quads that have the same texture drawn with a single call to draw primitive.

Generally speaking, you want to make as few calls to draw primitive as possible (unless it would result in other unecessary things, like vb locks). Typically, if your scene has a total of 10,000 triangles with 2 different textures, you should be making 2 draw primitive calls. If you had a million triangles, you''d probably want to cull some of them out.

In the end, though, drawprimitive can handle up to 1,048,576 (at least on the geforceFX) triangles per call. A geforceFX 5900 can render a few hundred million triangles per second, so it''s pretty clear cut that a huge draw prim call isn''t going to pose much of an issue for it.

Share this post


Link to post
Share on other sites
Thanks Etnu :-)

Do you by chance know what the "cost" of having a texture duplicated(by setting the max tu/tv to say 2.0) across a larger quad is compared to just having two smaller quads with the same texture mapped?

Thanks!!

Share this post


Link to post
Share on other sites
Unless the person writing your video card drivers is a complete idiot, there''s no difference. Most video cards support tiling a texture many thousands of times without issue.

Share this post


Link to post
Share on other sites
Thanks a ton for the feedback, sorry for making you post twice in two different places.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!