Large terrain file

I just recently created a map using L3DT and was hoping to use it in a game I was making with Panda3D. I imported it into blender as .obj and tried exporting it as .egg using the yabee addon. However blender would just freeze and stop responding :cry: I left it for about 2 hours but nothing had changed.

My map has 605k faces. I wasn’t sure whether this was too large or something :confused:

What can I do about this? I can export it as .x but converting using x2egg gives me a memory error. Would it be better just to use the .x file?

605k faces must be around 1GB file size…that can’t be good. You can:
-reduce the face count (I think it’s called decimate in Blender)
-re-export it from lt3d with fewer faces
-export it as a hightmap and use pandas geo-mipmap-terrain
-export it as a hightmap and use it in blender to make a mesh
-split the mesh into smaller tiles
-get more RAM and a 64bit os, maybe more memory will handle a mesh that big?

Thanks for the help, I’m thinking splitting into tiles might be the best way. I have just tried reducing the number of facing by exporting it from L3DT but the lowest I can get it without looking blurry is 82k. Is that an ok size? (The first time I tried exporting it with less faces, I did it in the opposite direction and it attempting to make an .obj file with 2 million faces :smiley: but my computer went a bit funny)

If I was to split it into tiles, do you know how I would go about doing this?

82k is still on the fat side, but it should not make the computer hang.
For spliting it into tiles you could use one of the octree scripts that are here somewhere on the forum. It would cut the mesh into 4 pieces (if it’s flattish, could be 8 if it has a lot of height) and then each piece into 4 (8) more and then maybe do the same again. You’ll end up with 16- 64 (512?) tiles that are easy for Panda3D to cull (hide if not in the cameras view).
You could also manualy detach a few polygons in Blender and make them into a new mesh.
If you’re up to it, you could load and unload tiles yourself in code, but don’t ask me how.

I’d still suggest to export the heightmap from l3dt and apply it to a 100x100 plane in Blender (as a displace map?). Then you can subdivide selected faces to make it more smooth.

That sounds good, I’ll try that. Thanks for the help :smiley:


Do you need to load the terrain as an egg file for some reason ? I use L3DT too to generate 1024X1024 terrains and load the .png file directly into Panda GeoMipTerrain and use its LOD features with no problem. It loads fast and I get good frame rates.

I’ve just looked into doing that way but the framerates aren’t too good so far :confused: It tends to lag when I am looking at too much. This is with only a few lines of code so I’m sure there are many things that could speed it up.

I’m also finding it hard to apply a texture :frowning: Do you know how I would do this? I’m thinking of using this way but I need to read a bit more into the documentation first.

I’m doing the same thing, the only way I’ve found to get geomipterrain running smoothly is to use bruteforce, and not to call the update function.

My computer slows down bit with a 1024 heightmap, so I’m using a 513x513 with 1024x1024 texture maps from L3DT. With just the terrain, I’m getting well over the 60fps mark. Thats on a Intel Q6600 / 4GB RAM / Geforce 8800GT.

I’d start off with just applying the texture manually. Something like:

ts = TextureStage("ts0")
terrain.setTexture(ts, loader.loadTexture('diffuse.jpg'))

You could apply a few different textures with a stencil (Which is the attribute map in L3DT). Have a search for ‘texture splatting’

If your feeling more confident, then you’d look into a shader.

Thanks, that is really useful. I’ll give that a go. I probably need to use smaller maps, do you know if I am able to split a L3DT heightfield map into parts? Or would I need to make a new one?

I haven’t tried it, but I think you can do that with the pro version: … ops:mosaic

I only have the standard version :cry: Would it be possible to manually split the image like with a image editor or something?


Yeah, if you call GeoMipTerrain update in a task it can slow things down. The trick is to call it when you really need to. What I do is call it when my camera moves a certain distance. You probably already have a task to handle camera movement when keys are pressed, just put a distance check on current camera pos and previous pos in the camera movement task(s) and when the distance changed is like 64 units, call the update on the terrain and set your prev camera pos to the current. I also do an update when camera has been idle, just to sneak an update if there was movement but not the full distance traversed. doing the update only when you need to (for visual purposes) really speeds up the frame rate, give it a go !

I’ve used L3DT (free version) to create up to 8 texture layers and using shaders. I’ll write up the procedure for making the textures when I get some time.

Thanks, that’s a pretty smart way to go about it :smiley: I’ll give it a go. I’ve just managed to split my 4048x4048 map into parts. Is that a good idea? :confused:


