by Christopher King
A tool to help create channel packed textures for use in shader animation
Building upon my
last blog post
, I want to take the textures that I generated previously
and create an effect that would look like blood flowing out
from the center.
This scene from Hellboy is exactly what I'm going for:
A simple solution to get the make the image appear radially
would be to use the pixel's distance from the center of the image in the fragment shader.
But by doing this, it would be impossible to gradually render an arc that is
equidistant from the center like we see in the video above.
So what I really want to do is precalculate a breadth first search
on the image from an arbitrary starting position
using a heuristic where the cost is the inverse of the image's alpha.
Put more simply, I want to select a spot on the image from where the
liquid will flow out from, and I want to prioritize flowing to opaque areas
of the image before filling transparent areas.
1048576 total unique positions for a 1024px by 1024px image, and with 24 bits of precision we get a max value of 16,777,216. So that is plenty of space