Shutting off bounding tests

Hi, i’m working on an Alpha Centauri clone and work goes on quite well.

I already implemented a tiled terrain that allows me to have texture splatting, detail textures and on top of it, a decal layer for every tile and a grid as an overlay. Everything works as you can see in the picture:

You can see the green grid overlay and the decals, which is a road for now  :D

My problem is: the rendering is inefficient… My terrain consists of multiple TerrainBlocks, i.e. for a 64x64 grid I have 4096 small TerrainBlocks with own vertex buffers, index buffers and so on and furthermore there is a bounding check for every block, of which I think is the real bottleneck here.

I want to keep it in this structure, because it allows for very easy picking and handling of decal and grid texturing.

Now my question is: How can I force the terrain node to draw itself and its 4096 children blocks without doing bounding checks? The GPU is idle all the time…

I’ve tried many different approaches concerning TerrainPages and their QuadTrees but the results always led me back to this implementation which seems to me to be the best. AFAIK the Cullstate is used for frustum culling backface culling so this is not what I need.

Any Ideas? Thanks  :)


I now found out that there exists this nice method called lock(). And by that, making displaylists is probably the most useful thing here. But the problem with locking is, that all texture coordinates are screwed…

I now switched back again to TerrainPages to try it quick and dirty. But look at the pictures when setting lock() on or off:


activating grid overlay:

And now when lock() turned off(of course the terrain looks now different because i rerun terrain generation)

and with grid

So somehow the texturecoordinates are set to 0 or something when locking. This can be seen expecially on picture 2.

Another thing: now I remember why i switched from TerrainPage to DIY. If you look at the first picture in the bottom left corner you see that TerrainPage always drags one edge of the Page down…Why?

You should try lockBounds() because lock() locks everything  :slight_smile:


thx for the post. Yes, I tried all available locks and lockMeshes() is the one that makes the textures go monkey.

In the API it says that lockMeshes() tells jME to assume that no further changes will be made to vertices, indices, texcoords etc. So far, so good. The point is: I don't change them anymore! I set them all up and lock the terrain afterwards! Theoretically, they stay the same after and before i lock them. But something goes wrong… Has this something to do with multipass rendering? Though I doubt that. Or is it possible to blend my 4 textures in one pass?

Hmmm, that’s not good  :’(

Maybe a dev is going to look into this thread…

But another question I already raised:

I have 4 textures:

  1. produced by ProceduralGenerator
  2. a detail map (jpg)
  3. my decal texture (png with alpha channel)
  4. my grid texture (png with alpha channel)

    And I render in 3 passes:

    1:  Tex1 and Tex2 are rendered in one texture state

    2:  My decal with enabled blending mode

    3:  My grid with enabled blending mode (optional)

    Can I create all 4 textures in such a way that one pass will blend them together nicely?

    The point is that I render the terrain 3 times to accomplish this which is not helpful with my performance problem  :-o

LoL, looks like I’m spamming my own thread, but here are the news:

As I said earlier, I used multiple passes (3 to be precise) to render my terrain and therefore utilized the PassManager.

Now I use the normal scene graph way, i.e. renderer.draw(terrain) and it works while having a locked terrain.

So lock() DOES interfere with MultiPassRendering of TerrainPage. Don’t know whether this makes sense or not but I need to live with that.

That means: I really have to find a way to blend these 4 textures inside one pass using 4 texture units…

Any tips?

Edit: I included two pictures to illustrate my problem:

If I just use the first two textures, my terrain looks like the following:

But when I add my decal texture with alpha channel, this is the result:

It seems that the alpha-channel decides whether to draw the pixel or not, and if yes, then draw it combined with the textures beneath. But I need: Draw beneath textures always and the current pixel only if alpha allows!

How do I do that? I tried so many combinations of the blendstate that I’m going nuts…

After a lot of reading through the web I finally came to the conclusion that BlendState is not what I want. BlendStates are used for determining how a pixel is to draw when the framebuffer is filled at that position already with another pixel. That means if I render the terrain in multiple passes, which I now do not.

I need to set the right combine properties for the textures if I want multitexturing in one single pass. This, or I switch to shaders… But due to the lack of documentation for using it inside jME I shall stick to the fixed-function-pipeline.

 t0.setApply(Texture.ApplyMode.Combine); // procedural texture
 t1.setApply(Texture.ApplyMode.Combine); // detail texture
 t2.setApply(Texture.ApplyMode.Combine); // decal texture

This gives funny results if I play with the setting but I am really lost here. I'm sure there is someone who can help me set these combiner properties right, isn't there?

I appreciate any help I can get!