Bilinear Interpolation for reshade

  • qdclonman
  • Topic Author
More
7 years 3 months ago - 7 years 3 months ago #1 by qdclonman Bilinear Interpolation for reshade was created by qdclonman
Hi everyone,I found Bilinear Interpolation shader code,but I can't make this working for reshade,anyone can made this?????
Code:
/*
Copyright (c) 2013 James Slepicka

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

Texture2D tex;

SamplerState sam_linear
{
Filter = MIN_MAG_MIP_LINEAR;
AddressU = Clamp;
AddressV = Clamp;
};

matrix world;
matrix view;
matrix proj;

float2 tex_size;
float2 input_size;
float2 output_size;
float sharpness = 1.0;

struct VS_INPUT
{
float4 pos : POSITION;
float2 tex : TEXCOORD0;
};

struct PS_INPUT
{
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
};

PS_INPUT VS (VS_INPUT input)
{
PS_INPUT output = (PS_INPUT)0;
output.pos = mul (input.pos, world);
output.pos = mul (output.pos, view);
output.pos = mul (output.pos, proj);
output.tex = input.tex;
return output;
}

float4 PS (PS_INPUT input) : SV_Target
{
float2 scale = output_size / input_size;
float2 interp = saturate((scale - lerp(scale, 1.0, sharpness))/(scale * 2.0));
float2 p = input.tex.xy * tex_size + .5;
float2 i = floor(p);
float2 f = p - i;
f = saturate((f - interp) / (1.0 - interp * 2.0));
p = ((i + f) - .5) / tex_size;
float4 r = tex.Sample(sam_linear, p);
r.a = 1.0;
return r;
}

technique10 render
{
pass P0
{
SetVertexShader(CompileShader(vs_4_0, VS()));
SetGeometryShader(NULL);
SetPixelShader(CompileShader(ps_4_0, PS()));
}
}
Last edit: 7 years 3 months ago by qdclonman.

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

  • qdclonman
  • Topic Author
More
7 years 3 months ago #2 by qdclonman Replied by qdclonman on topic Bilinear Interpolation for reshade
UP

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

  • Marty McFly
More
7 years 3 months ago - 7 years 3 months ago #3 by Marty McFly Replied by Marty McFly on topic Bilinear Interpolation for reshade
Bilinear interpolation is hardware supported, no need for any custom shadercode. It's what ReShade does when sampling any texture, if specified in the sampler. There is no use of this code as is, it just modifies the default algorithm slightly. For any application where e.g. the quality of an upscaled image is important, one uses bicubic or other functions.
Last edit: 7 years 3 months ago by Marty McFly.

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

  • Eleventeen
More
1 year 9 months ago #4 by Eleventeen Replied by Eleventeen on topic Bilinear Interpolation for reshade
Uhh yes GPUs can do it.. But no, it's not "supported" in almost any game like reshade is.

In most older games, and plenty of modern ones, you get what the developer gives you.

Even if you delve deep into the nvidia inspector profiles, you get TONS of options to effect 3D games.. But zero to add bilinear filters to 2D games. It's just not something nvidia implemented as an option (and pretty sure amd/intel too).

And devs that use that absolute basic windows defaults, they get nearest neighbour scaling, not bilinear interpolation.

There is also a difference in how lower rez images are stretched, and how they are filtered. With stretch algorithms like nearest vs smoothsal x2, xBRZ, etc. And interpolation filters like bilinear or other similar techniques.

I know reshade isn't designed for resizing/stretching windows - But the equivalent effect can be faked with a shader.

So yea I'd love to see that one get translated to the latest reshade.. Or someone point out an equivalent.

I found plenty that remove bilinear filters that devs force on in many modern 2D games.. But i dunno which one is best for the reverse of that.

(and for my preference, depends highly on the game/artstyle which I prefer, so would be nice to have access to both)

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

We use cookies
We use cookies on our website. Some of them are essential for the operation of the forum. You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.