TerrainLighting - Splats black without normalmap

Hi there!



In my project I want to use a TerrainLighting material with an alpha map and 4 splats. Since eventually I wish to use the maximum of 16 (2a+8s +6n) textures I omitted giving each layer a normal maps. This, however, causes the texture to be displayed as black. Only if a diffuse map is given a normal map as well, will it be rendered correctly.

I tried to play around with the ‘Miscellaneous Material Parameters’ from the materials_overview wikipage but got nowhere.



Please help me.

Do you have a light in your scene?

How does it look when you use different materials in the TerrainEditor in the SDK?

Thank you for answering so promptly!


@Sploreg said:
Do you have a light in your scene?


Yes, I do:

[java]
AmbientLight ambLight = new AmbientLight();
ambLight.setColor(new ColorRGBA(128/255f, 50/255f, 0.1f, 0.8f));
rootNode.addLight(ambLight);

DirectionalLight light = new DirectionalLight();
light.setDirection((new Vector3f(-0.5f, -0.5f, -0.5f)).normalize());
light.setColor(ColorRGBA.White);
rootNode.addLight(light);
[/java]

They are loaded before I generate the terrain and set it up.

@Sploreg said:
How does it look when you use different materials in the TerrainEditor in the SDK?


I've never used the TE since I aim to generate all the needed assets on the fly. Clicking things together in a GUI doesn't really get me the understanding required for that, or so I thought.
On that note - is the following correct? Alpha map values are mapped like this:

255,0,0,0: DiffuseMap
0,255,0,0: DiffuseMap_1
0,0,255,0: DiffuseMap_2
0,0,0,255: DiffuseMap_3

I was wondering if there was any tutorial on how to blend these DMs?

Do the test cases look as they are supposed to on your machine?



red: DiffuseMap

green: DiffuseMap_1

blue: DiffuseMap_2

alpha: DiffuseMap_3



If your image is ARGB then that will be mixed up a bit.



There isn’t a tutorial on bending them, that is handled for you in the TerrainLighting.frag shader so you can look at that for reference.

@Sploreg said:
Do the test cases look as they are supposed to on your machine?


I tried to copy+paste code form there to my project and somehow fiddle it in.
Somewhere along the line I must have fixed my mistake, since the problem had resolved itself with that.
Unfortunately I have absolutely no clue as to how that came to pass :o

@Sploreg said:
There isn't a tutorial on bending them, that is handled for you in the TerrainLighting.frag shader so you can look at that for reference.


Thank you, I will do that!

Another thing I was wondering, is there any way to get more than 12 textures on a material?
I want to (initially) color spots on a 3D surface, eventually to move on to replace them with a range of symbols (textures). Having only 12 will likely not be enough.
Placing simple 3D objects is out of the question for me, since they would stand out on the noisy underground and I will place a lot of them. I'm not sure whether or not that would lead to a significant increase in memory usage, as compared to the texture-based solution.
Is there a way to avoid this?

16 textures is the limit for most video cards. More textures can be used with TextureArrays or 3DTextures in the terrain shaders. They currently do not use them though.

For projecting a texture on the terrain you can try this http://hub.jmonkeyengine.org/groups/contribution-depot-jme3/forum/topic/projective-texture-mapping/

@buggy said:
I tried to copy+paste code form there to my project and somehow fiddle it in.
[...] the problem had resolved itself with that.
Unfortunately I have absolutely no clue as to how that came to pass :o


I figured it out. My custom alpha map didn't get filled with any values until after the textures were set on the material. Although I painted the whole map immediately afterwards, this wasn't enough.
Initializing it before texture-setting did the trick.

@Sploreg said:
[...] For projecting a texture on the terrain you can try this [...]


This looks promising, thank you.