style: cleaned up some frag shaders
This commit is contained in:
parent
ed130cdacc
commit
eddbde479c
|
@ -13,8 +13,7 @@ struct gles2_tex_shader {
|
||||||
GLint alpha;
|
GLint alpha;
|
||||||
GLint pos_attrib;
|
GLint pos_attrib;
|
||||||
GLint tex_attrib;
|
GLint tex_attrib;
|
||||||
GLint width;
|
GLint size;
|
||||||
GLint height;
|
|
||||||
GLint position;
|
GLint position;
|
||||||
GLint radius;
|
GLint radius;
|
||||||
};
|
};
|
||||||
|
|
|
@ -45,16 +45,15 @@ const GLchar tex_fragment_src_rgba[] =
|
||||||
"uniform sampler2D tex;\n"
|
"uniform sampler2D tex;\n"
|
||||||
"uniform float alpha;\n"
|
"uniform float alpha;\n"
|
||||||
"\n"
|
"\n"
|
||||||
"uniform float width;\n"
|
"uniform vec2 size;\n"
|
||||||
"uniform float height;\n"
|
|
||||||
"uniform vec2 position;\n"
|
"uniform vec2 position;\n"
|
||||||
"uniform float radius;\n"
|
"uniform float radius;\n"
|
||||||
"\n"
|
"\n"
|
||||||
"void main() {\n"
|
"void main() {\n"
|
||||||
" gl_FragColor = texture2D(tex, v_texcoord) * alpha;\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"
|
" 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"
|
" float smooth = smoothstep(-1.0f, 0.5f, d);\n"
|
||||||
" gl_FragColor = mix(vec4(0), gl_FragColor, smooth);\n"
|
" gl_FragColor = mix(vec4(0), gl_FragColor, smooth);\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
|
@ -66,38 +65,37 @@ const GLchar tex_fragment_src_rgbx[] =
|
||||||
"uniform sampler2D tex;\n"
|
"uniform sampler2D tex;\n"
|
||||||
"uniform float alpha;\n"
|
"uniform float alpha;\n"
|
||||||
"\n"
|
"\n"
|
||||||
"uniform float width;\n"
|
"uniform vec2 size;\n"
|
||||||
"uniform float height;\n"
|
|
||||||
"uniform vec2 position;\n"
|
"uniform vec2 position;\n"
|
||||||
"uniform float radius;\n"
|
"uniform float radius;\n"
|
||||||
"\n"
|
"\n"
|
||||||
"void main() {\n"
|
"void main() {\n"
|
||||||
" gl_FragColor = vec4(texture2D(tex, v_texcoord).rgb, 1.0) * alpha;\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"
|
" 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"
|
" float smooth = smoothstep(-1.0f, 0.5f, d);\n"
|
||||||
" gl_FragColor = mix(vec4(0), gl_FragColor, smooth);\n"
|
" gl_FragColor = mix(vec4(0), gl_FragColor, smooth);\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
const GLchar tex_fragment_src_external[] =
|
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"
|
"precision mediump float;\n"
|
||||||
"varying vec2 v_texcoord;\n"
|
"varying vec2 v_texcoord;\n"
|
||||||
"uniform samplerExternalOES texture0;\n"
|
"uniform samplerExternalOES texture0;\n"
|
||||||
"uniform float alpha;\n"
|
"uniform float alpha;\n"
|
||||||
"\n"
|
"\n"
|
||||||
"uniform float width;\n"
|
"uniform vec2 size;\n"
|
||||||
"uniform float height;\n"
|
|
||||||
"uniform vec2 position;\n"
|
"uniform vec2 position;\n"
|
||||||
"uniform float radius;\n"
|
"uniform float radius;\n"
|
||||||
"\n"
|
"\n"
|
||||||
"void main() {\n"
|
"void main() {\n"
|
||||||
" gl_FragColor = texture2D(texture0, v_texcoord) * alpha;\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"
|
" 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"
|
" float smooth = smoothstep(-1.0f, 0.5f, d);\n"
|
||||||
" gl_FragColor = mix(vec4(0), gl_FragColor, smooth);\n"
|
" gl_FragColor = mix(vec4(0), gl_FragColor, smooth);\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
|
|
|
@ -86,8 +86,7 @@ bool init_frag_shader(struct gles2_tex_shader *shader, GLuint prog) {
|
||||||
shader->alpha = glGetUniformLocation(prog, "alpha");
|
shader->alpha = glGetUniformLocation(prog, "alpha");
|
||||||
shader->pos_attrib = glGetAttribLocation(prog, "pos");
|
shader->pos_attrib = glGetAttribLocation(prog, "pos");
|
||||||
shader->tex_attrib = glGetAttribLocation(prog, "texcoord");
|
shader->tex_attrib = glGetAttribLocation(prog, "texcoord");
|
||||||
shader->width = glGetUniformLocation(prog, "width");
|
shader->size = glGetUniformLocation(prog, "size");
|
||||||
shader->height = glGetUniformLocation(prog, "height");
|
|
||||||
shader->position = glGetUniformLocation(prog, "position");
|
shader->position = glGetUniformLocation(prog, "position");
|
||||||
shader->radius = glGetUniformLocation(prog, "radius");
|
shader->radius = glGetUniformLocation(prog, "radius");
|
||||||
return true;
|
return true;
|
||||||
|
@ -277,8 +276,7 @@ bool fx_render_subtexture_with_matrix(struct fx_renderer *renderer, struct wlr_t
|
||||||
glUniform1f(shader->alpha, alpha);
|
glUniform1f(shader->alpha, alpha);
|
||||||
|
|
||||||
// rounded corners
|
// rounded corners
|
||||||
glUniform1f(shader->width, dst_box->width);
|
glUniform2f(shader->size, dst_box->width, dst_box->height);
|
||||||
glUniform1f(shader->height, dst_box->height);
|
|
||||||
glUniform2f(shader->position, dst_box->x, dst_box->y);
|
glUniform2f(shader->position, dst_box->x, dst_box->y);
|
||||||
glUniform1f(shader->radius, radius);
|
glUniform1f(shader->radius, radius);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue