summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorame <[email protected]>2024-10-10 02:02:43 -0500
committerame <[email protected]>2024-10-10 02:02:43 -0500
commit37aba1bce27c2f322312dd01acac54a026fc89ce (patch)
tree579134aa6c9cf2e71f10bc74cc72fd0d2de5a7f7
parent6094bf78c30f9b636844825e208a601019bec589 (diff)
fix non blended index
-rw-r--r--render/fx_renderer/gles2/shaders/quad_grad.frag9
-rw-r--r--render/fx_renderer/gles2/shaders/quad_grad_round.frag13
-rw-r--r--render/fx_renderer/gles2/shaders/rounded_grad_border_corner.frag9
-rw-r--r--render/fx_renderer/shaders.c6
4 files changed, 29 insertions, 8 deletions
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));
diff --git a/render/fx_renderer/shaders.c b/render/fx_renderer/shaders.c
index 0e2c43b..21cd522 100644
--- a/render/fx_renderer/shaders.c
+++ b/render/fx_renderer/shaders.c
@@ -29,6 +29,12 @@ GLuint compile_shader(GLuint type, const GLchar *src) {
glGetShaderiv(shader, GL_COMPILE_STATUS, &ok);
if (ok == GL_FALSE) {
wlr_log(WLR_ERROR, "Failed to compile shader");
+ GLint maxLength = 0;
+ glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &maxLength);
+
+ char a[maxLength];
+ glGetShaderInfoLog(shader, maxLength, &maxLength, a);
+ printf("%s\n", a);
glDeleteShader(shader);
shader = 0;
}