Search Unity

Resolved Parallax Occlusion Mapping node

Discussion in 'Shader Graph' started by MACHIN3, Dec 15, 2019.

  1. MACHIN3

    MACHIN3

    Joined:
    May 25, 2016
    Posts:
    61
    Hi,

    I'm struggling to get the POM node to work, as it should.

    I have a height map wich is 50% grey at the mid point - the "surface level". Darker should offset down, brighter up. I have tried setting the map to linear and sRGB. It doesn't seem to make much of a difference, but I'd assume linear to be the way to go. I can only get the UV offset to work if I increase the Amplitude A LOT, but then the entire thing offsets, including the 50% grey pixels. I've attached the map for reference.

    Here's the simple node setup with a normal map, which I have also attached.
    pom.png
    Do I need the PixelDepthOutput, if so what do I do with it? Am I wrong in using the Amplitude for the Parallax amount?

    Here's the general offset described at the beginning, when increasing the Amplitude a lot.

    I'm using ShaderGraph 7.1.6 in the latest Unity 2019.3.0f3 with HDRP on Ubuntu. The manual, does not include an entry for the node unfortunately.

    I'd really appreciate some input! Thanks!
     

    Attached Files:

    Last edited: Dec 15, 2019
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,339
    You definitely want it to be linear, however height maps for POM are almost always 1.0 is at the surface and 0.0 is offset "down". POM doesn't handle surfaces that extend "up" from the surface well, since at glancing angles the mesh's silhouette isn't changing it's obvious that he effect is fake, so the 0.5 as the mid point that usually comes from displacement doesn't apply.
     
    MACHIN3 likes this.
  3. MACHIN3

    MACHIN3

    Joined:
    May 25, 2016
    Posts:
    61
    Thanks, using a height map that's white at the surface does the trick. I'm aware going "up" is not ideal for parallax, but it works well enough for me in Blender in some cases. Also, I'm pretty sure ASE did parallax using a grey height map, when I last used it 2 or so years ago. Will check that out again.

    Anyway, thanks again, marking this as solved.
     

    Attached Files:

  4. LastAtlas

    LastAtlas

    Joined:
    Jun 9, 2013
    Posts:
    15
    The Pom in HDRP seems to be a "shell" like implementation and does in fact add to the silhouette and even self shadow from what I recall though? Unless it's changed?
     
  5. laurent-h

    laurent-h

    Joined:
    Sep 29, 2016
    Posts:
    78
    Hi, our POM indeed only goes down from the surface.
    As a result, the neutral/reference value for the height map when using POM is white and not grey.

    Silhouette POM would allow to go up but it is still quite expensive so it is not what we implemented.
     
    MACHIN3 likes this.
  6. laurent-h

    laurent-h

    Joined:
    Sep 29, 2016
    Posts:
    78
    You can use depth offset by enabling it on the Master node and then connecting the pixel depth offset from the POM to it.
    This will make all effects relying on depth match the displaced surface like :
    - contact between objects
    - lighting, shadow maps, contact shadows
    - ambient occlusion
     
    MACHIN3 likes this.
  7. Laurens-Paladin-Studios

    Laurens-Paladin-Studios

    Joined:
    Apr 25, 2015
    Posts:
    54
    @laurent-h : I would like to hijack this thread to maybe have Unity reconsider to add a value that can be set as the 0 plane for the POM node, between 0 and 1

    As @MACHIN3 states, as long as you are careful with the placement of the decals that protrude outwards "it works well enough in blender". This would not necessarily need any Silhouette implementation, just a slight offset for the value.

    Small example Of the top part "sticking out" (hacked in by just applying the grey scale = 0 texture)
    POM_GoingUp.gif

    Example of it only going in, not as fancy, because only the Normal info makes it look like it's up
    POM_OnlyDeeper.gif

    Anyway, I hope this makes sense. Other option is to create a custom POM node based off the Unity one.

    Cheers,
    Laurens
     
    Last edited: Apr 13, 2021
    MACHIN3 likes this.
  8. altepTest

    altepTest

    Joined:
    Jul 5, 2012
    Posts:
    1,115
    Hi Laurens, I will hijack this thread from you because I still don't get how this depth offset should work. I've managed to implement it in the HDRP hair shader, and it appears to do what I want, meaning get rid of the ugly intersection of hair cards, but I did all this implementation not actually understanding what I'm doing,

    so for my height map what is the 0 point? white, black, 50 grey?

    thanks
     
  9. Laurens-Paladin-Studios

    Laurens-Paladin-Studios

    Joined:
    Apr 25, 2015
    Posts:
    54
    Hi @dorusoftware The shadergraph node expects your heightmap value of 1 to be the surface, anything darker would be pushed inwards
     
    altepTest likes this.
  10. altepTest

    altepTest

    Joined:
    Jul 5, 2012
    Posts:
    1,115
    thank you for the answer