Slope visualizer on terrain - Part deux

How can I do this on a terrain layer shader. I did this for a material shader for a mesh made in blender for my greens, slope gradient using a vector for the normal plus a dozen other nodes. but… man it would be so much easier to be able to apply this material for my greens on terrain.
blending the mesh edges into the terrain, plus, designing the greens in blender. it’s a lot of extra work to use this method.

I’m at a loss on where to even begin with customizing a terrain shader to do this.

I previously posted about a few methods I tried to apply a gradient to terrain texture using scripts but I failed horribly and settled on this. any ideas on where to even begin.

I assume the golf games that let you design your own courses must be applying to terrain layer, unless those games are converting terrains to a mesh and then rendering a different material for greens if that’s even possible. First time terrain user here so I’m really noobing it up on this.

Unfortunately it is quite hard to customize the legacy terrain shader (you didn’t specify which render pipeline you’re using; the path is slightly different for each one). The biggest obstacle is that the default shaders all assume you want at some point to blend out of the default shading path into a low res baked version of the terrain texture; many years ago this was a good optimization on hardware that was more ALU-challenged but that assumed path is baked into the terrain shaders now and makes it particularly tricky to customize, especially if you’re not familiar with the depths of the SRP include system.

We are painfully aware of how annoying this is for users. As you may have seen at Unite, there’s ongoing work on something much cooler and much more flexible, but alas we don’t have an ETA we can talk about yet :frowning:

In the meantime there are three ways forward for a case like this:

  1. You could use the Amplify shader editor, which will let you write node-based shaders for terrain in URP or BIRP. I Have not tried it but but the Visual Engine plugin makes a point of supporting Amplify shaders within its own terrain rendering system.
  2. You can write a regular Lit shader for the terrain using shadergraph. The UI tries to stop you applying non-terrain shaders to the terrain, but if you drop your material onto the material field in the inspector, it works. The big drawback here is that a regular lit shader does not support the Terrain system’s Draw Instanced flag, and Draw Instanced is pretty much always going to be faster on modern hardware. If you’re not GPU challenged, however, this is doable and it opens up a lot of creative options.
  3. You can bake the Unity Terrain to a conventional mesh, saving you the round trip to Blender. Since it’s a regular grid you just sample the height values build a grid of your own. This opens up all sorts of conventional shading options, and also offers more control over performance and memory (you could, for example, resample the baked mesh to save vertices). You can hide the original terrain while retaining the TerrainData and the collision that came with it. The main drawback here is the need to switch between the editing representation (the Terrain) and the runtime one (the mesh).

A fourth option would be a compute shader that generated a mesh on the fly using the heightmap and/or splat map data. That’d be fast (assuming your target hardware has compute) but it’s more technically challenging.

thanks for the response. about 98% of that was way above my head but I do appreciate it. ps I’m doing this in URP. probably going to just stick with what I’ve done as I’m about half way done and stick to making games that are more in my wheel house of modeling stuff in blender and not large open terrain scenes…