Search Unity

Question Per-poly billboard in HDRP, world position issues.

Discussion in 'Shader Graph' started by CVernon, Mar 5, 2021.

  1. CVernon

    CVernon

    Joined:
    Jan 28, 2015
    Posts:
    4
    Hello,

    I am trying to recreate this tutorial from Pontus Karlsson on stylised fluffy trees but in Shadergraph instead of Amplify. Basically, each polygon covers the entire UV space and is billboarded individually, to create a stylised fluffy effect.


    Thing is, I can't get it to work properly. I end up with a severe position offset that gets exponentially worse the further from world origin the mesh is located:


    Here is my graph. I am using Unity 2019.4.7f1 LTS, HDRP 7.3.1, and Shadergraph 7.3.1.


    This is based on one of the solutions posted in the youtube comments, and have tried other variations posted, including one from the tutorial maker themselves there but to no avail. Different people have had varying results with setting the transform to either Direction or Position.



    I looked up how World position is relative to the camera in HDRP and have tried various combinations of Absolute World, World, Object, etc. but it has not helped me. I can either make it change the specific behaviour of the offset (including making it stick to world 0 and be immobile) or if I remove the offset I lose the expected billboard behaviour. I even tried disabling Camera Relative Rendering, but it had no effect besides making everything look like it was under intense motion blur.

    I have also attempted this in a fresh project using URP, same results. I also created a basic billboard to get a better understanding of them, which was successful but not in a way I knew how to transfer to this. My brain is fried now so I've lost track of all the other small things I've tried or any mistakes I may have made attempting them.

    I lack the knowledge and experience on how to effectively troubleshoot further and make this work. So any help is appreciated!
     
    Last edited: Mar 6, 2021
  2. CVernon

    CVernon

    Joined:
    Jan 28, 2015
    Posts:
    4
    With some further testing, I've found the positional offset occurs because scale and rotation is being performed from the world origin.

    So the question is, how can I correct for this in the shader?
     
    ASMRPL2022ZBI likes this.
  3. CVernon

    CVernon

    Joined:
    Jan 28, 2015
    Posts:
    4
    I have fixed my problem.


    Turns out, the Transform from Absolute World to Object space was causing the offset. I replaced it with an extra multiplication of the model's Transformation Matrix, and removed the final addition from the Object Position.

    Here is the completed shader, with billboard size and inflation added from the tutorial:
     
  4. spinning_clock

    spinning_clock

    Joined:
    Jun 22, 2015
    Posts:
    23
    Hi NoraMeep,

    Thanks for the shader info, I tried your shadergraph but I am getting this issue, where the back billboards are in front of the front billboards, there is some z-ordering issues:

    https://drive.google.com/file/d/1rHt0JaDBEaCZ5IE6V3GBCFb2ZujLdIkj/view?usp=sharing

    Ive double checked my shader graph against yours but can't see any differences (I have unplugged the emission which wont have any effect):

    https://drive.google.com/file/d/1AoTStyw0SYBu_5HnboRKYayGBnTFRzQR/view?usp=sharing

    Any thoughts on what Ive done wrong?

    Thanks
     
  5. CVernon

    CVernon

    Joined:
    Jan 28, 2015
    Posts:
    4
    Hello!

    I had a look and replicated this kind of behaviour by making it Transparent like your master node. We instead used a Standard Opaque Lit shader relying on the fresnel to fake transmission (which does unfortunately mean it needs to be tuned per each level's lighting).

    This is the result we intend to ship with + the master node settings: upload_2021-8-7_16-27-57.png

    I couldn't find a quick way to make it sort properly on a Transparent shader, so if you need that specifically then I'm afraid I can't be of much help. I would suggest however, if you're using HDRP, to use the Lit master node instead of the PBR one, since that seems to be the one we're meant to use for HDRP (frustratingly, this master node is not mentioned in the 7.3 Shadergraph docs, but is in HDRP: https://docs.unity3d.com/Packages/c...es.high-definition@7.3/manual/Lit-Shader.html still worth checking the docs for your versions just in case though.

    You may be able to get the results you want from Translucency + Diffision Profile (which is closer to actual plant behaviour, Transparent is for things like glass), which is available from the material type options. However, while this looks great on things like our grass, it appears to have little to no effect on these kinds of meshes, so I presume additional shader magic would be needed.

    I hope this helps you out!
     
    ASMRPL2022ZBI likes this.
  6. MelonMan96

    MelonMan96

    Joined:
    May 4, 2014
    Posts:
    10
    Dude thank you so much! I was trying to replicate this shader for DAYS and with your graph it finally worked <3