Implementing tiles with different states...

Hi!

I have big tiled square (textured like a tiles). And I need to implement following behaviour for tiled surface: I need to be able to make some tiles of my choice to get transparent (dissapear) + I would like to decal holls on some tiles of choice.

One way I tried is - just making tiles as individual shapes - working fine of caurse, but performance wisely - not acceptable…

I wonder can I get desirable effect having only one big polygon shape (instead of individual shapes), and playing somehow with its texturing only?
The problems with individual ones is - that I need many of them, and this affect performance considerably.

Have anybody tried to do something similar? Any advices would be very much appreciated.

Sincerely,
bohdan.

You could try to work with TextureUnitStates. But You have to know, that the number of TextureUnitStates you can use is limited by the grafic-card (mine, for example, only supports two, but it’s already pretty old - most now have 4 to 16)

There is a little bug in Xith ; it allways take for granted that the graphic card has 4 texture units.
On my Geforce2 GTS, I only have 2. This causes the LWJGL renderer to assert (the JOGL renderer silently ignores this error).
I have already filled a bug report for this.

            Vincent

I’m going to look at this

Could you use multitexturing as described in: http://xith.org/tutes/GettingStarted/html/more_fun_with_textures.html?
If you wanna do something like persist zillions of bullet holes, you could divide the surface up and add a texture for each section in clamp mode. You could trace the intersection using a similiar method to mouse picking, or using your own math by ray-plane intersection, then draw a new overlay texture using Graphics2D for the section and swap it out. I’ve never tried this before so I don’t know if it would be fast enough. I don’t know how many textures a single shape can take or how the overlap effect performance, if at all. I don’t know if this idea scales well for huge areas, you might need to make more shapes for a compromise.

Yes you can have just a big Shape3D with a Grid geometry… and then you just play with UV texture coordinates… But that’s a huge job.

Thank you very much for suggestions!

Actually, at the moment I have this implemented just as JViz suggests. To modify the tile texture I am drawing the texture using Graphics2D, for “decals”. But I have individual shapes for tiles.

I can use TexUnitsStates here too (for individual shapes still, I mean), but because of my celtic TNT2 I would be limitted… especially when I need lets say few decals for a tile… I can always easily prepare my texture with Graphics2D, but with states - it would be either difficult to achieve (in my particular case) or even not possible… probably. I may end up then drawing states textures with the Graphics2D :).
And I don’t see big help of Ordered/DecalGroups here for me too…

So basically even to manage one tile - I see, that multytexturing is not helping me much (not to the level I would like to)… And unlikely it will help when switching to single Shape3D geometry for bunch of tiles… i think… hmm…

Anyhow, appreciate your thoughts, guys!

MagicSpark,

Sorry, can you specify what you mean by “big Shape3D with a Grid geometry”? Do you mean that creating big shape (instead of individual tiles) not as a one big square (4 vertices), but as set of many vertices may help?

I can specify one texcoords for one vertex… I don’t see how “Grid geometry” may help (as in case of flat shape)… ???

you can specify texcoordinates for every TextureUnitState for every vertex

That’s what I mean, and Arne is right.
You can have ONE Shape3D with ONE geometry and ONE texture composed of multiple squares corresponding to the different tiles types.

Thanks guys! Appreciate you help!

Did you get it running ?

look at my fun with texture example on xith site. In it I mess with texture coords and multi texturing…

http://xith.org/tutes/GettingStarted/html/more_fun_with_textures.html

“Mess” is actually the right word. Anyway, great work hawkwind it’s more convenient to have a tutorial than to read in the Javadoc. I think a rewrite/split of the texture tutorial would be great.

[quote="<MagicSpark.org [ BlueSky ]>,post:12,topic:26419"]
Did you get it running ?
[/quote]
Well, I believe I understood the approach you sugest, but I really have too many “states” for a tile… For example number of decals I may need - is kind of unlimited, could not be predefined… It seems I need to draw tile texture dynamically anyhow…
I see it difficult to cover by playing with texCoords and or using texture states (actually, originaly when I was posting the question I didn’t realise there is limit for a number of states you can use)…

Yes, have studied it in the first turn :slight_smile: Thanks!

For now I just left it as it was with individual shapes… Anyhow, thanks for sugestions! It was helpfull information for me!

And maybe individual shapes is better for performances, since we have frustum culling in Xith. (This is only if you don’t see your terrain from very far)

I see… Yes, when I’m close to tiles, and there are not many of them visible - performance is great. But sometimes I need to have look from far a way - yes, then there is considerable drop of performance…
But I decide I can live with it for now…

Thanks!