summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorWill McKinnon <[email protected]>2022-10-26 02:48:49 -0400
committerWill McKinnon <[email protected]>2022-10-26 02:48:49 -0400
commiteddbde479c9c93b8707d01dffb2e6a41fc451f29 (patch)
treea9b33cce73e4e5fc568f5b50cab6a22dcf5b8437 /include
parented130cdacce66ed2ae4f9e44bb4ae894beefceca (diff)
style: cleaned up some frag shaders
Diffstat (limited to 'include')
-rw-r--r--include/sway/desktop/fx_renderer.h3
-rw-r--r--include/sway/desktop/shaders.h24
2 files changed, 12 insertions, 15 deletions
diff --git a/include/sway/desktop/fx_renderer.h b/include/sway/desktop/fx_renderer.h
index 39c1a25b..889d8a82 100644
--- a/include/sway/desktop/fx_renderer.h
+++ b/include/sway/desktop/fx_renderer.h
@@ -13,8 +13,7 @@ struct gles2_tex_shader {
GLint alpha;
GLint pos_attrib;
GLint tex_attrib;
- GLint width;
- GLint height;
+ GLint size;
GLint position;
GLint radius;
};
diff --git a/include/sway/desktop/shaders.h b/include/sway/desktop/shaders.h
index 4ff9ca42..6a9f8863 100644
--- a/include/sway/desktop/shaders.h
+++ b/include/sway/desktop/shaders.h
@@ -45,16 +45,15 @@ const GLchar tex_fragment_src_rgba[] =
"uniform sampler2D tex;\n"
"uniform float alpha;\n"
"\n"
-"uniform float width;\n"
-"uniform float height;\n"
+"uniform vec2 size;\n"
"uniform vec2 position;\n"
"uniform float radius;\n"
"\n"
"void main() {\n"
" gl_FragColor = texture2D(tex, v_texcoord) * alpha;\n"
-" vec2 corner_distance = min(gl_FragCoord.xy - position, position + vec2(width, height) - gl_FragCoord.xy);\n"
+" vec2 corner_distance = min(gl_FragCoord.xy - position, size + position - gl_FragCoord.xy);\n"
" if (max(corner_distance.x, corner_distance.y) < radius) {\n"
-" float d = radius - distance(corner_distance, vec2(radius, radius));\n"
+" float d = radius - distance(corner_distance, vec2(radius));\n"
" float smooth = smoothstep(-1.0f, 0.5f, d);\n"
" gl_FragColor = mix(vec4(0), gl_FragColor, smooth);\n"
" }\n"
@@ -66,38 +65,37 @@ const GLchar tex_fragment_src_rgbx[] =
"uniform sampler2D tex;\n"
"uniform float alpha;\n"
"\n"
-"uniform float width;\n"
-"uniform float height;\n"
+"uniform vec2 size;\n"
"uniform vec2 position;\n"
"uniform float radius;\n"
"\n"
"void main() {\n"
" gl_FragColor = vec4(texture2D(tex, v_texcoord).rgb, 1.0) * alpha;\n"
-" vec2 corner_distance = min(gl_FragCoord.xy - position, position + vec2(width, height) - gl_FragCoord.xy);\n"
+" vec2 corner_distance = min(gl_FragCoord.xy - position, position + size - gl_FragCoord.xy);\n"
" if (max(corner_distance.x, corner_distance.y) < radius) {\n"
-" float d = radius - distance(corner_distance, vec2(radius, radius));\n"
+" float d = radius - distance(corner_distance, vec2(radius));\n"
" float smooth = smoothstep(-1.0f, 0.5f, d);\n"
" gl_FragColor = mix(vec4(0), gl_FragColor, smooth);\n"
" }\n"
"}\n";
const GLchar tex_fragment_src_external[] =
-"#extension GL_OES_EGL_image_external : require\n\n"
+"#extension GL_OES_EGL_image_external : require\n"
+"\n"
"precision mediump float;\n"
"varying vec2 v_texcoord;\n"
"uniform samplerExternalOES texture0;\n"
"uniform float alpha;\n"
"\n"
-"uniform float width;\n"
-"uniform float height;\n"
+"uniform vec2 size;\n"
"uniform vec2 position;\n"
"uniform float radius;\n"
"\n"
"void main() {\n"
" gl_FragColor = texture2D(texture0, v_texcoord) * alpha;\n"
-" vec2 corner_distance = min(gl_FragCoord.xy - position, position + vec2(width, height) - gl_FragCoord.xy);\n"
+" vec2 corner_distance = min(gl_FragCoord.xy - position, position + size - gl_FragCoord.xy);\n"
" if (max(corner_distance.x, corner_distance.y) < radius) {\n"
-" float d = radius - distance(corner_distance, vec2(radius, radius));\n"
+" float d = radius - distance(corner_distance, vec2(radius));\n"
" float smooth = smoothstep(-1.0f, 0.5f, d);\n"
" gl_FragColor = mix(vec4(0), gl_FragColor, smooth);\n"
" }\n"