texture management

Started by
1 comment, last by GameDev.net 19 years, 1 month ago
I am in the middle of making a building, that requires more than one texture (about 2 or 3). I heard constantly switching textures is costly and should be avoided as much as possible. However, if my building requires three textures (let's say a house, one texture for wall, one for roof, one for chimney), rendering one building would switch the textures thrice. If I want to have about 40 of this building, I need to switch 120 times! So, I have been thinking about possible solution. One is to separate the roof, the wall, and the chimney, treating them like separate objects. Draw all the chimneys, then the roofs, then the walls. Three texture switching. I don't like this solution because then I can no longer do: house.draw(); The roof and wall and chimney constitute a house. It is just against my software design :P. Second solution is to combine the textures required for a house into one texture, and heavily rely on textures coordinates. I like this solution, but I just figured that I also need the flexibility of mixing and matching textures. Like brick walls+red roof+red chimney, or wooden walls+green roof+red chimney. I cannot do such thing if I combine the textures. Plus, texture coordinate are not always accurate. So, I just want to know how you guys handle this problem. If your model requires more than one texture, how do you render it?
Advertisement
Quote:Original post by alnite
If your model requires more than one texture, how do you render it?


Well... If you're model uses 3 seperate textures you're still doing 3 different render calls. So really it's only house.draw() because of how it's set up. You should really be batching all your render calls anyway. So, I'd recommend leaving the house.draw() design that you have, but creating an extra layer between an object and rendering of that object. IE: house.draw() shouldn't directly be drawing the house, it should just insert the house into a list of objects that should be rendered for the frame. Your renderer should take care of sorting objects based on render states, shaders and textures. So you get the best of both worlds, efficient rendering and good design.

Good luck with it and if there is anything else you need to know just let ask.
use texture atlas.

This topic is closed to new replies.

Advertisement