Search Unity

Question Shader displacement around colliders?

Discussion in 'Shader Graph' started by Natecurt, Apr 22, 2019.

  1. Natecurt

    Natecurt

    Joined:
    Jul 25, 2014
    Posts:
    8
    Hi,

    I am fairly new to Unity's shader graph and was hoping someone may be able to help me achieve the following effect.

    I am trying to create a dynamic shader which displaces from certain areas in realtime. Ideally, I would like to be able to have this shader fill the scene everywhere except for areas which have colliders with a specific tag or of a specific layer. (Similarly to shadows which wrap around the only light source in a dark room).

    I do not want to mask the shader as it does not give the result I am looking for.

    As of right now, the only options I see available are:

    1. Using a realtime boolean subtraction on the mesh of this shader.
    2. Some sort of shader displacement method I am not familiar with.

    If you have any ideas for how I may be able to achieve this effect or need more details please let me know.

    Thanks
     
  2. Fainth

    Fainth

    Joined:
    Apr 19, 2019
    Posts:
    11
  3. Natecurt

    Natecurt

    Joined:
    Jul 25, 2014
    Posts:
    8
    Thanks for the reply!

    I will attach some quick examples of what I mean.

    In the images, the shader is represented by the black outer portions of the image. The white portions represent "light" or the areas unaffected by the shader. Essentially, I want to be able to control where a shader is being displayed dynamically. Since the game is top down, I image the shader to be on an object which is a child of the player so that when the player moves around the object with the shader will follow. Therefore, whenever the player walks by a "light source"(image 2) this object's shader needs to basically mask itself from these areas. Like I mentioned before, a mask wont work in this case as it is a 3D shader and the edges will not transition nicely. Perhaps there would be a way to smoothly transition vertexes underneath the ground plane rather than masking them? I am already using vertex displacement on my shader however so I'm not sure that will work.

    Hopefully this helps. Let me know if you're still confused and Ill try my best to explain further.

    Thank you :)
     

    Attached Files:

    • 1.png
      1.png
      File size:
      36.8 KB
      Views:
      569
    • 2.png
      2.png
      File size:
      34.6 KB
      Views:
      577
  4. Fainth

    Fainth

    Joined:
    Apr 19, 2019
    Posts:
    11
    I'm not sure if I'm capable of creating the effect you're looking for.
    Maybe someone else could shine some light on this scene? ;)

    ( However my approach to this would be to either create a black plane in front of the camera, and let a shader adjust the alpha value of the area's you want to be lit. Or alternatively, turn off all the lights in the scene and add point lights to the locations that require lighting.)