Yeah, I think splitting a 4048x4048 is a good idea. I think that’s the maximum size for free version of L3DT,
or do you have the paid version ? Also I think the free version I couldn’t cut the terrain in L3DT, so I used IrfanView image editor to split both the height map and texture maps ( a bit of work ). My terrain areas are 1025x1025 which gives a good visual distance ahead and gives me good frame rates ( not using bruteforce ).
You’ll need your own Terrain Manager class to handle the split up areas. I manage 3x3 areas in memory and read in new terrain files when within a certain distance from the new area ahead, the 3x3 matrix of GeoMipTerrain is shifted around in such a way to reuse the memory of areas farthest from behind the camera.

So, do you have the paid version of L3DT, and used that to split your height map ? Did you also export all the texture maps too, and are split same as height map, all using L3DT ?

I found a couple documents I made to remind me how to create the split terrain areas (2048x2048 -> 4 X 1025x1025), and how to create the texture layers for using with a terrain shader. If you would like to see it I can put it in the next post, but maybe you have it worked out already…

Are you programming with python ? Problem with me is I program all in C++, so sharing code between us is not as easy, but code basically looks similar, you’ll be doing the same things in python that I do in C++.

Yeah I’m using python and the free version of L3DT :slight_smile: I split my heightfield map using paint.NET but this probably wasn’t the most accurate way of going about it :confused: The area I’m having a bit of trouble in is how to use more than one part of the map. At the moment I just have one quarter and I can move around it but I wasn’t sure how to know when to load in others. I haven’t split the texture map yet (at the moment my terrain is all white) but I’ll probably do that once I have the map working.

I’d be interested to see how you split terrain areas and the stuff about texture layers, I’m a bit stuck :smiley:


One other thing I had a problem with was my texture seems to be a bit inaccurate. I’ve taken the top left corner of my map’s texture and used it as the texure for the top left corner of my heightfield map but there seems to be a few lakes that have a mountain in the middle of them and things like that? Could that be a problem with me using paint.NET to split it? :confused:


Are you still building your terrain with blender ?
The way it puts together the polys my not be the same as with a GeoMipTerrain ( upper left as opposed to lower left corner as the start of rows and cols), that could be your problem. As for what I do using GeoMipTerrain, my height image and texture image(s) look the same, well except for color since height map is gray level and texture maps can be either full color picture of the terrain or several files to do texture splatting layers put into Panda texture stages and using a shader. I don’t need to set any texture coordinates, but here are a few lines of code that I use in specifying a single full color texture image:

  PT(Texture) groundTexture = TexturePool::load_texture(textureFile); 
  tnode.set_texture(groundTexture, 1);

It’s getting late so tomorrow I’ll put together something on how I used L3DT and IrfanView and Gimp, I need to add a little more detail to what I have already so it will be easier for someone else to understand, and it has been a while since I made some terrain and cut it up.

Sorry so late
Things got busy past couple days

Here are some step for cutting height and texture maps using IrfanView

In my case I created a 2048x2048 terrain using L3DT and cut it into four 1025X1025 (you overlap the edge pixels)

Create 2048x2048 terrain in L3DT

Export height and texture maps

Create cut 1025x1025 height and texture maps using IrfanView.

   Use Edit->CreateCustomCropSelection 
     In dialog enter X-Coord, Y-Coord, Width and Height
     example: X,Y ( 0,0 )  wid,hi (1025,1025);  then click “Apply to image”

    Then Edit->CropSelection
    Then File->SaveAs new file name

    Do next areas as above:
    File->ReOpen, and begin steps to crop another
       example: X,Y ( 0,1024 )  wid,hi (1025,1025);  then click “Apply to image”
       then crop and save as before.

       Then cut and save
         X,Y (1024,0 )  wid,hi (1025,1025)
         X,Y (1024,1024 )  wid,hi (1025,1025)

If you want to see how I did texture splatting, I’ll have to add that later; but you use L3DT to write out all the names of the textures used (grass,rock,sand, etc) and produce a couple files that map each type of texture into each color channel. You copy the individual texture images and channel mapping files to where you want them, and cut them up the same way.
In Panda you have to add them in as different “stages” and set a shader to do the “splatting” of them together.

Thanks that’s a great help :smiley: I’ll give it a go now.

I’ve got the textures under control now :smiley: However I’m having a bit of a problem with when to update the terrain. My code looks like this:

def updateTask(task):
    return task.cont
taskMgr.add(updateTask, "update")

How could I change that so it only updates after a certain distance? :confused: