From 37aba1bce27c2f322312dd01acac54a026fc89ce Mon Sep 17 00:00:00 2001 From: ame Date: Thu, 10 Oct 2024 02:02:43 -0500 Subject: fix non blended index --- render/fx_renderer/gles2/shaders/quad_grad.frag | 9 +++++++-- render/fx_renderer/gles2/shaders/quad_grad_round.frag | 13 +++++++++---- .../gles2/shaders/rounded_grad_border_corner.frag | 9 +++++++-- 3 files changed, 23 insertions(+), 8 deletions(-) (limited to 'render/fx_renderer/gles2/shaders') diff --git a/render/fx_renderer/gles2/shaders/quad_grad.frag b/render/fx_renderer/gles2/shaders/quad_grad.frag index d259942..a73975b 100644 --- a/render/fx_renderer/gles2/shaders/quad_grad.frag +++ b/render/fx_renderer/gles2/shaders/quad_grad.frag @@ -39,12 +39,17 @@ vec4 gradient(){ 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; - if(!blend) return colors[ind]; - 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)); diff --git a/render/fx_renderer/gles2/shaders/quad_grad_round.frag b/render/fx_renderer/gles2/shaders/quad_grad_round.frag index 58cdb53..66a54a6 100644 --- a/render/fx_renderer/gles2/shaders/quad_grad_round.frag +++ b/render/fx_renderer/gles2/shaders/quad_grad_round.frag @@ -28,7 +28,7 @@ uniform int count; vec4 gradient(){ float step; - vec2 normal = (gl_FragCoord.xy - grad_box)/grad_size; + vec2 normal = (gl_FragCoord.xy - grad_box)/size; vec2 uv = normal - origin; float rad = radians(degree); @@ -48,13 +48,18 @@ vec4 gradient(){ 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; - if(!blend) return colors[ind]; - - vec4 color = colors[ind]; + 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)); diff --git a/render/fx_renderer/gles2/shaders/rounded_grad_border_corner.frag b/render/fx_renderer/gles2/shaders/rounded_grad_border_corner.frag index ef36f06..85a6f79 100644 --- a/render/fx_renderer/gles2/shaders/rounded_grad_border_corner.frag +++ b/render/fx_renderer/gles2/shaders/rounded_grad_border_corner.frag @@ -44,12 +44,17 @@ vec4 gradient(){ 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; - if(!blend) return colors[ind]; - 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)); -- cgit v1.2.3