TriPlanar DiffuseMap_x_scale

I’m playing with the terrain-stuff and noticed that when I switched to Tri-Planar mapping (using TerrainLighting.j3md) my textures got the crap scaled out of them.

When not using tri-planar I have something like mat_terrain.setFloat(“DiffuseMap_0_scale”, 128f); but switching on tri-planar I have to set the scale factor to something like 0.125f to get about the same visual size of the projected textures (on an xz-plane triangle).

Almost seems like not using Tri-planar the scale maps to “number of pixels” and using tri-planar it is a scale factor. Is this by design and I misunderstand something? Otherwise perhaps it would be simpler on the newbies like me if it was consistent :slight_smile:



I don’t get this behavior, what do you do exactly?

They are scaled differently. Regular scaling is done by texture coordinates. TriPlanar mapping however can’t use the texture coordinates so it has to use world coordinates, which can make the scales widely different.

In the SDK it already converts them for you so they are roughly the same size when you switch back and forth.

Not a big problem, just eager to learn about this stuff so mostly interested in the expected behaviour, i.e. did I break something through ignorance or are my expectations flawed :slight_smile: I guess I might have some wierd set up of something to get the difference in scale. Given what Sploreg explained maybe the local scale and/or the local translation of the terrain explains it.

But basically I have code similar to the sample on the Wiki. One difference is I’m generating my own heightmap, fooling around with Perlin-stuff, maybe I mess up here, although the terrain sure looks alright.


terrain = new TerrainQuad(“my terrain”, 65, 513, heightmap.getHeightMap());

Material mat_terrain;

/** 1. Create terrain material and load four textures into it. /

mat_terrain = new Material(assetManager,


mat_terrain.setTexture(“AlphaMap”, assetManager.loadTexture(


mat_terrain.setTexture(“AlphaMap”, alphaTexture);

* Add red layer */

Texture red = assetManager.loadTexture(



mat_terrain.setTexture(“DiffuseMap”, red);

mat_terrain.setFloat(“DiffuseMap_0_scale”, 0.125f);

… [snip - the other diffuse maps are similar]

mat_terrain.setBoolean(“useTriPlanarMapping”, true);


terrain.setLocalTranslation(0, -100, 0);

terrain.setLocalScale(2f, 1f, 2f);


No your stuff is fine, switching between the two texture projection techniques drastically effects the scale of the texture. For example in the SDK if you has regular mapping and the scale is 16, if you switch to tri-planar, it will change the scale to 0.0625; and with that it looks about the same. It all really depends if your terrain is scaled and what the texture scale was.

Ok, thanks for your time, I feel more confident now :slight_smile: By the way, TerraMonkey is awesome, a big thank you to all commiters! Really looking forward to doodling with the terraingrid.

1 Like

Glad you like it. :slight_smile: