Going a step further than normal maps, here is an implementation of relaxed cone step mapping (ala GPU Gems 3) with Unity’s built-in terrain. It adds agreat amount of detail at a relatively low cost.
Screenshot from Dawn of the Tyrant (In-development)
To use it, unzip the 2 files (shader and C# script) into your assets folder, save, and then restart Unity (so that the terrain shader replaces the built-in). Drag the C# script onto your terrain object and fill in the parameters.
It requires that you input normal, parallax, and texture for each of a maximum 4 textures that line up respectively with the texture list of your terrain object. It also needs the tile size of each texture and a parallax depth that determines the amount of offset (0.1 is a good start).
The shader itself is open to further optimization. It currently tests against all 4 textures which will likely hurt your framerate. It will be dramatically faster if you cut the shader code to accommodate only 1 or 2 terrain parallax textures that need the parallax effect and leave the others to normal mapping.
The parallax format is relaxed cone. Use xnormal to convert heightmaps to relaxed cone step maps.
Future planned improvements are height based blending (the screenshot below shows why this would improve the unnatural fading between textures), instruction optimization to allow for more steps, and proper silhouettes.
Enjoy!
Screenshot from Dawn of the Tyrant (In-development)


Unbeliavable. Still haven’t tested it, but the idea is unbelievable – thank you.
Unfortunately, the first test didn’t go well.
As soon as I import the shader plus the C# to my assets folder, the terrain behaves strangely. It becomes gray in the middle and I can see the textures on it only away from the central point of view.
Bug?
Tell me if I can help you identify the problem with screenshots etc.
Have you supplied the script with the right parameters, splat maps, normals maps, and displacement maps (have to be relaxed cone step)?
The shader overrides the built-in shader, so all of these parameters are necessary for the terrain to behave correctly
I have not placed ALL the textures yet, no; I took for granted that something was going wrong. I will now try to place them all and see what happens.
I am trying your previous shader first, just to have a quick test. It doesn’t give me the strange behavior on the terrain as this newest one. I added the shader and the script to my assets folder, I dropped the script to a Unity terrain, and what I see are four bump maps to place, and four tile and epsc values, and terrain size X and Y. No other values. I placed the same normal bump map, generated from within unity from a color texture, on the four bump channels. Nothing has changed…and, am I missing something or…how am I supposed to apply these textures? By using Unity’s terrain script, nothing changes as for the texture painting…I can apply color textures but still no bump in sight.
Do the textures have to have certain names, etc…what am I doing wrong.
Texturing is applied the same way using the built-in terrain texturing tools. Then we you want to add the normal maps, you have to also specify the “tile” size of each of the 4 textures on your terrain. You can see this number when you click the texture in the terrain and click “edit” to see what the tile size is. Set the respective size for each texture in our script below. Each normal map should also line up with the terrain textures respectively. The bump map inserts itself at runtime so you won’t see the change in the editor; you’ll only see it when you press play.
Hope this helps!
I am also trying to use your parallax shader for a project of mine, but have trouble getting it to work.
I have some questions concerning this:
1) I have never worked before with parallax shaders, so this whole topic is kinda new to me…. what kind of texture is needed for the bump map, what for the parallax map? Is it a “normalmap” for both, or a normale texture?
2) Do I need to drop the Terrain Toolkit before I add the parallax shader? Are this two script compatible? If not, I assume with some work I could integrate both?
Thanks for clearing that up for me…
Anyway, this shader looks great, if I can get it to work with the terrain toolkit or splat maps from world machine this would be so cool…
Thanks for the questions, I understand parallax mapping can be a bit confusing.
1.) The texture for the bumpmap needs to be a normal map. The texture needed for the parallax map needs to be a very specific type of map called a “relaxed cone step map”. It requires quite a bit of preprocess time to generate it, but it pays off with it’s speed in rendering. XNormal can generate these maps and there are probably others as well.
2.) This tool does work with our Terrain Toolkit. The Toolkit is only used the generation of the terrain and so it doesn’t interfere with the runtime shaders and scripts this tool uses.
Hope this helps! – Chris
So, after having played around with xNormal my big question:
Is it possible to use a base texture size and bump map size of 2048×2048, but 512×512 for the parallax map? It seems that 2048×2048 kills my PC when xNormal tries to Render the relaxed cone map (literally, It might finish in 2-3 Days but everything is pretty much frozen, so I can’t work in the meantime)….
If its not possible I will try out the bump-mapped terrain for the time being and switch to the parallax version as soon as I get hold of a second PC for rendering…. but if I could try it out with a less finegranular relaxed cone map, also good
the download link doesnt work can anyone send this to me!?
Hi Pat,
Can you try again? It works for me. It looks like we might have just had an outage on our web server. Sorry about that.
Someone actually sent it to me thanks anyway!
I assume the splat map replaces the generated splatmaps for the textures from the terrain toolkit?
Or are these for a different purpose?
Have tried your bump mapped terrain, and got very good results with it. Thanks for sharing, I hope I can get your parallax shader to run with the same ease.
alright, got this shader to work. After I found out that I needed to bring down the parallax depth a lot, it looks really great. big improvement over your bump mapped terrain!
The only thing I noticed was a considerable FPS drop my project suffered from after I exchanged the Bump mapped shader for the parallax one, but thats most probably my fault for using a huge tiled terrain without having streamed assets and terrain
I look forward to your next project, keep up the good work!