Avoid popup effect of terrain tiles

Hey guys, :slight_smile:

I’m trying to write a terrain class for my game by using TerraMonkey - But there’s a “popup effect” on the terrain while moving the camera (=> not every tile in the view is rendered).

Do you know how I can avoid this effect?

http://img6.imagebanana.com/img/m7bpc1n4/terrain.jpg



I tried to reduce the patch size from 65 to 9 or less, but I’m sure there’ll be performance problems when using bigger terrains and that this wouldn’t a nice solution. (EDIT: Instead of the code in the jMETests, I’ve disabled the flyCam)

(Frustum far is also set to 999999, but the popup still remains :S)



Here’s the according part of my terrain class:

[java]

public Terrain(){

createHeightMap();

createMaterial();

terrain = new TerrainQuad(“terrain”, 65, 513, heightmap.getHeightMap());

terrain.setMaterial(material);

terrain.setModelBound(new BoundingBox());

terrain.setLocalScale(2f, 1f, 2f);

//addLODControl();

attachChild(terrain);

}

protected AbstractHeightMap heightmap;

protected Material material;

protected TerrainQuad terrain;



protected void createHeightMap(){

Texture heightMapImage = MaterialFactory.getAssetManager().loadTexture(“Textures/terrain/heightmaps/mountains512.png”);

heightmap = new ImageBasedHeightMap(heightMapImage.getImage(), 0.6f);

heightmap.load();

}



protected void createMaterial(){

material = new Material(MaterialFactory.getAssetManager(), “Common/MatDefs/Terrain/Terrain.j3md”);

material.setTexture(“Alpha”, MaterialFactory.getAssetManager().loadTexture(“Textures/terrain/alphamap.png”));

Texture grass = MaterialFactory.getAssetManager().loadTexture(“Textures/terrain/grass_1.jpg”);

grass.setWrap(WrapMode.Repeat);

material.setTexture(“Tex1”, grass);

material.setFloat(“Tex1Scale”, 64f);

Texture dirt = MaterialFactory.getAssetManager().loadTexture(“Textures/terrain/dirt.jpg”);

dirt.setWrap(WrapMode.Repeat);

material.setTexture(“Tex2”, dirt);

material.setFloat(“Tex2Scale”, 32f);

Texture rock = MaterialFactory.getAssetManager().loadTexture(“Textures/terrain/road.jpg”);

rock.setWrap(WrapMode.Repeat);

material.setTexture(“Tex3”, rock);

material.setFloat(“Tex3Scale”, 128f);

}

[/java]



I already searched on the forums and Google, but found nothing similar.



Yours,

destro :slight_smile:

Have you tried putting a walking character in the terrain (or just moving around at low altitude/more slowly)? Do you still get the same problem?

Doesn’t help, too. :frowning: New tiles appear still too late so that there’s the described popup effect.

Your tiles span too few of an area. It IS possible to make non-popping terrain with the current terraingrid.

Hm, even larger patch sizes like 129 or 257 don’t help. :frowning: (This is what you meant with “the tiles span too few of the area”, or? ← too small tile sizes)

Maybe my fault is somewhere in the camera settings, because I noticed the following:

If I set the tile size to 257, all of the terrain is invisible - When I zoom out a while, it appears. So maybe it’s a problem with the automatic culling or so?



EDIT: The only things, that I changed in the camera things was disabling the flyCam and setting the frustum far to 999999.




Alright, I found the line that caused the error:

[java]terrain.setModelBound(new BoundingBox());[/java]



If I comment out this line, everything works perfectly. :slight_smile: Maybe there was a wrong bound calculated or so, I don’t know…

Maybe someone should update the wiki, there it says:

[java]terrain.setModelBound(new BoundingBox());

terrain.updateModelBound();[/java]



I just removed removed the second line because of the hint in the IDE (Manually updating isn’t needed anymore in jME), so this explains why this line is in my code. :smiley:



Thanks for your quick help, :slight_smile:

destro

@destroflyer said:
EDIT: The only things, that I changed in the camera things was disabling the flyCam and setting the frustum far to 999999.

lol why? Normal games have a pretty close far frustum and use things like fog and/or blur to make the disappearing of the objects less apparent. I cannot give you numbers as its all relative. Also the tile resolution doesn't say anything about their game world size. Most terrain tests look at what I'd probably use for a whole city or something, if you drive the resolution up without using that for more actual space it of course won't work. You just need to scale the terrain geometry basically.

The crazy frustum far was for test purposes only (So that I can go sure, that the terrain tiles I don’t see aren’t just culled by the cam).

I already found the solution, I edited it in the upper post. :slight_smile:



Thanks again and good luck with jME. :slight_smile:

Yikes, yea that is some old code. I removed it from the wiki. Thanks for catching it, and sorry for the troubles.

@sploreq



I wonder if you could add a little example with the settings of the terrain so that it appears infinite and you can’t see any popping? I have spent several hours trying to get this but I can’t seem to get it right :frowning:

II did try scaling the terrain really large but then it’s stretched to the point where any painting on it becomes difficult because the tile is way too big for the camera clipping in the editor and the heightmap and textures are so big I get memory issues… Thanks :smiley:

A lot of games use fog/distance haze/etc possibly combined with some horizon stuff in order to mitigate popping.

@monkeychops Really what you are asking for is to view more polygons, but your machine can’t handle them; no real way around that. You will run into memory problems. Most games that have very large terrain also have very undetailed terrain; say one polygon per every 2-4 meters. They fill in the detail with rock and vegetation models near the camera.

As for the camera clipping/movement and scale in the editor, that is something I have to work on. But a fix for that won’t really solve your problem. You will have to pull back on your view range to not see the tiles come into the scene. To not see any tile loading, your frustum far value will have to be half the distance of a grid tile: so if your terrain grid is 2048x2048, each grid tile will then be 1024x1025, and your frustum far value will be 512.

I read somewhere that Just Cause (Avalanche studios) do some clever tricks to make it look like you can see very far. Basically what they do is generate an image of the very far terrain (often manually selected by level designers) for points of interests. Like that city you see in the distance at night - no you don’t, you see a post card of the city lights pasted onto “the sky” :slight_smile: The rest is like zarch says, smoke and mirrors to hide “the popping”.

1 Like