The following tutorial explains how to perform basic texture splatting with height maps.
http://jmonkeyengine.org/wiki/doku.php/jme3:beginner:hello_terrain
I was able to follow this tutorial and exercises with excellent results. However, I am wondering how to add more than three textures. I see in the material parameters of the Terrain.j3md file there are only three texture layers: Tex1, Tex2, Tex3 so I don't believe you can do this using the Terrain.j3md.
It is my assumption that you have to use the TerrainLighting.j3md. However, this is structured very differently with parameters such as NormalMap and DiffuseMap and I cannot find any documentation/tutorials explaining what exactly these are.
More recently, a new material definition for texture splatting has been released, supporting up to 12 textures, with optionally additional glow and specular textures.
The name of the material is TerrainLighting.j3md, and this is a (very nice) example using it.
JME3 is an OpenGL based library using GLSL shaders for rendering. You must write your custom shader, or modify an existing one, to perform custom rendering.
Shaders are an advanced topic. You can find an introduction to shaders on SDK documentation. But probably you would like to read full articles about "Materials, Light, Shadow".
JME3 uses three files to manage them:
.vert
file with the GLSL vertex shader code.frag
file with the GLSL fragment shader code.j3md
file with the shader program definitionBoth vertex and fragment shaders are just piece of code using the GLSL language. Vertex shader is executed once for each vertex in the view to compute screen coordinates. Fragment shader is executed once for each pixel on the screen to compute colors. .j3md file have definitions about input parameters (materials), techniques (shaders), and so on.
The number and the type of the parameters are fixed. But you can modify Terrain.j3m
to add a new texture parameter:
Texture2D tex4
Add a new input parameter to Terrain.frag
:
uniform sampler2D m_Tex4;
And modify the fragment shader code to use that new texture parameter as you like.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With