Archived

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

Graham

SetTexture() and ZBuffer speed issues

Recommended Posts

I plan on making a leaf based BSP tree and then calculating the PVS. I was wondering that once I know what polygons I should render, should i render them back to front, changing the texture for each polygon; or drawing the polygons in texture order, and using the z-buffer. Is one way always faster than the other, or are there certain situations when one method will be faster? Go on an Intense Rampage

Share this post


Link to post
Share on other sites
With a Z buffer, rendering **front to back** will be faster.

The exception of course is alpha blended stuff which needs to be sorted back to front to render correctly.


Bear in mind that if your sorting is at all expensive, don't do it. If your sort mechanism is more costly per polygon than the time it takes hardware to render a polygon (many are!), then it's obviously not a good thing - just sending the unsorted data to the chip is faster in that circumstance. Same if the sorting decreases the efficiency of the on chip vertex cache


--
Simon O'Connor
Creative Asylum Ltd
www.creative-asylum.com

[edited by - S1CA on July 18, 2002 8:01:23 AM]

Share this post


Link to post
Share on other sites
What if i have a list of polygons that I have to draw and they are ordered (back-to-front or front-to-back), should I just render them and possibly call the setTexture() function after every polygon, or should i take that list and quickly sort it by texture, and call setTexture() a minimal amount of times.

Go on an Intense Rampage

Share this post


Link to post
Share on other sites
Well if people cant answer the question, maybe you could help if you told what technique you use to render. I am making a FPS with indoor maps. Which rendering technique should I use?

Go on an Intense Rampage

Share this post


Link to post
Share on other sites
You should avoid calling SetTexture() too often. rendering polygons in odd orders won''t be nearly as slow as uploading textures on a per-poly basis.

HTH, Steve

Steve
DirectX Programmer
Soon to be the new Bill Gates

Share this post


Link to post
Share on other sites
If you have a PVS for each leaf then this will just indicate which other leaves are visible.
I''d then sort this large group of polygons by texture and render each texture at a time.
I have experimented with this technique and found it to be the fastest way.
Sorting by depth on a per leaf basis may be the way to go. ie. draw the furthest leaves first, however this ruins the sorting by texture which is a must.
If you don''t have transparency issues (ie. no transparent objects/windows etc.) then just sort by texture and render in that order.

However don''t start worrying about this too much cos doing the tree building, protal generation and PVS caluclations will be enough to keep you very busy for a while I think.

Good luck
Toby

Gobsmacked - by Toby Murray

Share this post


Link to post
Share on other sites