TerrainLighting.j3md: cannot modify scale of DiffuseMap texture?

I’m trying to use the Common/MatDefs/Terrain/TerrainLighting.j3md material in order to render terrain, but I’m having a problem with the DiffuseMap_0_scale variable: changing it doesn’t seem to do anything.

[java]mat_t_repeat = new Material(assetManager, “Common/MatDefs/Terrain/TerrainLighting.j3md”);

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


mat_t_repeat.setTexture(“DiffuseMap”, texture);

mat_t_repeat.setFloat(“DiffuseMap_0_scale”, 64f); // doesn’t seem to do anything at the moment

mat_t_repeat.setFloat(“Shininess”, 5f);[/java]

No matter if I change the DiffuseMap_0_scale to 0.01f or 1024f, neither the texture or the material changes at all. Any ideas?

(Also, if I load a NormalMap into the material, my entire game crashes with the error “ERROR: 0:606: error(#202) No matching overloaded function found calculateNormal” in Common/MatDefs/Terrain/TerrainLighting.frag.)

Looking at the source it looks like maybe the DiffuseMap texture is only scaled if an AlphaMap is also defined. Could this be the problem?

Without the alphamap the diffuse one cannot be mapped :?

Yup, by adding an AlphaMap it works as expected. i.e. TerrainLighting.j3md cannot be used with a single diffuse texture unless an AlphaMap is also supplied.

I was trying to use TerrainLighting.j3md to render a single-textured terrain because Lighting.j3md doesn’t have a scale parameter.

Not sure if it would be worth fixing TerrainLighting.j3md to scale for single-textured definitions?

Not really as its made for… terrain :slight_smile: And requires an alpha map.

1 Like