Terrain, rendering texture-tiles..

What would be a reasonable way to render tiles (water, dirt, rock etc.) on a terrain? I have a basic terrain constructed from a heightfield into one trianglestrip, and I have a basic idea of how to select exactly what I want to draw into each cell, but how should I render it? -I mean, wouldn’t looping through the mesh and changing the textures, re-binding them every time, be slow? How should it be done?


find out which tiles are visable.
then sort those depending on texture and draw them in the sorted order.
u will have to use multiple tri_strip calls though cause u cant bind another texture halfway through drawing a triangle strip

…then I’d have to calculate the strips every frame, because I generate (dynamically) the heights from a continuous 2d-function, which would probably be too heavy? :frowning:

…does this also mean that I can’t backface-cull single triangles from the strip? and if I can, then maybe I could do several passes, drawing only those triangles that use the current texture??


[This message has been edited by jonn (edited 01-14-2001).]

Okay. Well, if you have a great terrain, and want just to texture an oasis or something on it, you can switch depth test mode to GL_LEQUAL or how it is called and draw the oasis over. You won’t need to split the strips for the whole terrain, but you will be drawing many triangles twice. Another way would be to put the oasis in the second texture unit and don’t repeat it and have the triangles only texcoords inside the texture where the oasis should appear.

…I really need more textures than two, so maybe I’ll just have to draw individual triangles instead… :frowning:

could there be any performance gained due the fact that only the y-coords change? x and z remain the same…


If you put a set of textures in one, you’ll have the pro that multitexturing is for free if you’re already texturing, you won’t have to split the strips and you won’t have as many texture changes.

Following what has been said here, i built a terrain engine plus water, look at this code:


it is fine, but i’ve got the problem that i can see through terrain, i.e. terrain it is not “solid”, and i cant understand why !

One reason could be that the blendfunc is on, in the code you have pasted here, you terminate the blending, but are you realy sure the blending is 100% off?

what do you mean ?