Warpsharp Shader?

4 months 4 weeks ago - 4 months 4 weeks ago #1 by bugmenot
Warpsharp Shader? was created by bugmenot
Is there anyone whe ants to re-create the famous avisynth WarpSharp Shader for Reshade. Or is there a similar shader already existing?

I think, that Warpsharp would be a great addition for upscaled images especially when the ingame render resolution is lower than the output resolution:The basic "warp sharp" algorithmWarp sharp is the name of an algorithm that I originally found coded as a filter for an image editing application called "The GIMP." It's based on the idea that if you can identify the edges in an image, you can warp the image to shrink the edges and thus make them appear sharper. I don't remember how the original code worked, but here's one way to implement such an algorithm:
  • Convert the original channel to grayscale.
  • Compute a gradient map from the grayscale image. For each pixel in the original image, the gradient map encodes a vector that indicates the direction and rate of fastest ascent in luminance. The usual way to do this is through a pair of edge detection filters that compute horizontal and vertical gradient. In a 3x3 window, subtracting (right-left) and (bottom-top) is one way to do this. Sobel filters are also popular:-1 0 +1 -1 -2 -1
    -2 0 +2 0 0 0
    -1 0 +1 +1 +2 +1

    (Both filters can be computed together in 10 adds; how this is done is left as an exercise to the reader.)
  • Convert the gradient map to a bump map by taking the length of each gradient vector.
  • Optionally, apply a blur to the bump map.
  • Compute a second gradient map from the bump map.
  • Use the gradient map as a displacement map for warping the original image — that is, you use a scaled version of the gradient vector at each pixel to perturb the sampling location in the original image. In other words, given a gradient (du, dv), you retrieve (u+du*k, v+dv*k) from the source, where k is usually set such that the displacement is under a single pixel. I usually use a cardinal bicubic interpolator for the warp.


Last edit: 4 months 4 weeks ago by bugmenot.

Please Log in or Create an account to join the conversation.

4 months 2 weeks ago - 4 months 2 weeks ago #2 by bugmenot
Replied by bugmenot on topic Warpsharp Shader?
I think this would be a great postprocessing alternative to FSR. Look at the edge of the nose. Warpsharp produces a completely sharp edge whereas other solutions suffer from blurred upscaling.
Last edit: 4 months 2 weeks ago by bugmenot.

Please Log in or Create an account to join the conversation.

1 month 1 week ago #3 by rj200
Replied by rj200 on topic Warpsharp Shader?
Hi, I thought that sounds intersting and not too complicated so I wrote one:


Let me know what you think.

Warp sharp is good for restoring clear edges (but not texture details) on images that have been blurred or upscaled.

It is not necessarily good for sharpening game output, as games have a mixture of very sharp edges of objects, and varying levels of blurrines in different textures. Warpsharp needs configuring with scale and strength and can't magically sharpen some areas and not others.

Please Log in or Create an account to join the conversation.

1 month 1 week ago #4 by Tojkar
Replied by Tojkar on topic Warpsharp Shader?

It is not necessarily good for sharpening game output...

This is pretty much useless for sharpening for it's ugly output but I found plenty of other uses for it. Awesome effect overall! Although I hope that you keep developing it a bit further, maybe adding  a bit more control over it or having a bit better quality sample matrix or that ever that scale thing is called.

Please Log in or Create an account to join the conversation.