Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Shader graph: Rotating 2D planet with shadows?

Discussion in 'Graphics Experimental Previews' started by nicmarxp, Jun 5, 2020.

  1. nicmarxp

    nicmarxp

    Joined:
    Dec 3, 2017
    Posts:
    406
    The simplest way to make a planet in 2D that seem to rotate, was to make a sprite, set a mask, and have the texture offset animate. It worked, but there is a warning that this isn't supported, and it makes the game kind of laggy.

    So I want to know the best way to do this in the Shader graph. The current idea uses 4 textures:
    - 2048x1024 (Planet texture, wrapping)
    - 1024x1024 (Shadow overlay to make it appear rounded)
    - 1024x1024 (Black outline, could probably be combined with the shadow I guess)
    - 1024x1024 (Mask, to only show the circle)

    Also I'd like to have another texture to simulate the position of the sun, but I guess that wouldn't be an issue if I get the above working.

    Should I still use a sprite, or should I use a mesh/quad instead? And how would I set this up in Shader Graph?

    Oh and I'd also love to try and squish/bend the planet a little on the side to make it seem a little 3D. Is there a node for that? :)

    Note that I'm using the URP and 2D renderer, but in this case, lighting isn't required for the planets, but it would of course be good if I needed it for some reason, like for smalling rotating objects.

    Here's my current version using sprites:


    Thanks for your time! :)
     
  2. coolmatt

    coolmatt

    Joined:
    Jul 1, 2016
    Posts:
    4
    Hi,
    It's been awhile since your post but I find myself in the same boat... I saw that on Steam your game is announced for 2024, so I guess you found and answer since. If so, I really would appreciate a tip or two to point me in the right direction. Thanx; m.