Hardware Terrain Splatting

Original jME low-res software splatting with detail texture





Similar configuration: Hardware splatting with trilinear filtering & 2 pass rendering





info, screenshot & download

Cool, looks useful, thanks.

adding to own terrain rendering asap



where is the lighmap generator? i want to use it

Nice! Have you seen my own, similar attempt? http://www.jmonkeyengine.com/jmeforum/index.php?topic=4146.0

I like the fact that your's is applied as a render pass a bit better, though, but won't be able to switch over soon because I currently have my alpha maps in greyscale, not alpha channels. Plus I need an option to update alpha maps (splat painting), but that should be trivial to add.

GLSL doesn't work for me, while it does well in my own version. I'll try to look into that later, and provide a fix if possible.

Nice! Have you seen my own, similar attempt?

Yes, I have seen it, but it uses GLSL only, which means that it doesn't support fixed-pipeline effects (like fog), it is a lot slower than regular rendering, and can only handle as many textures as the card supports, those kind of limitations are not acceptable (at least for me).
I have implemented GLSL in my system, thinking that it would improve performance if many tiles are used (less passes), but it seems like I was wrong, fixed-pipeline is the way to go here.
but won't be able to switch over soon because I currently have my alpha maps in greyscale, not alpha channels.

With this system, you can try uploading your grayscale textures as ALPHA8 and then it would work. To update the splat textures, you could add an refresh method to the pass which would delete the alphamaps from the TextureStates.
where is the lighmap generator? i want to use it

I am not going to release it, yet. It is unfinished. I can say however, that using a pregenerated alphamap can triple the rendering speed of terrain.

My card is Geforce FX 5200, which is (to my knowledge) the first consumer card to support programmable shaders, I guess that it was not yet fully optimized for programming.

Hm, in that case, it would be best to ask the user if to use shaders or not. If many tiles are used, then it would be definetly better to use shaders to have less passes and thus increase performance.

Great, I'll definitely try that!

Just letting you know, ALPHA8 is missing from jME as of right now. You need to add it by yourself to the Image and LWJGLTextureState classes.

i tried using the renderpass for my terrain, but it looks rather crappy. like on the second screenshot, instead of texture 1 <-> texture 2, it renders texture 1 <-> white <-> texture 2. i thought this was intended, but i guess it's a "hole" (sum of all alpha values at a point is not 1) in the alpha maps. after they have been generated, you should check for values < 1 and add the apropriate values to the alpha maps.

also, the terrain started to look too regular and boring because my greyscale-detailtextures are now missing (i used 3 at different scalings which made the terrain look non-regular).

All the problems you mentioned have nothing to do with the library.

ike on the second screenshot, instead of texture 1 <-> texture 2, it renders texture 1 <-> white <-> texture 2.

The white in the 2nd screenshot is the highest.jpg texture, which is completely white (to represent snow I guess)
i guess it's a "hole" (sum of all alpha values at a point is not 1) in the alpha maps. after they have been generated, you should check for values < 1 and add the apropriate values to the alpha maps.

You need to input the correct values for the alphamap generator, so that no height ranges intersect too much.

I guess it is possible to normalize the alphamaps to get correct results, but that is not the purpose of this system.

what are the "correct" values? to get a constant opaque terrain?

another idea: could i render my own old terrain above yours using dst alpha as the blending function (or below -> render it first) to fill the holes?

this way i'd use your method to add high detal textures for things like roads or high slopes and use my own rendering for the usual parts

what are the "correct" values? to get a constant opaque terrain?

The sum alpha for all alphamaps at any given point must be 1.0
another idea: could i render my own old terrain above yours using dst alpha as the blending function (or below -> render it first) to fill the holes?
this way i'd use your method to add high detal textures for things like roads or high slopes and use my own rendering for the usual parts

Sure, do whatever you want.
The sum alpha for all alphamaps at any given point must be 1.0


i know. but which min/center/max-values should i use to make sure the sum is one?
these do not work with your method, but give perfect results with the jme's texturegenerator:

texture1.url=visual/landscape/grass_ground2.jpg
texture1.from=0
texture1.fullat=0
texture1.to=60

texture2.url=visual/landscape/moss11.jpg
texture2.from=0
texture2.fullat=60
texture2.to=120

texture3.url=visual/landscape/pebbles9.jpg
texture3.from=60
texture3.fullat=120
texture3.to=180

texture4.url=visual/landscape/rock_moss.jpg
texture4.from=120
texture4.fullat=180
texture4.to=240

texture5.url=visual/landscape/SnowTexture.jpg
texture5.from=180
texture5.fullat=255
texture5.to=255



for comparison:
new: http://img337.imageshack.us/my.php?image=fanrenderingls7.jpg
old: http://img356.imageshack.us/my.php?image=jmerenderingvq7.jpg

To be honest, I don't really know. The height-based alphamap generator was made only so that no external alphamaps are used in the test. I am using pregenrated alphamaps and so I don't have any of those problems.

Very cool!  I can't wait to check out the source and try it out!

seems like i'll have to make my own. SO BE IT!

seems like i'll have to make my own. SO BE IT!

I don't see a reason for that. The test uses the procedural alpha generator and it works fine, the system does what's it suppose to do perfectly. The problem is clearly on your side.
EDIT: By the way, I did not use a license for this code. You could import it into jME's CVS if you want.

I added this code to the wiki under "Code snippets", hopefully it is now more accessible.







It is kind of strange that people don't post here, I knew this was often requested but I wasn't sure, so I did a search…

http://www.jmonkeyengine.com/jmeforum/index.php?topic=615.0

http://www.jmonkeyengine.com/jmeforum/index.php?topic=1893.0

http://www.jmonkeyengine.com/jmeforum/index.php?topic=2634.0

http://www.jmonkeyengine.com/jmeforum/index.php?topic=2857.30

http://www.jmonkeyengine.com/jmeforum/index.php?topic=3206.0

http://www.jmonkeyengine.com/jmeforum/index.php?topic=3402.0

http://www.jmonkeyengine.com/jmeforum/index.php?topic=3422.0

http://www.jmonkeyengine.com/jmeforum/index.php?topic=3692.0

http://www.jmonkeyengine.com/jmeforum/index.php?topic=3699.0

http://www.jmonkeyengine.com/jmeforum/index.php?topic=4530.0

http://www.jmonkeyengine.com/jmeforum/index.php?topic=5502.0

http://www.jmonkeyengine.com/jmeforum/index.php?topic=5302.0



Now those people have hope… :stuck_out_tongue:

It seems to me that implementing render passes is best done through the scene graph architecture, by extending SceneElement, which also provides bound checking and locking capabilities. It also allows the pass to be used within other passes such as the water render pass.

I might try to reimplement this system as a SceneElement at some point.

Have you looked at PassNode and TestPassNode?

Very useful, and saves me work. Thanks.

i don't quite understand how a renderpass works, so i have no ida how to do this:

  1. render my terrain the old fashioned way
  2. use momokos pass to add more detail at some spots
  3. render another greyscale-texture on top off all this (lightmap/noisemap)



    1+3 are being done now using detail textures of different scalings, but when i use the momoko-pass, my terrain is not visible - everything is white.