Would like to clarify some optimizations techniques :)

The place for artists, modellers, level designers et al to discuss their approaches for creating content for OGRE.
Post Reply
ulukai
Gnoblar
Posts: 11
Joined: Sun Jan 08, 2006 12:02 am

Would like to clarify some optimizations techniques :)

Post by ulukai »

Hallo,
i was searching the forums, wiki, but i'm really not sure with these things:

1.) Batches - i understand that it's best for gpu to have as few objects as possible (10 1000poly objects render faster than 1000 10poly objects).
What I'm not sure of, is if this optimization applies to this (stupid example, but it makes it clear i hope): I have to boxes, using the same material, if i merge them into one mesh, where they are not connected anyhow (called element in 3dsmax) is this still optimized, will it work as one batch?

2.) If 1.) is true, than as soon as I assign different materials to those elements inside one mesh, they will go as separate batches?

3.) Texture atlases - will it really help somehow to have one 2048x2048 texture (with four 1024x1024 painted on it) instead of 4 separate 1024x1024 textures? Does this apply only if this big texture is used for one mesh, or it also helps if different parts of this texture are assigned to different objects?

4.) Open edges, interesecting geometry between two objects, intersecting geometry (polys) in one object - are they ok?

Thanks very much for reading....and helping maybe :D
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Re: Would like to clarify some optimizations techniques :)

Post by xavier »

ulukai wrote:I have to boxes, using the same material, if i merge them into one mesh, where they are not connected anyhow (called element in 3dsmax) is this still optimized, will it work as one batch?
You don't need to merge them into one mesh; if they are static in your scene you can make StaticGeometry of them. In Dagon, you can disable render state changes on (I think) a mesh-by-mesh (renderable-by-renderable) basis as well.
as soon as I assign different materials to those elements inside one mesh, they will go as separate batches?
Mostly true; there are geometry instancing techniques you can take advantage of if your needs match the restrictions of those techniques.
Texture atlases - will it really help somehow to have one 2048x2048 texture (with four 1024x1024 painted on it) instead of 4 separate 1024x1024 textures? Does this apply only if this big texture is used for one mesh, or it also helps if different parts of this texture are assigned to different objects?
It doesn't matter how many or what size the textures are. This is a way to get around the render state changes and render geometry that uses different textures in a single batch.

Good article on texture atlases (also refers to the other good nVidia article on the topic from GPU Gems): http://www.gamasutra.com/features/20060 ... v_01.shtml
4.) Open edges, interesecting geometry between two objects, intersecting geometry (polys) in one object - are they ok?
OpenGL for example will render anything you tell it to render; so will Ogre. The problem arises when you try to do thing like shadowing with that geometry.
ulukai
Gnoblar
Posts: 11
Joined: Sun Jan 08, 2006 12:02 am

Re: Would like to clarify some optimizations techniques :)

Post by ulukai »

Thanks, but :) :
xavier wrote:
ulukai wrote:I have to boxes, using the same material, if i merge them into one mesh, where they are not connected anyhow (called element in 3dsmax) is this still optimized, will it work as one batch?
You don't need to merge them into one mesh; if they are static in your scene you can make StaticGeometry of them. In Dagon, you can disable render state changes on (I think) a mesh-by-mesh (renderable-by-renderable) basis as well.
Oki, good to know, but let's say that i don't want to make them staticgeometry or disable render stages..... than will they work as one batch?
xavier wrote:
ulukai wrote:Texture atlases - will it really help somehow to have one 2048x2048 texture (with four 1024x1024 painted on it) instead of 4 separate 1024x1024 textures? Does this apply only if this big texture is used for one mesh, or it also helps if different parts of this texture are assigned to different objects?
It doesn't matter how many or what size the textures are. This is a way to get around the render state changes and render geometry that uses different textures in a single batch.

Good article on texture atlases (also refers to the other good nVidia article on the topic from GPU Gems): http://www.gamasutra.com/features/20060 ... v_01.shtml
Thanks for the link, will check it. But anyway... you mean... that texture atlases are good if i have more objects, which thanks to some techniques are rendered in one batch, but they also need this one texture, because more textures would break this one batch rendering?
xavier wrote:
ulukai wrote: 4.) Open edges, interesecting geometry between two objects, intersecting geometry (polys) in one object - are they ok?
OpenGL for example will render anything you tell it to render; so will Ogre. The problem arises when you try to do thing like shadowing with that geometry.
How serious is this problem? I know it's not good to have some polys very near each other, because than the renderer can't decide which one is closer. So would it help to intersect these object by some good amount?
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Re: Would like to clarify some optimizations techniques :)

Post by xavier »

ulukai wrote: Oki, good to know, but let's say that i don't want to make them staticgeometry or disable render stages..... than will they work as one batch?
Yes. In our project we post-process the exported .mesh.xml files to realign them into single meshes where possible (it's easier to do in the XML DOM than it is in code with HardwareVertexBuffers, etc, plus you get the optimization on the whole mesh at build time instead of runtime).
Thanks for the link, will check it. But anyway... you mean... that texture atlases are good if i have more objects, which thanks to some techniques are rendered in one batch, but they also need this one texture, because more textures would break this one batch rendering?
You can specify as many textures to your material as your GPU can handle at once (depends on how many texture units your hardware has). You use texture atlases as an optimization technique to regain batch count for use in other areas -- for example, there is little point in rendering your level geometry in dozens of batches when one will suffice.

It will make more sense after you read the articles. ;)
ulukai wrote: How serious is this problem? I know it's not good to have some polys very near each other, because than the renderer can't decide which one is closer. So would it help to intersect these object by some good amount?
Goofy topology (especially internal goofiness like "wings" or floating vertices or edges) and overuse of "hiding" mesh in other mesh will wreak havoc on, for example, stencil shadow techniques. You always want to clean up your meshes prior to exporting rather than depend on hidden face culling algorithms to do it for you at runtime.
ulukai
Gnoblar
Posts: 11
Joined: Sun Jan 08, 2006 12:02 am

Post by ulukai »

Thanks really much.
Got another question.... loooong triangles.... bad? if so, how much.... will it be faster for the engine to brake such a long triangle let's say into 6 shorter?
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Post by xavier »

Fillrate will likely be the same regardless. It only matters if your triangle spans LoD distances, or if the triangle is likely to be fully- or semi-occluded.

The engine won't break it up; if even a tiny bit of the triangle is showing, the whole object is queued for rendering (but don't quote me on that; I don't know what may have changed in Dagon)
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 538

Post by Kojack »

Open edges will also stuff up physics engines like Novodex (less so or not at all for others, Novodex's pmaps require meshes to enclose a volume with no gaps, otherwise they can leak out and form invisible collisions).
ulukai
Gnoblar
Posts: 11
Joined: Sun Jan 08, 2006 12:02 am

Post by ulukai »

thx guys 8)
Post Reply