Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  3. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Billboard Shader with Shadergraph

Discussion in 'Graphics Experimental Previews' started by Spy-Shifty, Aug 11, 2019.

  1. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546
    Hi,

    I wan't to create a spherical Billboard Shader in Shadergraph.

    I tryied severel things and nothing worked :(

    Can someone help me please?
     
  2. Excelerator

    Excelerator

    Joined:
    Nov 14, 2013
    Posts:
    37
    This is a good question! I can't get any billboarding to work because when I use the "Position" set to object space, it gives an inconsistent number when I clone the objects. It seems they broadcast a shared position between all of the objects under that drawcall? I have tried separate materials and it works, but then I lose the ability for it to run fast.

    Here's what I have. It's a vertical upwards billboard using some basic trigonometry. But it fails when I add clones of objects. This is so frustrating. I must be taking the wrong approach? What do you think?
    upload_2019-10-14_17-56-29.png
     
  3. Excelerator

    Excelerator

    Joined:
    Nov 14, 2013
    Posts:
    37
    Actually, it seems to work if I don't use sprites. Just Use 3D Geometry and it works.:eek:
     
  4. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546
    Thank you for your answer! I've already found a solution some time ago.
     
  5. Excelerator

    Excelerator

    Joined:
    Nov 14, 2013
    Posts:
    37
    How did you do it? I managed to make a spherical one using the "Rotate About Axis" node twice, but I get wrong rotations when the camera is upside down. Also, the object's transform rotation must be 0,0,0 for it to work.
     
  6. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546
    Here is how I managed the spherical rotation. It works pretty well.
    A note by the way: It also scales proportional with the distance to the camera

    This is part builds the 4x4 rotation matrix which is multiplied with the position of the vertex.
    It's the most importent part...
    upload_2019-10-24_18-39-58.png

    This fitts all together and also handles Color and auto scale by distance...
    upload_2019-10-24_18-40-30.png
     
    Last edited: Oct 24, 2019
    DeathRace26, SgerbwdGwyn and Windroid like this.
  7. jakwin

    jakwin

    Joined:
    May 20, 2019
    Posts:
    3
    There is a problem with the billboard algorithm upstairs
     
    ElementMo likes this.
  8. ElementMo

    ElementMo

    Joined:
    Jul 12, 2018
    Posts:
    4
    There is an error with the graph, in the very beginning, there is no need to multiply the camera direction by -1.
    In this case, the Quad mesh will not be rendered from it's back.