TerrainLighting diffuse maps

Hey, sorry to keep bothering y’all, but I have a problem with TerrainLighting.j3md

I was using a png with an alpha channel from photoshop for my alphamap, but when I ran it, all the red, green & blue areas turned out as diffusemap_3 & the alpha areas were a mixture of diffusemap, diffusemap_1 & diffusemap_2.

So I decided to just miss out diffusemap_3 & use jpgs for my splat maps, & skip directly to diffusemap_4, since I won’t end up using all 16 splat textures, & I would prefer to store my images as jpegs with no alpha since because I am using terraingrid, each alphamap consists of 144 different tiles (I have a big terrain :p).

So anyway, where the red area is on alphamap_1 just comes out as diffusemap

So yeah, hope you can understand that as it is a little wordy. Does anyone know how to get diffusemap_3 or diffusemap_4 to work? Thanks in advance!

Check the terrain manual, they are the splatting textures which are displayed through rgba values of the splat map. From what you describe this is expected behavior. If you paint terrain in the sdk and look at the alpha maps that should become clearer.

1 Like

Ok, thanks Normen. Where are TerraMonkey’s alpha maps stored?

They are created in Textures/Terrain/alpha (or something like that) when you create a terrain and paint on it.

1 Like

What I am seeing does not make sense. There are 7 textures painted onto the terrain, but only two images are being used, & each one has only alpha & another colour.


how does this work?

Yeah, R G B A, thats 4 values, one for each texture. So you need only one alpha texture for four diffuse maps that you want to mix.

1 Like

I do not know why the windows preview of the images look strange, does it handle transparencey correctly?

The behavior you described first seems really strange. I have no problem using 4 (or more) diffuse maps. They are mixed together fine by varying the values of the the alpha maps. Maybe you have some off by one error in setting the names of the maps to the shader (notice that the first diffuse map is named diffusemap, the second is diffusemap_1)?

From TerrainLighting.frag


uniform sampler2D m_DiffuseMap;



uniform sampler2D m_DiffuseMap_1;

If you load the image in a normal editor you will see some strange image as it decodes it as RGB and the Alpha value… So if you didn’t paint anything with the n*4th texture (the actual alpha channel of the alpha map) I guess the whole image might be transparent.

1 Like

I still don’t understand, there must be something going wrong in my code.


On the left is my Alphamap in photoshop, on the right I am using it with terraingrid

Here is the code:


material = new Material(assetManager, “Common/MatDefs/Terrain/TerrainLighting.j3md”);

material.setBoolean(“useTriPlanarMapping”, false);

//material.setBoolean(“isTerrainGrid”, true);

material.setFloat(“Shininess”, 0.9f);

// GRASS texture

Texture grass = assetManager.loadTexture(“Textures/Ground/grass.jpg”);


material.setTexture(“DiffuseMap”, grass);

material.setFloat(“DiffuseMap_0_scale”, 60f);

// DIRT texture

Texture dirt = assetManager.loadTexture(“Textures/Terrain/splat/dirt.jpg”);


material.setTexture(“DiffuseMap_1”, dirt);

material.setFloat(“DiffuseMap_1_scale”, 10f);

// COBBLE texture

Texture cobble = assetManager.loadTexture(“Textures/Cobble/Cobble4.jpg”);


material.setTexture(“DiffuseMap_2”, cobble);

material.setFloat(“DiffuseMap_2_scale”, 10f);

// PATH texture

Texture rock = assetManager.loadTexture(“Textures/Terrain/splat/road.jpg”);


material.setTexture(“DiffuseMap_3”, rock);

material.setFloat(“DiffuseMap_3_scale”, 10f);

What comes out as ‘path’ on the terrainquads is infact the cobble texture. also, without diffusemap_3 it comes out fine.

Can you switch the alpha and red coloring in the pic? How’s it look then?

1 Like



food for thought ^^ its a simple ordering issue combined with the “alpha channel” basically being invisible in an image editor.

Well that sounds alright… But how do I get my slphamap to work ? :confused:

:? You just write its R,G,B and A values? What do you want to do? Have a way to add dirt in-game or something? Just write the right channel in the image at the right locations and apply it to the terrain…

the texture layers are painted in this order:





so green on top of red, blue on top of green, etc.

Remember an alpha of zero means transparent in your image, and nothing rendered on the splat terrain.

In all cases there if you can see the text, then you have the alpha channel there too, on top of your other textures.

You want to paint by hand, use the channels section of photoshop with an alpha channel added.

1 Like

Forgive me for being such a noob here, but aren’t those grey sqaures in photoshop the alpha?

The way I understand it, the squares define which parts of the images will be transparent, arghh!!? help!

EDIT: Forget that, bear with me a sec!


Sorry for all my noob-ish-ness, it appears that I did not know what an alpha channel was. :stuck_out_tongue: