Game Development Community

Terrain constants

by Stephen Lujan · in Torque Game Engine · 04/11/2007 (12:40 pm) · 3 replies

I've been playing with the terrain constants in engine\terrain\terrRender.h

I changed this
enum TerrConstants {
   MaxClipPlanes = 8, ///< left, right, top, bottom - don't need far tho...
   MaxTerrainMaterials = 256,

   EdgeStackSize = 1024, ///< value for water/terrain edge stack size.
   MaxWaves = 8,
   MaxDetailLevel = 9,
   MaxMipLevel = 8,
   MaxTerrainLights = 64,
   MaxVisibleLights = 31,
   ClipPlaneMask = (1 << MaxClipPlanes) - 1,
   FarSphereMask = 0x80000000,
   FogPlaneBoxMask = 0x40000000,
   VertexBufferSize = 65 * 65 + 1000,
   AllocatedTextureCount = 16 + 64 + 256 + 1024 + 4096, 
   TerrainTextureMipLevel = 7,
   TerrainTextureSize = 1 << TerrainTextureMipLevel, 
   SmallMipLevel = 6
};
to this
enum TerrConstants {
   MaxClipPlanes = 8, ///< left, right, top, bottom - don't need far tho...
   MaxTerrainMaterials = 256,

   EdgeStackSize = 1024, ///< value for water/terrain edge stack size.
   MaxWaves = 8,
   MaxDetailLevel = 9,
   MaxMipLevel = 8,
   MaxTerrainLights = 64,
   MaxVisibleLights = 31,
   ClipPlaneMask = (1 << MaxClipPlanes) - 1,
   FarSphereMask = 0x80000000,
   FogPlaneBoxMask = 0x40000000,
   VertexBufferSize = 65 * 65 + 1000,
   AllocatedTextureCount = 16 + 64 + 256 + 1024 + 4096, //default ends at 4096

   TerrainTextureMipLevel = [b]8[/b],//was 7 ///< mip level of generated textures
   TerrainTextureSize = 1 << TerrainTextureMipLevel, //was 1 ///< size of generated textures
   SmallMipLevel = [b]7[/b] //was 6
};

I thought changing the mip level would make the mipmaps load over a smaller area. Actually I was right, but all kinds of artifacts appeared. Does anyone know anything about the terrain renderer or the constants? I'm just trying to get the texture to repeat over a smaller area so the detail is increased up close. Does anyone know how to do that, or how to eliminate these artifacts?

#1
04/11/2007 (4:43 pm)
I just did some work to convert some legacy terrain to a 512 height map. It took more effort than just changing a const. There are various interdependencies between consts and hard coded values which break things. All i can say is prepare to do alot of debugging... few people really understand the legacy terrain system and how it all works.

By the way this would be a great project for someone to take on... document the consts in TerrRender.h and TerrData.h.
#2
04/14/2007 (3:19 pm)
That's good to know, but I was hoping what I'm attempting is a lot less difficult. I didn't want to change the size of the height map, which I've read about others struggling with. I just wanted to fit more mipmaps of the terrain texture into the same area, which I thought to have far fewer interdependencies. By default it seems that each mipmap covers an 8x8 area of the heightmap. I would like to render the texture over smaller areas than that. I thought I could do that by changing those two constants I bolded above, which both the terrain renderer and the texture blender rely on. I read through the terrain renderer code and it seems like it should work but this is what it looks like in the game.
i9.photobucket.com/albums/a89/AnimateDream/links/screenshot_005-00001.jpgThere's these weird striping patterns in the texture as though things are overlapping that shouldn't, and I have no idea where the random white is coming from. I'll let you know if i have any breakthroughs.
#3
04/19/2007 (6:44 pm)
Stephen, if I remember correctly, similar to this I had when I tried to use non 256x256 bitmaps for painting terrain..
(I was working with water code actually, but ended up in terrain code :) but that was about half a year ago)

Try to replace the bitmap used for painting the terrain with something like 128x128 or 512x512.