Artoriuz / ArtCNN

Super-Resolution Convolutional Neural Networks as GLSL shaders for mpv
MIT License
109 stars 2 forks source link

unnecessary var #3

Closed hooke007 closed 7 months ago

hooke007 commented 7 months ago

https://github.com/Artoriuz/ArtCNN/blob/3bc920d6de1ccceddeea6c7f4cd327bd266e19c3/ArtCNN_C4F8.glsl#L460

You have defined ar_strength, why not use ar_strength instead here...

https://github.com/Artoriuz/ArtCNN/blob/3bc920d6de1ccceddeea6c7f4cd327bd266e19c3/ArtCNN_C4F16_SH.glsl#L1318

Artoriuz commented 7 months ago

If it works then sure =)

Edit: It doesn't work.

hooke007 commented 7 months ago

I mean, you can set ar_strength=0 on the fly to skip this part.

#define ANTIRING ar_strength

vec4 hook() {
    vec4 output_pix = vec4(0.0, 0.0, 0.0, 1.0);
    vec2 f0 = fract(conv2d_6_tf_pos * conv2d_6_tf_size);
    ivec2 i0 = ivec2(f0 * vec2(2.0));
    output_pix.x = conv2d_6_tf_tex((vec2(0.5) - f0) * conv2d_6_tf_pt + conv2d_6_tf_pos)[i0.y * 2 + i0.x];

#if (ANTIRING > 0)
    vec2 pp = LUMA_pos * LUMA_size - vec2(0.5);
    vec2 fp = floor(pp);

    vec2 pix_idx[4] = {{0.5, 0.5}, {1.5, 0.5},
                       {0.5, 1.5}, {1.5, 1.5}};

    float luma_pixels[4];

    for (int i = 0; i < 4; i++) {
        luma_pixels[i] = LUMA_tex(vec2((fp + pix_idx[i]) * LUMA_pt)).x;
    }

    float luma_min = min(min(min(luma_pixels[0], luma_pixels[1]), luma_pixels[2]), luma_pixels[3]);
    float luma_max = max(max(max(luma_pixels[0], luma_pixels[1]), luma_pixels[2]), luma_pixels[3]);

    output_pix.x = mix(output_pix.x, clamp(output_pix.x, luma_min, luma_max), ar_strength);
#endif

    return clamp(output_pix, 0.0, 1.0);
}
Artoriuz commented 7 months ago

This looks dangerous, to be honest I'll just remove the directive entirely as it at best saves you like 10us...

Artoriuz commented 7 months ago

In fact, I could remove the AR logic entirely and it wouldn't make that much of a difference. These models barely ring at all, the clipping is only there to stop it from overshooting line art.