Faster Terrain Rendering!

Started by
-1 comments, last by Miyamoto 23 years, 5 months ago
Hi I am working on making a 3D RPG using Direct X in Microsoft Visual C++. I am working on speeding up the terrain rendering. Right now, multiple level of detail terrain is too complicated for me and I would probably be spending too much time only on terrain rendering rather than game design. I am using a type of the Brute Force method of rendering. Here is the way I do terrain rendering: - A 128 X 128 height map is split up into blocks of 4x4 - The visibility for a 4x4 section is calculated - If visible, then render the 16 tiles - Each tile is 2 triangles, I render one tile at a time using the DrawPrimitive (Triangle Strip method) Some things I have tried were a DrawIndexedPrimitive with the texture coordinates like this at each vertex in a 4x4 chunk: 0,0 1,0 2,0 3,0 4,0 0,1 1,1 2,1 3,1 4,1 0,2 1,2 2,2 3,2 4,2 0,3 1,3 2,3 3,3 4,3 0,4 1,4 2,4 3,4 4,4 I thought, this would be faster but it was actually slower than my previous method (from 60 fps down to 40 fps for just drawing terrain!) I later found out it was because the texture coordinates weren’t between 0 and 1 and it had to wrap. I divided the coordinates by 10 (so 4, 4 was 0.4, 0.4) and my game ran fast (110 fps, Wow!) even though the textures looked all messed up. So this huge change of frame rates started to get me thinking about the fastest possible brute force method for rendering terrain. (Any suggestions?) Here is my structure for a 4x4 chunk of terrain: struct TERRAIN_4X4 { bool Tile_AllSameBasicTextures, Tile_NoTransitionTiles; unsigned char Tile_BasicTexture[16], Tile_TransitionTexture[16], Tile_Transition_Overlay[16]; D3DVECTOR Tile_TopLeft[25], Tile_Normal[25]; }; I know that my vertices overlap (I don’t like this.) What I want is to have a vertex map and normal map like this: D3DVECTOR Terrain_Vertices[128*128], Terrain_Normals[128*128]; and use the information of the TERRAIN_4x4 chunk for the textures and overlaying the transition tile alpha maps. I am thinking about using strided vertices and vertex buffers. The thing that is really confusing me is assigning texture coordinates to each vertex. If polygons share information on the vertices (position, normal, texture coordinates, etc.) how do I say to use different texture coordinates for the polygon rendered, like this: ------------------------------------------------- | 0,0 1,0 /| 0,0 1,0 /| | / | / | | / | / | | / 1,0 | / 1,0 | | / | / | | / | / | | / | / | | / | / | | / | / | |0,1 / |0,1 / | | / | / | |/ 0,1 1,1 |/ 0,1 | ------------------------------------------------- | 0,0 1,0 /| 0,0 1,0 /| | / | / | | / | / | | / 1,0 | / 1,0 | | / | / | | / | / | | / | / | | / | / | | / | / | |0,1 / |0,1 / | | / | / | |/ 0,1 1,1 |/ 0,1 | ------------------------------------------------- (2x2 chunk for example) See the center. It has four texture coordinates which is my problem. I like the speed of the draw index primitive but I don’t like the fact that the texture coordinates are for each vertex. I need some help with making my terrain render faster. Any suggestions would be helpful. Thanks.

This topic is closed to new replies.

Advertisement