diff options
author | ame <[email protected]> | 2024-10-24 12:45:09 -0500 |
---|---|---|
committer | ame <[email protected]> | 2024-10-24 12:45:09 -0500 |
commit | 6fe9f31f55a291bf738c8b76b75190a4ac909df1 (patch) | |
tree | 3b12f99e96adc2691df3064e49ebd5df82694f5d /render/fx_renderer/gles2/shaders/quad_grad_round.frag | |
parent | 0e4a97e5a67d886e64c0d5337b281dc2c68332cf (diff) |
clean shaders and other formatting
Diffstat (limited to 'render/fx_renderer/gles2/shaders/quad_grad_round.frag')
-rw-r--r-- | render/fx_renderer/gles2/shaders/quad_grad_round.frag | 45 |
1 files changed, 2 insertions, 43 deletions
diff --git a/render/fx_renderer/gles2/shaders/quad_grad_round.frag b/render/fx_renderer/gles2/shaders/quad_grad_round.frag index 516573e..60e5fcf 100644 --- a/render/fx_renderer/gles2/shaders/quad_grad_round.frag +++ b/render/fx_renderer/gles2/shaders/quad_grad_round.frag @@ -25,48 +25,6 @@ uniform bool linear; uniform bool blend; uniform int count; -vec4 gradient(){ - float step; - - vec2 normal = (gl_FragCoord.xy - grad_box)/size; - vec2 uv = normal - origin; - - float rad = radians(degree); - - if(linear){ - uv *= vec2(1.0)/vec2(abs(cos(rad)) + abs(sin(rad))); - - vec2 rotated = vec2(uv.x * cos(rad) - uv.y * sin(rad) + origin.x, - uv.x * sin(rad) + uv.y * cos(rad) + origin.y); - - step = rotated.x; - } else { - vec2 uv = normal - origin; - uv = vec2(uv.x * cos(rad) - uv.y * sin(rad), - uv.x * sin(rad) + uv.y * cos(rad)); - - uv = vec2(-atan(uv.y, uv.x)/3.14159265 * 0.5 + 0.5, 0.0); - step = uv.x; - } - - if(!blend){ - float smooth = 1.0/float(count); - int ind = int(step/smooth); - - return colors[ind]; - } - - float smooth = 1.0/float(count - 1); - int ind = int(step/smooth); - float at = float(ind)*smooth; - - vec4 color = colors[ind]; - if(ind > 0) color = mix(colors[ind - 1], color, smoothstep(at - smooth, at, step)); - if(ind <= count - 1) color = mix(color, colors[ind + 1], smoothstep(at, at + smooth, step)); - - return color; -} - vec2 getCornerDist() { #if SOURCE == SOURCE_QUAD_ROUND vec2 half_size = size * 0.5; @@ -86,5 +44,6 @@ void main() { vec2 q = getCornerDist(); float dist = min(max(q.x,q.y), 0.0) + length(max(q, 0.0)) - radius; float smoothedAlpha = 1.0 - smoothstep(-1.0, 0.5, dist); - gl_FragColor = mix(vec4(0), gradient(), smoothedAlpha); + + gl_FragColor = mix(vec4(0), gradient(colors, count, size, grad_box, origin, degree, linear, blend), smoothedAlpha); } |