BGE node set up for gradient texturing along Z-axis

I have been trying to find a solution using nodes to texture a plane using the z-axis and distance rather than normal’s. You can see in the picture below that I have separated this mountain into 6 areas of terrain. I am using a simple color code to visualize which area will have which terrrain type; red=coral, yellow=sand, brown=midlands/flatlands, light green=foothills, dark green=mountains, white=summit. I want to use a gradient node set-up to texture the plane according to the set distances as marked by my color code. If anyone can share any insights I would appreciate it.


I tried this method, but it doesn’t seem to work with BGE. Anyone have similar techniques that work in BGE?

You can try something like this but it’s based on incident angles not distance.

Attachments

ToonShaderGLSL.blend (146 KB)

I reworked one of my old blends.


I feel that i should mention that by using blender’s Texture Paint mode you can make a lot better landscapes.
I hope the node setup is understandable, the Blend:
Updated
Land.2.blend (952 KB)

Attachments

Land.blend (917 KB)

Thank you so much for the help. I am away from my dev station for a while so I can’t test, but it looks promising. The best I could do always ended up with real hard transition lines, which seems to be solved from your picture. I will study your node set up when I get home and see where I went wrong. Thanks again.

I had a chance to test the blend and it works as I had hoped. I am having trouble customizing it to fit my needs, but I think I can get it with a little help. I have been playing with the mapping settings to get the layers right, but I always end up with black sections, repeating textures, and for some reason or other the rock texture doesn’t load. Is this limited to 3 texture types (i.e. dirt, grass, rocks), or is there a way to define a texture for each color? I tried modifying the base color ramp, but I can’t quite get it as I always end up with black sections and incorrect textures in several layers. I can think of a few ways in my head that might fix this, but I can’t get it to work. Here is my blend with a section of my planet that shows the different terrain layers; 00Bedrock is untextured and simply defines the lowest most ground point or 0 on the z axis, followed by 01Coral, 02Sand, 03Midlands, and 04Foothills. The latter four each have a visual template, with everything above 04Foothills considered mountains. I could use a few tips to help me figure this out if anyone has the time. Thanks in advance.



This is a quick explanation of how it works.
First download Land.2, it has a better gradient and the missing texture.

The Yellow zone is where the gradient is mapped to the mesh, this feeds into each group.
The First important value is location and it moves the texture in 3d space and scale will map it, if you move your mesh up or down you can see how it is mapped.
If you want each mesh to have it’s own scale change the mapping node’s input to UV and UV-map from the side with project from view(Bounds).

The Red zone is where the color channels are extracted, press TAB key to edit a group.

The Blue zone is where each channel is converted to a stencil, by changing this color gradient you will change how much a space a texture uses.
Experiment with this to match what you want.

The Orange zone is a alpha overlay, here each stencil is stuck to the mesh.

If you want to add a new texture you can’t copy a group you have to make a new one.

First separate the red or green channel, depending on where you want the new texture, use the color ramp to adjust where you want the texture.(remember to add alpha to the color ramp)
Add a texture node with your texture(Select the Texture node and on the properties window go to textures), give it a global vector, multiply this with the white color ramp to use the color ramp as a stencil.

To lay a stencil over others the texture color should be plugged into the Color2 slot of a Mix color node and the factor should be the alpha of the stencil.

Thanks for the quick explanation, I was way off in what I was doing to make adjustments. I should be able to get this working now. I recommend you add this to the resource section, or let me do it for you. The only other thing is the blend did not get attached. Thanks for the help, I can finally move on to another part of my game. :cool:

Here is the blend:
Land.2.blend (952 KB)

You can add it to the resource section if you want, but I feel it has very limited use and not many people will have a use for it.