mirror of
https://github.com/swaywm/sway.git
synced 2026-04-21 06:46:22 -04:00
style: cleaned up some frag shaders
This commit is contained in:
parent
ed130cdacc
commit
eddbde479c
3 changed files with 14 additions and 19 deletions
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue