Jump to content

  • Log In with Google      Sign In   
  • Create Account


lots of textures for one mesh


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Ichi   Members   -  Reputation: 155

Like
0Likes
Like

Posted 20 June 2014 - 01:30 PM

Hello community,

 

I know this question has been asked a lot of times before everywhere in the internet but i can't come up with a good solution. My problem is if i run into the situation of having a mesh which should have different textures on different surfaces how do i switch the textures intelligent?

I don't want to use texture atlases because textures arent always the same size and i have to rework everything if i ever go over the max number of textures my atlas can contain. btw im using opengl.

 

I have read something about sorting meshes by textures, does that mean creating vbos for every texture? that would mean to create a lot of small vbos and it would uhm suck hard in my opinion.

 

So if i have a mesh like a house or something which uses like 10 different textures. How do i gonna do it? Do i really have to splitt the vbos?

 

Thanks
Ichi



Sponsor:

#2 Samith   Members   -  Reputation: 2141

Like
2Likes
Like

Posted 20 June 2014 - 02:00 PM

There are a million ways to do this and what you end up doing depends entirely on your performance/quality requirements. Let's take your house example, say there are three different types of textures: shingles on the roof, the siding of the house, and brick for the chimney.

 

Option 1: use one texture, with different portions of the texture mapping to different things: part of the texture is shingles, part is siding, part is brick. The vertex UVs make sure the correct image is mapped to the correct vertex position. This is an extremely common option.

 

Option 2: Split the shingles, siding and brick portions of the house into separate surfaces, and each surfaces has its own texture. The shingle surface uses the shingle texture, siding surface uses the siding texture, etc. This is also an extremely common technique, and is useful if you can't fix enough texture resolution for option 1 to be useful. This option does not "suck hard".

 

Option 3: Use three separate textures, but have some vertex attribute control the blending of each texture. This makes sense for terrain or something where blending between multiple textures is useful for the look of the material. It wouldn't make much sense for your house.

 

I would choose option 1 or option 2 unless I had a specific reason not to.



#3 L. Spiro   Crossbones+   -  Reputation: 13185

Like
4Likes
Like

Posted 20 June 2014 - 02:14 PM

I have read something about sorting meshes by textures

This is unrelated to the current task. This is for improved performance and while you should always do it it can be ignored in this discussion.
 

does that mean creating vbos for every texture?

If you need to change a render state between surfaces (such as a texture, a shader, a blend mode, etc.) then you logically need to make more than 1 draw call to do this.
This does not mean you have to make more than what VBO, with bark-textured surfaces in 1 and leaf-textured surfaces in another, but this is the simplest and most common way.

If you want a faster approach but a more complicated set-up, you can still use a single VBO, but then you need to keep a table for the 2 draw calls so you know which portions of the VBO to draw for each draw call.


In either case, if you need to switch textures from one surface to another, those surfaces will be drawn via more than 1 draw call, whether the surfaces are in separate VBO’s or not.


L. Spiro

Edited by L. Spiro, 20 June 2014 - 07:58 PM.

It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#4 mark ds   Members   -  Reputation: 1176

Like
0Likes
Like

Posted 20 June 2014 - 04:03 PM

How important is it to use textures of different sizes?

 

If you're prepared to rework them to be equal in size, texture arrays could be an ideal solution. Essentially you multidraw using the same vbo (but different offsets/lengths) and pass in the texture array slice number to be used as per instance data in the shader. This means no state changes, and is probably the fastest way to do this without going down the bindless route.


Edited by mark ds, 20 June 2014 - 04:05 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS