mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Skip 5xBR based upscaling if output < (1.6 * input)
This commit is contained in:
parent
1b39c3cb17
commit
f71759020d
2 changed files with 20 additions and 7 deletions
|
@ -84,6 +84,12 @@ float c_df(vec3 c1, vec3 c2) {
|
|||
|
||||
void main() {
|
||||
|
||||
bool upscale = u_texelDelta.x > (1.6 * u_pixelDelta.x);
|
||||
vec3 res = texture2D(sampler0, v_texcoord0.xy).xyz;
|
||||
|
||||
// Let's skip the whole scaling if output size smaller than 1.6x of input size
|
||||
if (upscale) {
|
||||
|
||||
vec4 edri, edr, edr_l, edr_u, px; // px = pixel, edr = edge detection rule
|
||||
vec4 irlv0, irlv1, irlv2l, irlv2u;
|
||||
vec4 fx, fx_l, fx_u; // inequations of straight lines.
|
||||
|
@ -205,8 +211,8 @@ void main() {
|
|||
res2 = mix(res2, mix(F, B, px.y), maximos.y);
|
||||
res2 = mix(res2, mix(D, H, px.w), maximos.w);
|
||||
|
||||
vec3 res = mix(res1, res2, step(c_df(E, res1), c_df(E, res2)));
|
||||
|
||||
res = mix(res1, res2, step(c_df(E, res1), c_df(E, res2)));
|
||||
}
|
||||
gl_FragColor.xyz = res;
|
||||
gl_FragColor.a = 1.0;
|
||||
}
|
||||
|
|
|
@ -52,18 +52,25 @@ vec4 weighted_distance(vec4 a, vec4 b, vec4 c, vec4 d, vec4 e, vec4 f, vec4 g, v
|
|||
|
||||
|
||||
void main(){
|
||||
|
||||
bool upscale = u_texelDelta.x > (1.6 * u_pixelDelta.x);
|
||||
vec3 res = texture2D(sampler0, v_texcoord0.xy).xyz;
|
||||
|
||||
// Let's skip the whole scaling if output size smaller than 1.6x of input size
|
||||
if (upscale) {
|
||||
|
||||
bvec4 edr, edr_left, edr_up, px; // px = pixel, edr = edge detection rule
|
||||
bvec4 interp_restriction_lv1, interp_restriction_lv2_left, interp_restriction_lv2_up;
|
||||
bvec4 nc; // new_color
|
||||
bvec4 fx, fx_left, fx_up; // inequations of straight lines.
|
||||
|
||||
|
||||
vec2 pS = 1.0 / u_texelDelta.xy;
|
||||
vec2 fp = fract(v_texcoord0.xy*pS.xy);
|
||||
vec2 TexCoord_0 = v_texcoord0.xy-fp*u_pixelDelta.xy;
|
||||
vec2 dx = vec2(u_texelDelta.x,0.0);
|
||||
vec2 dy = vec2(0.0,u_texelDelta.y);
|
||||
vec2 y2 = dy + dy; vec2 x2 = dx + dx;
|
||||
|
||||
|
||||
vec3 A = texture2D(sampler0, TexCoord_0 -dx -dy ).xyz;
|
||||
vec3 B = texture2D(sampler0, TexCoord_0 -dy ).xyz;
|
||||
vec3 C = texture2D(sampler0, TexCoord_0 +dx -dy ).xyz;
|
||||
|
@ -111,7 +118,7 @@ void main(){
|
|||
edr = bvec4(vec4(lessThan(weighted_distance( e, c, g, i, h5, f4, h, f), weighted_distance( h, d, i5, f, i4, b, e, i)))*vec4(interp_restriction_lv1));
|
||||
edr_left = bvec4(vec4(lessThanEqual(coef*df(f,g),df(h,c)))*vec4(interp_restriction_lv2_left));
|
||||
edr_up = bvec4(vec4(greaterThanEqual(df(f,g),coef*df(h,c)))*vec4(interp_restriction_lv2_up));
|
||||
|
||||
|
||||
nc.x = ( edr.x && (fx.x || edr_left.x && fx_left.x || edr_up.x && fx_up.x) );
|
||||
nc.y = ( edr.y && (fx.y || edr_left.y && fx_left.y || edr_up.y && fx_up.y) );
|
||||
nc.z = ( edr.z && (fx.z || edr_left.z && fx_left.z || edr_up.z && fx_up.z) );
|
||||
|
@ -119,8 +126,8 @@ void main(){
|
|||
|
||||
px = lessThanEqual(df(e,f),df(e,h));
|
||||
|
||||
vec3 res = nc.x ? px.x ? F : H : nc.y ? px.y ? B : F : nc.z ? px.z ? D : B : nc.w ? px.w ? H : D : E;
|
||||
|
||||
res = nc.x ? px.x ? F : H : nc.y ? px.y ? B : F : nc.z ? px.z ? D : B : nc.w ? px.w ? H : D : E;
|
||||
}
|
||||
gl_FragColor.rgb = res;
|
||||
gl_FragColor.a = 1.0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue