Skip to main content
gamedev.net
🔒 Locked

best rendering technique

Started by adam17 6 replies 900+ views
Original Post
adam17
adam17
im trying to optimize my rendering loop and i would like to get some opinions on the best rendering techniques. i havent started space partitioning yet, but im thinking of going with octrees. anyway, im starting to add ahaders and lights into the rendering loop. should i seperate the polygons by texture, by lighting, or by shader? any suggestions? btw im using opengl, c++ and glsl for the shaders
superpig
superpig
There is no best rendering technique. If there was, nobody would use any of the others.

The best solution for you is dependent on your dataset.
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
adam17
adam17
sounds fair. i guess now is the time i stop researching the net and start researching on my part...

i appreciate it
MENTAL
MENTAL
Do some experients to see which state changes impact the framerate the most.

The rule of thumb is to sort by material, as materials can change virtually every state when you switch from one to another. Of course, it depends on how complex your materials are.

Once you have your geometry grouped by material, sort them by depth (with the closest to be drawn first). This will help reduce overdraw. If your materials are very lightweight, it might be beneficial to skip the material sorting phase and just sort everything by distance. Again, this is something that you will only find out by experimenting with rendering options.

If you store which octree nodes your lights effect, it should be a fairly trivial task to calculate the closest 4 (or whatever your max amount of lights are) lights are and update that information when you draw each object. Remember that the more you compose your objects out of subobjects (and process those individually), the better the lighting will look as you won't be trying to pick the best 4 lights for a massive object that is surrounded by 30 of them. On the other hand, the more sub-objects you have, the more sorting and light-picking operations you have.

Best of luck :).
Kest
Kest
Here's the priority my engine uses:

1. Textures.
2. Mesh streams.
3. Shader techniques.
4. Materials - lighting, shader data, and other miscellaneous uploads.

From my own experience, I would say that changing textures is generally the biggest hindrance. But it depends on situations. In some cases, changing a rendering stream could be worse.
blaze02
blaze02
http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c_dec_2004/directx/graphics/programmingguide/advancedtopics/ProfilingDirect3D.asp#Controlling_Runtime_and_Driver_Optimizations
Scroll to the very bottom. It has clock cycles necessary for certain API calls. The entire page is a great read actually.

G'luck.
Kest
Kest
Quote:
Original post by blaze02
http://msdn.microsoft.com/archive/default.asp?
url=/archive/en-us/directx9_c_dec_2004/directx/graphics/programmingguide/advancedtopics/ProfilingDirect3D.asp
#Controlling_Runtime_and_Driver_Optimizations
.
Scroll to the very bottom. It has clock cycles necessary for certain API calls. The entire page is a great read actually.

G'luck.

Thanks for this link. It looks like I was mistaken about SetTexture being the biggest punch. Would texture sizes have anyhthing to do with this? Does the video card need to perform routines or move data relative to the size of the texture in order to render with it? Or in other words, does the routine to set textures time differently with a 1x1 image than with a 4096x4096?
Morpheus011
Morpheus011
Changing shader state is the most expensive operation in general (as far as GLSL is concerned, not positive if this is true for HLSL/Cg but I would assume so) so usually you'll want to sort by shaders, then materials, then textures.

There's a few decent threads on this topic spread throughout the graphics theory forum IIRC.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.