[fixed]Texture Resolution & Max. Polygons

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
Bate
Posts: 364
Joined: Sun Nov 01, 2009 11:39 pm
Location: Germany

[fixed]Texture Resolution & Max. Polygons

Post by Bate »

Hey everybody

Since I'm pretty new to Irrlicht, I have 2 technical questions which I couldn't find anywhere.

1.) What's the maximum resolution for a texture? I tried 20000x10000px but it crashed instantly :) It doesn't depend on my Gfx-card, does it? (HD 4770)

2.) What's the max. polycount I can use for a single entity?
e.g. with addSphereSceneNode(50.0f, 1024)

thanks in advance
Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Post by Lonesome Ducky »

1) Yes, it depends on your graphics card.
2) Because of 16 bit indices, you can have a max of 65536 vertices, but if you get a patch for 32 bit indices you can have almost limitless.
Bate
Posts: 364
Joined: Sun Nov 01, 2009 11:39 pm
Location: Germany

Post by Bate »

ah ok, so seems like 8192x8192px is max for my card.

hm...

addSphereSceneNode(50.0f, 65536)

will not compile and gives some memory error.
besides, I made a weird observation:

addSphereSceneNode(50.0f, 1024) works just fine, whereas higher polycounts (> 4000) don't improve the sphere but turn it into a lowpoly-sphere again (looks like 16); and even higher values transform it into a cylinder with a cone on top :D

what's that about?
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Bate wrote:ah ok, so seems like 8192x8192px is max for my card.
You can query the video driver to see what the maximum texture size is. Making very large textures is often just a waste of texture memory.
Bate wrote: addSphereSceneNode(50.0f, 65536)

will not compile and gives some memory error.
Are you sure that won't compile? If it doesn't compile, it would be impossible for you to get a runtime memory error. If it is really a compile error, it might be useful for you to post the error message so that the rest of us can tell what is really going on, or file a bug with the compiler vendor.
Bate wrote:addSphereSceneNode(50.0f, 1024) works just fine, whereas higher polycounts (> 4000) don't improve the sphere but turn it into a lowpoly-sphere again (looks like 16); and even higher values transform it into a cylinder with a cone on top :D
Have a look at the code for addSphereSceneNode() and createsphereMesh(). The polyCount parameter isn't the total poly count. Since the total number of indices available is 65536 for 16-bit index buffers, the sphere creation code has written to avoid creating spheres absurdly high vertex counts. The author decided it was best to limit the number of vertices instead of failing.
Bate wrote:what's that about?
It's mostly about you not looking at the source and assuming that you know what it does. Granted, the documentation isn't perfectly clear on this subject, but the source code _never_ lies.
Lonesome Ducky wrote:Because of 16 bit indices, you can have a max of 65536 vertices, but if you get a patch for 32 bit indices you can have almost limitless.
32-bit indices do not defy numerical properties. If you have a 32-bit index buffer, the most verticies would be limited to 4,294,967,296.

Travis
Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Post by Lonesome Ducky »

vitek wrote:
Lonesome Ducky wrote:Because of 16 bit indices, you can have a max of 65536 vertices, but if you get a patch for 32 bit indices you can have almost limitless.
32-bit indices do not defy numerical properties. If you have a 32-bit index buffer, the most verticies would be limited to 4,294,967,296.

Travis
Of course not, but if there are 3 indices per triangle that's 1431655765 triangles. This is more than you could ever practically need for an in-game model in this day and age. It could very well change in the future, but it'll most likely be a while before in-game models reach that many triangles :wink:
Bate
Posts: 364
Joined: Sun Nov 01, 2009 11:39 pm
Location: Germany

Post by Bate »

Alright, thanks guys. This clarifies a lot.

By the way, the reason why I don't look at the Irrlicht source is that I probably wouldn't really understand it. So for a start, I try to focus on Tutorials, Forum threads and the API which in fact, isn't entirely obvious to me at times.

Yes, it compiles but then crashes before the first rendering.

Code: Select all

ISceneNode* world = smgr->addSphereSceneNode(50.0f, 65536);
world->setMaterialTexture(0, driver->getTexture("data/world.jpg"));
world->setMaterialFlag(EMF_LIGHTING, false);
Unbehandelte Ausnahme bei 0x10081f26 in Test.exe:
0xC0000005: Zugriffsverletzung beim Schreiben an Position 0x00000000.

means:

Unhandled Exception at 0x10081f26 in Test.exe:
0xC0000005: Access Violation by writing at Position 0x00000000.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Are you sure that this can be avoided by changing the parameters? Did you check that? This error usually means that one of the pointers, i.e. smgr or driver, are not properly set.
Bate
Posts: 364
Joined: Sun Nov 01, 2009 11:39 pm
Location: Germany

Post by Bate »

Yes, I tried several times now. If the parameter is too high it crashes, I didn't change anything else.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Ah yes, we use set_used instead of push_back. And since the Y value gets 0 here, it will acess an empty array at higher indices. I guess we'll need a better parameter clamping, I move the thread to bug forum for tracking.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Ok, SVN/trunk has a different way now to calculate the maximum range of vertices to be used. This will lead to a better distribution (before it could lead to very sparse tesselation in one direction) and avoids the crash on wrong values.
Bate
Posts: 364
Joined: Sun Nov 01, 2009 11:39 pm
Location: Germany

Post by Bate »

I use mesh files now, but thanks anyway :)
Post Reply