Archived

This topic is now archived and is closed to further replies.

GekkoCube

samples on multiple texture mapped terrain?

Recommended Posts

are there any tutorials/samples on how to do multi-texturing on terrain landscapes? for example: i want the valleys to have a grass texture, the hills to have a very lush grass texture, and mountains to have a rocky/snowy texture. and i want the texture transition (i.e. valley to mountain) to be very smooth. I have seen this as a demo. but I am unsure how they did it. some theory would be great! thanks. ~ I am a DirectX to OpenGL convert! ~

Share this post


Link to post
Share on other sites
Dunno if this would work, but you could render the terrain 3 times. Once for each texture. On each render you then set the alpha values and blen it all. For example when you render it with the grass texture, you have the alpha value in the valies high, and low in the mountains and hills.


Edited by - reverse_gecko on February 22, 2002 10:16:38 AM

Share this post


Link to post
Share on other sites
There are plenty of ways...

Rendering the terrain 3 times is not the wya as it is slow...

What you do is you pregenerate the texture map using the height map... There was posting on here 1-2 weeks back check around...

Share this post


Link to post
Share on other sites
i found an article over at flipcode about pregenerating the texture, the downloadable program produces a great texture, but i am not sure how to apply it to my terrain,

http://www.flipcode.com/tutorials/tut_proctext.shtml

check it out, pretty interesting, later-



what we do in life... echoes in eternity...

Share this post


Link to post
Share on other sites
The "pregen the composite texture" technique is ok but keep in mind it cannot repeat, so it will be a bit coarse, as it is a one to one mapping (one texture to one mesh or subportion).

It can look good though if you multi-pass it with other textures with higher scaling for some better detail.

Currently I am playing with a small terrain on a small 30x30 mesh (adj. 10-100), it has 4 layers: a repeating 30x scale vertex-shadowed ground texture, a blended repeating 2x scale texture for patchy color, a blended repeating very high 750x scale texture for detail, and a blended repeating 6x scale scrolling texture for a rolling mist/cloud shadow effect. (for my Physics contest entry)

I am not using the multitexture extension but am doing it in small culled strips. Along with quite a few other elements (several cloud and water meshes, several spheres, several billboards, and several fullscreen quads for noise/dimming lightmaps, and am getting 50-100 fps on my 1 gig athlon w/ geforce2. And that w/ an unoptimized detail layer.

Whether or not you use the multitexture extension, multipass is the only way to get nice terrains. Look at several commercial games w/ good terrain and you will see many scales of texture employed.

I should also employ reverse_geckos techniques of multipassing different zoned textures, I did that in my EruptionZ app, 4 layer multipass (small 20x20 mesh!) in 180 fps, check it out. But that means 8 layers if I don''t drop 1 or 2.

zin

zintel.com - 3d graphics & more or less

Share this post


Link to post
Share on other sites
180fps!

I ran Nehe''s first few demos and I only get 80fps max!
I have a PII-350, 197 ram, and a geforce2 mx 200 (which can theoretically o about 25 million triangles per sec).

What am i doing wrong?
what can i do to improve my fps for Nehe''s demos?

~ I am a DirectX to OpenGL convert! ~

Share this post


Link to post
Share on other sites
You could draw each tile once for every texture that needs to be applied on it.
Here''s how i do it:
First texture, you disable blending and draw the first one, with glColor3f setting the needed percentage (0,0,0 or 1,1,1) of the current texture for each vertex.
Then, for the second or third texture if they need to be drawn, you set blending to (GL_ONE, GL_ONE) which is additive blending and you draw the triangle again, with the new texture, and for each vertex you set the glColor3f to the percentage needed.
This way you can have three textures fading into each other at the three vertexes of a triangle.
Note: the total sum of the glColor3f at any vertex should not exceed (1,1,1) and not be below (0,0,0), except if you do lighting yourself.

Share this post


Link to post
Share on other sites
Ok, doing multi-pass texturing will definitely make my terrain look better...but thats not exactly what im trying to do right now.

Here is what i mean...for example:
I have a landscape representing the Grand Canyon.
On the surface ground level, I want a grass texture.
On the cliffs of the trenched I want a dirt texture.
And on the very bottom of the canyon I want a mud texture.

So now I have 3 textures to work with.
But within my loop I call

SetTexture(0,&texture); // directx code.
terrain->Render();
SetTexture(0,NULL);

which basically updates my quadtree and then renders it!
But notice that I apply the texture to the whole mesh!

Should I just simply call different SetTexture() calls within the terrain->Render() function? This way I can apply textures to different areas of the mesh...although it would require more coding to get the texture coordinates right.

Now I''m more curious then ever!! How do "they" apply multiple textures on a terrain mesh?!?!
Argh!


~ I am a DirectX to OpenGL convert! ~

Share this post


Link to post
Share on other sites
THe way i did it, was pregenerating the textures. I take 5 diff, textures, snow, rock, grass, beach, and then water. This is how the article i mentioned earlier does it and their is code to download too that shows you how to do it. It blends the five textures, depending on the height value, into one texture which i then apply to my mesh. The end result is very nice, and is what i think you are looking for, i could post a pic of my textured terrain if you want to see it. Give it a try and if you need help with the code let me know, later-

what we do in life... echoes in eternity...

Share this post


Link to post
Share on other sites
Hey would this be possible... Or has it been done...

Having to pregenerate a terrain texture, is only good for small to medium sized no repeating terrains, etc...

Multipass textured terrains can be huge but lack the details (snow, mud, grass, dirt, rock etc...

What if be doing some visibility testing (portal, octree, b-tree or what ever) the textures can be blended in real time...

So you have a terrain mesh and apply a multipass technique with a base texture, detail texture etc... Then what ever can be seen depending on the height you blend in the appropriate texture depending on height, snow on higher levels, dirt/mud at lower levels, rock somewhere in between etc...

Share this post


Link to post
Share on other sites
Here''s a shot of my EruptionZ app:

http://zintel.com/images/EruptionZ.jpg

It has water, grass, dirt and a cloud texture for snow.

It is a cell-based terrain mesh, I have a small table of heights describing the "zones", and I scan the mesh and determine which zone/texture the cell is in/straddles. Then I render it in 4 passes, cells which start and end in the same zone get drawn, otherwise they get blended.

This technique allows for texture repeat, so detail can be tweaked in, for example I could have increased the detail of the dirt layer.

zin



zintel.com - 3d graphics & more or less

Share this post


Link to post
Share on other sites
here is screen shot, it is alittle bright, but should show you how the pregenerating looks in the end. Later-

what we do in life... echoes in eternity...

Share this post


Link to post
Share on other sites
colonelfr: yes I use the same vertex coords, but maybe different vertex colors and tex coords in EruptionZ.

In my current app I use the same vertex and tex coords, using the texture matrix for texture scaling and scrolling. I also do vertex coloring/shadowing. Instead of 4 layers w/ different textures for patches, I do 4 layers for ground, patch color, detail and scrolling shadows, from my PhysicZ entry:

http://zintel.com/images/green.jpg

zin

zintel.com - 3d graphics & more or less

Share this post


Link to post
Share on other sites