Search Unity

Edge Detection/Environment Effect Help

Discussion in 'Universal Render Pipeline' started by DylanGilchrist, Feb 14, 2022.

  1. DylanGilchrist

    DylanGilchrist

    Joined:
    Feb 16, 2018
    Posts:
    6
    I am creating a shader to gradually show a 3D environment over time. I have an edge detection shader for a stylised look and the world drawing functionality of the shader is working but rather than just drawing the surfaces of the objects I would like to draw the edges of those object before the surface if that makes sense? It’s meant to be like the world is being sketched so the outlines/edges are drawn and then the surfaces are coloured.

    I would appreciate any advice/links of this effect and would like to know if it’s even possible lol.

    Cheers.
     
  2. DylanGilchrist

    DylanGilchrist

    Joined:
    Feb 16, 2018
    Posts:
    6
    Edge detection custom pass*
     
  3. uwdlg

    uwdlg

    Joined:
    Jan 16, 2017
    Posts:
    150
    How does the edge detection work (does it look for color, depth or normal discontinuities or any combination of them)?
    How does the "world drawing" shader work?
    Assuming you have some kind of value based on which the shader draws more or less of the world (let's call it "revealPercentage") and that value is animated from let's say 0 (nothing revealed) to 1 (everything visible), I came up with the following rough idea:
    Maybe you could expand the custom pass to first draw the scene to a temporary RenderTexture using an override material with the "world drawing" shader, but with a higher "revealPercentage" (meaning more of the world is already visible) and use this RenderTexture as the source for the edge detection part. Then composite the edge detection outlines on top of the "normal" scene drawn with the "world drawing" shader and lower "revealPercentage", theoretically producing outlines extending farther than colored-in areas that appear with a delay.
    I hope that was more or less comprehensible, also no guarantee this is a "good" solution.