Splatting in JME2 ( jglest )

I'm currently trying to reimplement the game glest using jme.

I can load models and the terrain now, but I still have problems with the terrain textures. I'm a noob for all this so please be gentle :slight_smile: .



Glest uses several tiling texturesets to texture its terrain. To do this with jme what do I have to do?


  1. Whats the general way of texturing a terrain? Is this a huge precalculated texture which is set as texture for the terrain or is it done a different way?
  2. I already read something about "splatting". Is this the right keyword for me to read on?



    Please give me some hints ( even some keywords help me very much ! )

Probably splatting is the right keyword for you. Its a way to have several different types of tiled textures for the terrain and then tell the OpenGL renderer what texture to display/mix in where by alpha maps. Theres examples for this in the JME2 source.

I still don't know what to do…



here is mentioned a zip file to download but the link is dead. Anyone still has it?

http://www.jmonkeyengine.com/wiki/doku.php/hardware_texture_splatting





And once more my general question:

Is the terrain texture usually ONE huge precalculated picture? Or is there any trick to get smooth borders when the ground type changes?

ok, I think I found something now.



TestTerrainSplatting.java  â€¦

there is a way to do splatting with PassNodes and PassNodeStates…

look at TestIsland source code in the jmetest.terrain package…

Thanks for all the replies!



Its done now i can load the textured terrain now. I was able to calculate the alphamap on the fly and now it looks good :).

Nice one! Well done.

Thanks! And now , even better with trees and so on ( but still a long long way to go …)



Very nice, glad it worked out!

Very nice work man. I love what a couple trees can do to a piece of land :slight_smile:

Yeah,…good job! I would be interested how you did create the alphamaps on the fly (from the glest-maps). It would be great if you could provide a code-snippet.



Keep on rocking

This is something differrent but I like it and its used to smooth the terrain. I found this idea in the original glest code. It might be a common way but for me it was new simple and cool.


  
public float[] smoothHeight(float[] terrainHeight,int w, int h)
   {
      
      float[] newTerrainHeight=Arrays.copyOf(getTerrainHeight(),terrainHeight.length);
      for(int y=0;y<h;y++)
      {
         for(int x=0;x<w;x++)
         {
            float newheight=0.0f;
            for(int l=-1;l<2;l++)
            {
               for(int k=-1;k<2;k++)
               {
                  int pos=(y+l)*w+(x+k);
                  if((pos>0)&& pos<terrainHeight.length)
                  {
                     newheight+=terrainHeight[pos];
                  }
                  else
                  {
                     newheight+=terrainHeight[y*w+x];
                  }
               }
            }
            newheight=newheight/9;
            newTerrainHeight[y*w+x]=newheight;
         }
      }
      return newTerrainHeight;
   }

Hey, thx for the snippets! This procedural alphamaps are really a good job.



Keep on rocking, ToM