Search Unity

Character Field Of View Visualisation Shader (grayscale)

Discussion in 'Shaders' started by MichalDev, Mar 23, 2018.

  1. MichalDev

    MichalDev

    Joined:
    Mar 1, 2017
    Posts:
    33
    Some time ago I added a thread which you can check right here:
    https://forum.unity.com/threads/transparency-shader-render-only-lit-enemies.515788/#post-3380740

    I got my answer but I realised that using volumetric lights to represent player's field of view can heavily impact performance. We don't want to do that when we are going to have like 20 characters with their own field of view on the scene. The project is top-down shooter with restricted character's vision and we want to visualise that.

    I can easily generate vision mesh by script and write stencil shader that shows only pixels in mesh mask. It's great. But everything else is black ! I want to get practially the same effect as on the screen :



    The only difference is that I can't make grayscale texture of my map in the background like guys from Monaco team.

    Summarizing in case if someone will immediately know how to help me:
    I want to create shader that will desaturate (create grayscale effect) everything except the objects in player field of view which is indicated by mesh.



    Thank you guys in advance. I need to get it done till this year's Digital Dragons in Poland. I will be really, really grateful, because my knowledge about shaders is really poor.