can I switch texture withing a triangle_strip?

Started by
4 comments, last by 21st Century Moose 11 years ago

Hi,

I am still a noob w/ GL and I couldn't find an answer to this yet.

short version:

Assume I have 2 adjacent triangles which could be represented with Strip ABCD. Is it possible that ABC refere to a different texture than BCD?

long version:

Scenario: I have a tile based terrain. It will by split into smaller n*n pieces. Everything is more or less in x*y and I consider it "2d". Such an n*n piece will have one big texture which I want to compose of smaller tile textures (dirt, grass, ...) using render to texture (haven't done this yet)

Now I want to go 2.5d and add different height levels and cliffs. So between tiles of different level there will be another quad in x*z or y*z plane. For those I want to use another texture (rock wall or something ...) .

Currently I have created the triangle strip without texturing. For performance reasons I want to do everything in one strip. But now I am not sure if I can switch texture in between ....

thx n rgds

tmg

Advertisement

Yes, it's possible. One option is to combine all the smaller tile textures into one big texture, and then just have each triangle reference the right portion of the large texture. Another option is to use multitexturing, but might make your shaders and draw calls a bit more complicated.

[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

Like cornstalks said, the best option for your scenario is to put all the tiny textures into a single texture (like a tile sheet), and simply use texture coordinates to refer to the part texture you want to use.

If you were thinking about using glBindTexture() inside the glBegin() glEnd() pair, i don't think it's valid,

If you were thinking about using glBindTexture() inside the glBegin() glEnd() pair, i don't think it's valid,

Not to mention horribly deprecated. I hope no one uses glBegin()/glEnd().

[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

 

Yes, it's possible. One option is to combine all the smaller tile textures into one big texture, and then just have each triangle reference the right portion of the large texture. Another option is to use multitexturing, but might make your shaders and draw calls a bit more complicated.

 

Hi, thx for your and the others reply. I think I have to read more into multi texturing. BTW I am using Java and JogAmp.

"one big texture" get's difficult.

e.g.: if I have 3*3 tiles of gras (g) at the same Level (0) it looks like


ggg   000
ggg   000
ggg   000



and I think already about getting one big 30*30 texture (assuming a tile is 10*10 px).

But If I now change the top left Level to 1 I will need to render a cliff (c) additionally to it's right and one to it's lower neighbour


gcgg      100
c ||      000
g-gg      000
g-gg


'|' & '-' means the gs are directly connected. The big texture would not be symmetric or contains a lot of holes ... just writing this got me thinking but I also think this approach would not be feasible.


BWT I am inspired by the Warcraft 3 Engine.

The other option you could try is using a texture array.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

This topic is closed to new replies.

Advertisement