I’m trying to write a shader that alters the alpha of vertices in a progressive circle around it. Imagine a circular sprite, where at one point on the outside is the color red, and the point opposite it is white, with a gradient of color between. I don’t believe my attempt is inherently wrong… but regardless of the amount of tweaking, I can’t seem to get it to work how I’d like. Here’s the vertex shader:
(note, _Center is a property being updated by the owning object to its transform.position)
Thought one is that the result from a sqrt is always positive, so the abs is not needed in the magnitude calculation.
Thought two is that distance.x * distance.x + distance.y * distance.y can better be written as dot(distance.xy, distance.xy).
Thought three is that clamp(v, 0, 1) can better be written as saturate(v).
Thought four is that I’d like to see the current result and what you intend the result to be. It’s probably in the sin(_Time+theta+distance) part where it differs.
@jvo3dc : Thanks for the optimization suggestions! I need to hit the docs to see what vector.xy and saturate() do, but I trust that they’ll work.
Unfortunately I can’t record a .gif right now, but the intended result is for every vert to have a separate, incrementing time step where the alpha is high. The surface shader uses this after the fact to change the color. I made a couple of modifications to the code that seem to have gotten me close to the desired effect:
On one sprite, it almost looks like the effect I’m going for, but on a separate sprite of the same size, the effect starts at the top all the way across and moves down.
After a lot of fucking around with this shader and getting nowhere, I tried a different approach from a different shader base. I got it to work the way that I wanted it to, but I still don’t understand why the previous one didn’t work the way I thought it should.