Search Unity

Star Background

Discussion in 'Shaders' started by cranky, Sep 21, 2014.

  1. cranky

    cranky

    Joined:
    Jun 11, 2014
    Posts:
    180
    Hey guys, I'm a pretty experienced C# programmer, but the world of shaders is totally new to me. I am working on a simple Space Shooter style game. For the backdrop, I'd like to have a basic infinite star map. The stars can be just a few pixels wide, nothing fancy. I don't need nebulae or anything, though that would be cool. Flicker/twinkle is a neat bonus, but not necessary. I'd figure Perlin Noise would be the way to go, but I have absolutely no idea how to go about this in Unity. I've never written a shader before. Can anyone please point me in the right direction?

    Thanks!
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    The simplest thing is to not use any special shaders, but plonk a star map texture on a quad in the background (make sure the texture is set to repeat, not clamp), and animate renderer.material.mainTextureOffset.x. Use modulo to keep it in the 0..1 range, since mobile GPUs tend not to like it when UVs get too far from the origin.

    --Eric
     
  3. cranky

    cranky

    Joined:
    Jun 11, 2014
    Posts:
    180
    Thank you very much! This is exactly what I need!