Color based on height

Hi, noob here that only just started reading about shaders and I am really struggling to get to grips with them.

I think what I am trying to achieve is quite straight forward - build a ships radar that will render everything above a certain height solid yellow and everything else blue. I have an overhead ortho cam to display radar.

I have tried varies answers from this forum, this one gave me compile error line 24, this one everything is solid blue. Finding it really hard to get my head round this and would really appreciate some help.

Thanks

well I couldnt work it out, but i got it working by simply swapping the material to an unlit yellow material at render for the radar camera

  • You first make a seperate camera for the radar (the ortho cam you already have)
  • You define which objects this camera renders (via RenderType or Layers && if object is above certain height)
    You could also render the water as a mask or adjust orthocam farclipplane to water level, so you wouldnt need the if clause above
  • The result of the camera goes to a render texture via a replacement shader (to get a mask)
  • you Show this mask texture and do the color ramp with it.

If you would like to see the procedure, one of these packs: TOZ Glow, TOZ Blur, TOZ Emboss, TOZ Desaturate, TOZ Pixelate do the procedure as described above with small differences which is ready to use for their purpose and also a good learning material as all the well written source code is in there, or you could contact me and i could prepare you one.