Search Unity

Help Making View Cone that Follows Terrain Height

Discussion in 'Shaders' started by Bradster15, Jul 24, 2019.

  1. Bradster15

    Bradster15

    Joined:
    Feb 15, 2019
    Posts:
    1
    HI I am trying to make a view cone, similar to the one found the the Commandos and Shadow Tactics Game.

    I have tried using projectors, however they don't get effected by world objects, and I have also tried spot lights.
    Would anyone advise if it would be possible to use a shader to do this. All I want is for the texture to follow to ground height and no go through objects. Thanks
     

    Attached Files:

  2. mouurusai

    mouurusai

    Joined:
    Dec 2, 2011
    Posts:
    350
    Yes it is possible. You need render depth map from your object place and use it for masking. Basically it's how shadow maps works.
    It's little too much for me to try do it myself, here some random article about shadow mapping for give some taste what I mean:
    http://www.opengl-tutorial.org/ru/intermediate-tutorials/tutorial-16-shadow-mapping/

    Also you can use one from "2d lighting" assets, from asset store if your ground if pretty much flat.
     
    Last edited: Jul 28, 2019