Texture Splatting Revised



This is my second try of doing texture splatting. There's more layer types, like a fog layer for shader fog, and light layer for lightmapping. The black borders bug reported by HamsterOfDeath was fixed, btw.
Check the test class on usage info (TestSplatPage).
Download now - jME1 version (.zip)
Download now - jME2 version (.zip)

UPDATE 1.1:
Removed bad test, integrated TerrainPass, and added a test that uses TerrainPass.
Also fixed some issues with layer blending.

UPDATE 1.2:
Removed debug messages, fixed issue with light layers throwing errors.

UPDATE 1.3:
It is now possible to specify separate detail scale values for AlphaDetailLayers.

UPDATE 1.4:
Various minor changes, ported to jME2.

Made an update, download from the same link.

Amazing, thank you very much for sharing that!

I am right now replacing my old TextureSplattedNode system with this, seems to be really easy to do.

Nice fps - had to comment put SceneGraphDump ???




Screenshot ? :smiley: (I know, I'm lazy…)



Edit:  thanks  :slight_smile:

there is a class missing.

return Arrays.copyOfRange(tex,1,last); doesn't compile, copyOfRange isn't found

Maybe it is a Java 1.6 feature?

yes it is  :lol:



here’s a comparison between splatted textures:



and my old rendering:





i accidently used an old version of the terrainpass in my first try of screenshotting it. image has been replaced.



currenty i can’t run the new terrainpass because

at com.gibbon.mfkarpg.terrain.splatting.SplatEnv.createGLSLShader(SplatEnv.java:325)

at com.gibbon.mfkarpg.terrain.splatting.TerrainPass.generate(TerrainPass.java:167)

at com.gibbon.mfkarpg.terrain.splatting.TerrainPass.doRender(TerrainPass.java:235)

at com.jme.renderer.pass.Pass.renderPass(Pass.java:90)

at com.jme.renderer.pass.BasicPassManager.renderPasses(BasicPassManager.java:89)

Looks a lot better now :), especially on close terrain. The water refrect/reflect thing can be fixed by using PassNode and sending that as the reflected scene to water render pass. Not sure about the milk-like white mysterious whitish though, might want to get a closer screenshot of that.

Update coming soon to fix the SceneGraphDump and copyOfRange. Also screenshot added to first post.

urrenty i can't run the new terrainpass because
at com.gibbon.mfkarpg.terrain.splatting.SplatEnv.createGLSLShader(SplatEnv.java:325)
  at com.gibbon.mfkarpg.terrain.splatting.TerrainPass.generate(TerrainPass.java:167)
  at com.gibbon.mfkarpg.terrain.splatting.TerrainPass.doRender(TerrainPass.java:235)
  at com.jme.renderer.pass.Pass.renderPass(Pass.java:90)
  at com.jme.renderer.pass.BasicPassManager.renderPasses(BasicPassManager.java:89)

What's the error?
Looking at those lines in my IDE, they seem to point to completely different functions.
Maybe try downloading from the link again?

didn't call addDetail(tex, null);

only spedified die actual detail-maps, but no basetex.

next problem: looks like r_fullbright 1. lighting isn't applied anymore. what to do?

You need to add a LightLayer, call the constructor without any arguments and make sure it's the first layer in the SplatEnv.

i don't have a lightlayer  :smiley:

i'm screwed, aren't i  XD

or should i add an empty lightlayer? there is no method taking one.



i'd also like to use one scaling value per detail layer so i can add my precious random noise greyscale layer - without it, the whole ground looks like a simple tiled texture (which it is). is this possible?

You need to add a LightLayer, call the constructor without any arguments and make sure it's the first layer in the SplatEnv.

->
java.lang.UnsupportedOperationException: LightLayer must be the last layer in the SplatEnv


calling this:

tPass.setRenderMode(TerrainPass.MODE_FRAG_PROGRAM);



fixed it.

Momoko_Fan, I have updated my ORPG project to use your splatting, and it works nice. Thanks again! Could you check if you can get some better framerates on your card now?

HamsterofDeath: If you're using TerrainPass then you only need to call TerrainPass.setDynamicLighting(1.0f);

i'd also like to use one scaling value per detail layer so i can add my precious random noise greyscale layer - without it, the whole ground looks like a simple tiled texture (which it is). is this possible?

Yes it's possible, I'll do it, but not today (I already released two updates..)


hevee:
I tried your RPG before without GLSL on (white terrain) and didn't have much speed improvement, I think there's a bottleneck somewhere else and it is hiding any fps improvements; for example, that llama terrain system is a bit suspicious. Also I checked in the game directories and found that you're using a huge amount of 128x128 alpha textures, I find it pointless since alpha maps don't need that kind of detail, in my experiments I found that bilinear filter suffices and you can get nice blends even with extremely low resolution alphamaps.

UPDATE 1.2: Okay, I was able to fix hamster's issues with some hacking.. The best and most reliable way to do splatting is through TerrainPass. Using SplatEnv and layers is not recommended since there's lots of video card support dependency.
Also updated page on wiki.

after some texture tweaking, everything looks good. i'll add a lightmap & a random noise greyscale map later and then post some screenshots.



edit:

one thing still not working:

 if (Main.isParameterGiven(Main.Parameter.HQ_DETAIL_EXT)) {
        final PassNode l_passNode = new PassNode("TerrainPass");
        l_passNode.attachChild(l_terrainBlock);
        m_core.getReflectNode().attachChild(l_passNode);
      } else {
        m_core.getReflectNode().attachChild(l_terrainBlock);
      }



in splatting-mode, the terrainblock isn't reflected at all - it's simply ignored. i search the forum for "passnode" but only found this thread. what's the problem here?
Momoko_Fan said:

hevee:
I tried your RPG before without GLSL on (white terrain) and didn't have much speed improvement, I think there's a bottleneck somewhere else and it is hiding any fps improvements; for example, that llama terrain system is a bit suspicious.


Is there anything in particular you found with the llama terrain or is it a hunch. One thing for sure is that the terrain in the far distance does not need so many passes, but this is just an implementation of the terrain system, not the system itself.

theprism: Nothing specific. I suggest hevee to profile his game and optimize unusually slow code. I am suspicious of the terrain system since it's role is quite big in terms of scene management and rendering.



Hamster: I had this issue before with the water and MrCoder pointed out that PassNode could help. Other people said that PassNode fixed it. Perhaps there were changes to PassNode or the new TerrainPass causes problems.

Nice work Momoko, just want to hear, are there any speed improvements compared to the splatting in cvs? That's what I'm playing with right now, and it starts to slow down when adding a lot of splats(+6), does your version widen this bottleneck?



btw, how do you guy's make you prebaked shadow maps? (sorry if that's a dumb question ://)

any release plan yet for the "scale per layer" and "more than one lightmap"-features?