loading a large amount of textures...

Started by
6 comments, last by Pipo DeClown 19 years, 7 months ago
Hi, How is it possible, or whats the best way, to efficiently load up to 1000 textured quads or sprites? These may not be on the screen at the same time, but it is necessay that they load at the same time... fast. Any help? Thanks
Advertisement
Do each of them have a different texture or the same one?

Either way, I recommend creating a vertex buffer the size of 4 * 1000 * sizeof(quad's vertex) and a 16-bit index buffer the size of 6 * 1000 * sizeof(WORD), then filling them with data, and at render time just draw them (with offsets, if you need to change textures between them).

And, if you want only screen aligned quads with no rotations, you could use point sprites to save memory and bandwidth, albeit with some hardware-imposed limitations.

Niko Suni

Quote:Original post by Nik02
Do each of them have a different texture or the same one?


they're all different.

Quote:Original post by Nik02
And, if you want only screen aligned quads with no rotations, you could use point sprites to save memory and bandwidth, albeit with some hardware-imposed limitations.


I'll need 3d transformations: smooth scaling, translation and rotation.
Quote:Original post by xyz
Quote:Original post by Nik02
Do each of them have a different texture or the same one?


they're all different.


I recommend using a texture atlas technique then - packaging many small textures onto as few big textures as possible, and using texture coordinates to show correct parts of the texture at each quad. ¨
It becomes important to sort the geometry by the atlas texture used, if you use this technique - but it's still more efficient than brute force method of creating own texture objects for each quad, because you don't need to change the actual textures so often and you can draw all quads refering to the same atlas in a single call.

Quote:

I'll need 3d transformations: smooth scaling, translation and rotation.


Point sprites are probably out of question then, unless you want to implement a custom sampler in pixel shader. It is definitely possible, though, and scaling and translation could still be done in the vertex stage, as usual.

If you're not confident with shaders, the previous technique may prove too difficult, in which case I recommend constructing the quads manually.

Niko Suni

Well, depending on how many unique textures there are, you would load each texture into it's own texture resource. If you have a lot of closed meshes, chances are you won't be able to get away with using an index buffer since texture coordinates are likely to be different at each vertex, defeating the purpose of using one. But you would want to put all the vertexes into a single vertex buffer, and sort their rendering by texture to minimize state changes. I would suggest creating a special face object for this purpose that stores its vertex offset and number in the vertex buffer, but can be sorted independently of the vertexes. That way you don't have to fuddle with the physical vertex data at all.

If the texture state changing starts to get in the way, you'll have to start putting a few textures into a single resource and fiddling with texture coordinates. I explained it a bit better here, and I just noticed that Nik02 explained it pretty well above.
Have you thought of ID3DXSprite? If not, consider it!

I recommend the texture-packaging idea, you should at least try to group them on color or something [wink]

And if that still doesn't work, you should try to use the infinite-world method. You split your world into texture zones (you can do this based on position, or based on time (in techdemos)) and load a group of textures when you enter one of those.
thanks a lot! Are there any papers/web sites showing the techniques you mentioned?

And one more thing: what to you think I should use? sprites or textured quads?

Note: I need to have run-time capability to add or remove images from the view...
Well, texture-packaging is just what it says: you take some files and put the images together in one file, and split using RECTs (ID3DXSprite) or UV-Coördinates (Textured Quads). The texture matrix or whatever can help with doing UV transformations (without locking the vertices), this is speedier if for some dumb reason you choose to use Textured Quads. [wink]

As for the infinite-world method, the name I just thought up. I was refering to the technique used in Dungeon Siege (it used this method to create an endless world by loading parts of the world as you slowly approached them). It might sound like an overkilling-method, but if you have 1000 textures, I don't know if this is such a bad idea (as long as you keep it fast, clean & simple; no need for Dungen Siege style [wink]).

I'd try packing the textures first, and then see if the infinite-world method is necessary. [wink]


I wink a lot.

This topic is closed to new replies.

Advertisement