Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Newbie Shader Question on masks.

Discussion in 'Shaders' started by Fluzing, Apr 5, 2014.

  1. Fluzing

    Fluzing

    Joined:
    Apr 5, 2013
    Posts:
    815
    Hi All,

    I am building a space game and I am designing the GUI now for the ship status. I am trying to create a shield status effect (in blue in the picture. As the shield of the ship goes down, the blue line gets thinner. I figured the easiest way to decrease the blue line would be to shrink the scale of a circle. However, if I simply use a circle with a black hole in it, the hole would shrink too.

    I figured a simple mask that cuts out the hole would be the best solution, but is it possible to achieve what I want using a simple mask? How would I do this? I tried finding a way to lay a mask onto a texture, but I can't find anything on this subject. Is what I want possible?

    Below the picture. The hole is supposed to be the same size in both instances.

    $shield.jpg
     
  2. bricevdm

    bricevdm

    Joined:
    Nov 4, 2009
    Posts:
    34
    the easy way would be to do a flip book, where you have various steps of the animation side by side which play like a series of frames.
    Since this is only a circle and you only want to change the outline you could look into "signed distance fields" and create an animated mask by clamping a blurred version of your circle. (this involves some custom shaders tough, but it's not too complicated)
    https://www.youtube.com/watch?v=CGZRHJvJYIg
    http://www.valvesoftware.com/publications/2007/SIGGRAPH2007_AlphaTestedMagnification.pdf