Multitextured Terrain

Started by
14 comments, last by paccabal 21 years, 8 months ago
I am also very interested in finding out how to do this.

d000hg: Ignoring LOD for a moment, does this mean that you would have to rebuild the data in your vertex buffer each time? So that you can update the diffuse and texture coordinates? Could you use multiple stream sources for this. The first stream containing the vertex information (x,y,z) and the second stream containing the diffuse/texture information? Then (in a brute force method) all you would need to do is create 4 vertex buffers (one for positional information and the other 3 for the texture information) and during the render phase just change stream 1 to each of the texture streams for each rendering pass?
Advertisement
Thanks people. You helped me alot. No I''ve understand the method.
TooTer:
I think you would rebuild VBs each frame yes, but gor a heightmapped terrain that''s better because think how much space you can save with a heightmap than a big bulky VB. For instance I store heights as shorts, which are then multiplied by a scaling factor to get the height in floats.

Your idea for 4 VBs sounds good, but I''m not up to scratch on how to do that. With single-pass multitexturing, can you make each texture stage get its vertex data from different streams? Otherwise you HAVE to do it in single passes I think, because the alpha components of the vertices are different for each texture. Ideally you''d want to do this in a single pass, not sure how though - if you understand the streams and multitexturing stuff well can you email me and explain please? Also if you want to ask about the theory side - think I got that down ok




Read about my game, project #1


John 3:16
Rebuilding vertex buffers every frame is a big performance hit in my tests though, so if the camera is not moving a lot you''ve really got to check if its neccesary...
quote:
Hi there. I want to create a terrainrenderer but I have one problem. I don't want to use just one big texture. My idea is to create the world out of different textures like grass, stone, snow etc. These texture are drawn on the specified vertexes. But how can I create a smooth drawing from one texture to another like grass to snow. I saw this technique in many demos and games (project igi, giants...) but I don't know how this can be created. I'm using DirectX 8.1 for rendering.


One nice way to do this is to allow each vertex to have two texture stages. You can put your grass texture in one, then the sand on in the other. Then you can use the vertex alpha to control how much of each is shown (this is easiest to do using pixel shaders). So if you imagine a vertex alpha on 1.0f is fully texture 1, 0.0f is texture 0, and 0.5f is half-and half, then you can apply smooth and arbitrary blends across terrain.

I would highly recommend reading the Multitexturing part of the following link to see what I mean: http://www.gamasutra.com/features/20020626/hargreaves_02.htm.

You need to be a member of gamasutra to read this but its free to sign up.

(EDIT)

Erm, well, actually I thought Shawn had written about the texture blending using the vertex alpha in that article, but it turns out he didn't, but its still worth a read. Still, that is the way that the texture blending is done.

Rory.


[edited by - protopornopants on July 25, 2002 11:05:33 AM]
quote:Original post by AndyM
Rebuilding vertex buffers every frame is a big performance hit in my tests though, so if the camera is not moving a lot you''ve really got to check if its neccesary...


Yeah it can be a speed hit, but if you can''t get a decent framerate anyway on your p3/4 with GF2/3/4 doing something that''s been around since pre 3D accelerator days, you are rubbish! Check you''re using a dynamic VB, using the D3DLOCK_DISCARD flag gave me a big increase - I got from 20fps to 40 just doing those 2 things.

You could see if all the stuff you need to draw is in your VB from last frame, but I don''t think it''s necessary.


Read about my game, project #1


John 3:16

This topic is closed to new replies.

Advertisement