Procedural terrain

oupss… I changed only the shaders in the material… I’ll take a look at what’s wrong… :confused:

okay… I set the shader in the j3md to be GLSL130… Changed that to 100 and it still works, so now it should be okay…

Okay, I dont get any errors now but just a plain white, unshaded terrain.

that’s strange… Is there a way to force my graphics card to use only opengl 2? :confused:

I might be a difference in your video cards too.

What card do you have anthyon?

Mine is an ATI Mobility Radeon 3400 in an asus notebook…

I’m sorry but this looks awesome, and I would love to give it a try.



Where can I find the libraries and a working exemple ?



Thank you :slight_smile:

ozonegrif said:
I'm sorry but this looks awesome, and I would love to give it a try.

Where can I find the libraries and a working exemple ?

Thank you :)

Its all in the latest nightly, update the SDK to latest nightly and create a new tests project.

Hi



All you need is contained in the svn. The base class to use is TerrainGrid instead of TerrainQuad, and there’s a working testcase called TerrainGridTest int the test packages, that uses a FractalHeightMapGrid which calculates heightmap on the fly whereever you go :slight_smile:

Ooooohh pretty ! Thank you all ^.^ (special thanks to anthyon)

Superb work, really. Just a little question.



in FractalHeightMapGrid :

[java]heightmap.setHeightScale(256);[/java]

should be ?

[java]heightmap.setHeightScale(heightScale);[/java]



and in TerrainGridTest :

[java] this.terrain = new TerrainGrid("terrain", 65, 257, new FractalHeightMapGrid(ground, null, 256f));[/java]

should be ?

[java] this.terrain = new TerrainGrid("terrain", 65, 257, new FractalHeightMapGrid(ground, null, 255f));[/java]

with the first, you’re right, I’ll make a commit ASAP. In the constructor you can give any float number to be the maximum height. The noise basis generates values in the [0…1] interval, and it can be scaled to any height you need :slight_smile: Eg. given that using physics means that 1 unit is 1 meter, heightscale of 256 means only 256 meters hill. :slight_smile: 255 is used when the TerrainQuad uses heightmap images of ARGB types (value range: 0…255). I prefer 16 bit grayscales instead (value range: 0…65536), it gives a smoother terrain.

Understood ^.^

I will continue to hunt bugs (I found 3 in two days) :stuck_out_tongue:

1 Like
ozonegrif said:
Understood ^.^
I will continue to hunt bugs (I found 3 in two days) :P

Lets hire this man!
We need more bug hunters :)
1 Like

In TerrainGrid :

[java] this.setLocalTranslation(cam.mult(2 * this.quadSize));[/java]

There’s a problem with this line. It works fine if you scale the Terrain by 2 (like you do in the exemple).

But if I change the scale :

[java] terrain.setLocalScale(4f, 1f, 4f);[/java]

It doesn’t work anymore.

It’s an easy fix if x and z scales are identical. But what about rectangular Terrains ?


Lets hire this man!

Well thank you. I doubt I know enough about graphic engines yet, maybe later.
I can still reports the bugs on the forums ; your team is very quick to answer ^.^

Well TerrainQuad uses square terrain especially with sizes 2^n+1. You’re right, that with scaling you can make rectangular terrains, but, what’s the use, when you have “infinite” terrain with grid? I need to mult with localScaling, that will solve both problems, and fix it right now, but I still doubt the usefullness of rectangular quads :slight_smile:



Edit: commit is done and solved both of your problems :slight_smile:

I agree, with Terrain grid you do not need rectangular terrain quads.

It was just a newb question. :slight_smile:

anthyon’s fix is universal anyway. He multiplies the localScale instead of a constant ; nifty.

Today I had the time to take a look at the TerrainGrid, it looks great, and even works nearly fluent when generating new parts on the fly :slight_smile:



But I’m more interestend, what exactly do I have to do, when I want to implement a different system to load maps (basically I have a few dozen heighmaps that fit seamless, and from them I want to get my data. I tried to understand the code fo the TerrainGrid but I’m not complelty sure where I has to do what I need.



I think I need to make a new TerrainGrid that itself gives back the heighmaps of the tiles. So I need heighmaps for the tiles to am I right?

Also does the TerrainGrid handle the loading in background(and more impoartantly do i have to make thing threadsafe?)

@EmpirePhoenix: Depending on how you store your heightmaps, the actual implementation may differ, but the logic is the following:

  1. the TerrainGrid constructor gets a HeightMapGrid instance (FractalHeightmapGrid in the test, but I have done an ImageBasedHeightMapGrid as well in the same package)
  2. every time the terrain needs to be changed, the getHeightMapAt(Vector3f) method gets called on this object. The vector it gets contains the camera’s current cell index (1 cell => 1 tile), which should be enough information to load the tile needed. ImageBasedHeightMap tries to load it from the classpath (I’m using 16bit grayscale images, see above posts), and FractalHeightMapGrid simply calculates the new tiles on the fly.
  3. there is a threadsafe cache algorithm based on LRU cache implementation, that loads tiles on demand (4x4 tiles)
  4. the terraingrid uses 4 tiles at one time, representing the four subquads. that means that for a grid of size 512x512 you’ll need to have tiles of size 256x256.

    I hope it was clear. The tutorial will be done soon I promise :smiley: