Sign in to follow this  

texture management

This topic is 4664 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 4664 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this