Search Unity

URP and _CameraDepthNormalsTexture

Discussion in 'Universal Render Pipeline' started by asger60, Nov 12, 2019.

  1. asger60

    asger60

    Joined:
    Mar 27, 2013
    Posts:
    45
    Hey
    I'm trying to make an outline shader like the one described here https://alexanderameye.github.io/edgedetection but it seems like there's no way to get the camera normals into shader graph or anywhere else for that matter.
    Is that correct?
    Is there an alternative way to get to screen space normals?
     
  2. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    nope. urp does not render out normals. only depth and color if you set it up properly.
     
  3. asger60

    asger60

    Joined:
    Mar 27, 2013
    Posts:
    45
    well that is disappointing, and there's no workaround/hack?
     
    Lars-Steenhoff likes this.
  4. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    you can "approximate normals" by reconstructing the worldposition of the depth buffer sample.
    then use cross( ddy(wpos), ddx(wpos) ) to get the normal. this normal will represent the actual geometry. it won't be smoothed. so you will get some flat shaded style.
     
  5. asger60

    asger60

    Joined:
    Mar 27, 2013
    Posts:
    45
    Hey thanks, that took me a little step closer to destination outlines :)
     
  6. zezba9000

    zezba9000

    Joined:
    Sep 28, 2010
    Posts:
    985
    That will not work on GLES2 devices.