Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Sky-Star Shader

Discussion in 'Shaders' started by Berserker44, Nov 28, 2017.

  1. Berserker44

    Berserker44

    Joined:
    Sep 1, 2013
    Posts:
    29
    Hello,

    I am trying to create 2d sky and I need help with creating a shader that combines a gradient background, and a rotating texture of stars. Currently I have two seperate planes with a gradient background and a transparent plane with stars. It looks great and what I am shooting for, but i am trying to avoid a full-screen transparency. Having overlaying transparency is really bad on performance.


    Current 2d Sky
    Unity Star Sky Question.PNG

    I just wanted to reach out and see how should I approach something like this and see if anyone else has tried to do something similar to this. My main issue right now is I am having a hard time writing a gradient shader
     
  2. brownboot67

    brownboot67

    Joined:
    Jan 5, 2013
    Posts:
    375
    A gradient is easy, just use the UV's of your quad as the base...

    Code (csharp):
    1. fixed3 gradientColor = lerp(_GradientColorOne.rgb, _GradientColorTwo.rgb, i.uv.y);
    You can easily google more examples of this as well as rotating a texture in a shader.