Skip to main content
added 54 characters in body
Source Link
wondra
  • 4.9k
  • 1
  • 22
  • 36

There is a very simple way achieving this with shaders, you need threethree* textures: empty health bar, health bar texture and mask with gradient of health distribution with one extreme(e.g. darkest not black or most transparent alpha value) on one end and the other on other end. It is best shown on image (I, I am currently unable do draw curved gradient only linear one, - but I am sure your artists wont have any trouble): enter image description here Now, in shader sample both textures and threshold the mask value, discarding all the pixels which are not brighter than input threshold (based on health % shader input).
You could use mathematical formula for masking instead of a texture, but if you did that, you would be still very limited to shapes you are able(=simple ones) to create with said formulas - and finding one is not trivial.
*see comments

There is a very simple way achieving this with shaders, you need three textures: empty health bar, health bar texture and mask with gradient of health distribution with one extreme(e.g. darkest not black) on one end and the other on other end. It is best shown on image (I am currently unable do draw curved gradient only linear one, but I am sure your artists wont have any trouble): enter image description here Now, in shader sample both textures and threshold the mask value, discarding all the pixels which are not brighter than input threshold (based on health % shader input).
You could use mathematical formula for masking instead of a texture, but if you did that, you would be still very limited to shapes you are able(=simple ones) to create with said formulas - and finding one is not trivial.

There is a very simple way achieving this with shaders, you need three* textures: empty health bar, health bar texture and mask with gradient of health distribution with one extreme(e.g. darkest not black or most transparent alpha value) on one end and the other on other end. It is best shown on image, I am currently unable do draw curved gradient only linear one - but I am sure your artists wont have any trouble: enter image description here Now, in shader sample both textures and threshold the mask value, discarding all the pixels which are not brighter than input threshold (based on health % shader input).
You could use mathematical formula for masking instead of a texture, but if you did that, you would be still very limited to shapes you are able(=simple ones) to create with said formulas - and finding one is not trivial.
*see comments

Source Link
wondra
  • 4.9k
  • 1
  • 22
  • 36

There is a very simple way achieving this with shaders, you need three textures: empty health bar, health bar texture and mask with gradient of health distribution with one extreme(e.g. darkest not black) on one end and the other on other end. It is best shown on image (I am currently unable do draw curved gradient only linear one, but I am sure your artists wont have any trouble): enter image description here Now, in shader sample both textures and threshold the mask value, discarding all the pixels which are not brighter than input threshold (based on health % shader input).
You could use mathematical formula for masking instead of a texture, but if you did that, you would be still very limited to shapes you are able(=simple ones) to create with said formulas - and finding one is not trivial.