mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-14 07:45:06 +00:00
gs-mipmapper: Add mip level and remove bilinear from effect
This commit is contained in:
parent
ff8618c339
commit
3f3cbb8939
1 changed files with 21 additions and 40 deletions
|
@ -1,5 +1,6 @@
|
||||||
uniform float4x4 ViewProj;
|
uniform float4x4 ViewProj;
|
||||||
uniform texture2d image;
|
uniform texture2d image;
|
||||||
|
uniform int level;
|
||||||
uniform float2 imageTexel;
|
uniform float2 imageTexel;
|
||||||
uniform float strength;
|
uniform float strength;
|
||||||
|
|
||||||
|
@ -15,12 +16,6 @@ sampler_state linearSampler {
|
||||||
AddressV = Clamp;
|
AddressV = Clamp;
|
||||||
};
|
};
|
||||||
|
|
||||||
sampler_state bilinearSampler {
|
|
||||||
Filter = Bilinear;
|
|
||||||
AddressU = Clamp;
|
|
||||||
AddressV = Clamp;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct VertDataIn {
|
struct VertDataIn {
|
||||||
float4 pos : POSITION;
|
float4 pos : POSITION;
|
||||||
float2 uv : TEXCOORD0;
|
float2 uv : TEXCOORD0;
|
||||||
|
@ -41,17 +36,12 @@ VertDataOut VSDefault(VertDataIn v_in)
|
||||||
|
|
||||||
float4 PSPoint(VertDataOut v_in) : TARGET
|
float4 PSPoint(VertDataOut v_in) : TARGET
|
||||||
{
|
{
|
||||||
return image.Sample(pointSampler, v_in.uv);
|
return image.SampleLevel(pointSampler, v_in.uv, level);
|
||||||
}
|
}
|
||||||
|
|
||||||
float4 PSLinear(VertDataOut v_in) : TARGET
|
float4 PSLinear(VertDataOut v_in) : TARGET
|
||||||
{
|
{
|
||||||
return image.Sample(linearSampler, v_in.uv);
|
return image.SampleLevel(linearSampler, v_in.uv, level);
|
||||||
}
|
|
||||||
|
|
||||||
float4 PSBilinear(VertDataOut v_in) : TARGET
|
|
||||||
{
|
|
||||||
return image.Sample(bilinearSampler, v_in.uv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float4 PSSharpen(VertDataOut v_in) : TARGET
|
float4 PSSharpen(VertDataOut v_in) : TARGET
|
||||||
|
@ -67,15 +57,15 @@ float4 PSSharpen(VertDataOut v_in) : TARGET
|
||||||
r = -l;
|
r = -l;
|
||||||
|
|
||||||
float4 tl, tc, tr, cl, cc, cr, bl, bc, br;
|
float4 tl, tc, tr, cl, cc, cr, bl, bc, br;
|
||||||
tl = image.Sample(pointSampler, v_in.uv + ul);
|
tl = image.SampleLevel(pointSampler, v_in.uv + ul, level);
|
||||||
tc = image.Sample(pointSampler, v_in.uv + u);
|
tc = image.SampleLevel(pointSampler, v_in.uv + u, level);
|
||||||
tr = image.Sample(pointSampler, v_in.uv + ur);
|
tr = image.SampleLevel(pointSampler, v_in.uv + ur, level);
|
||||||
cl = image.Sample(pointSampler, v_in.uv + l);
|
cl = image.SampleLevel(pointSampler, v_in.uv + l, level);
|
||||||
cc = image.Sample(pointSampler, v_in.uv);
|
cc = image.SampleLevel(pointSampler, v_in.uv, level);
|
||||||
cr = image.Sample(pointSampler, v_in.uv + r);
|
cr = image.SampleLevel(pointSampler, v_in.uv + r, level);
|
||||||
bl = image.Sample(pointSampler, v_in.uv + dl);
|
bl = image.SampleLevel(pointSampler, v_in.uv + dl, level);
|
||||||
bc = image.Sample(pointSampler, v_in.uv + d);
|
bc = image.SampleLevel(pointSampler, v_in.uv + d, level);
|
||||||
br = image.Sample(pointSampler, v_in.uv + dr);
|
br = image.SampleLevel(pointSampler, v_in.uv + dr, level);
|
||||||
|
|
||||||
float kernel1, kernel2, kernel3;
|
float kernel1, kernel2, kernel3;
|
||||||
kernel1 = -0.25 * strength;
|
kernel1 = -0.25 * strength;
|
||||||
|
@ -104,15 +94,15 @@ float4 PSSmoothen(VertDataOut v_in) : TARGET
|
||||||
l = float2(-imageTexel.x, 0);
|
l = float2(-imageTexel.x, 0);
|
||||||
r = -l;
|
r = -l;
|
||||||
|
|
||||||
tl = image.Sample(pointSampler, v_in.uv + ul) * smoothKernel3[0];
|
tl = image.SampleLevel(pointSampler, v_in.uv + ul, level) * smoothKernel3[0];
|
||||||
tc = image.Sample(pointSampler, v_in.uv + u) * smoothKernel3[1];
|
tc = image.SampleLevel(pointSampler, v_in.uv + u, level) * smoothKernel3[1];
|
||||||
tr = image.Sample(pointSampler, v_in.uv + ur) * smoothKernel3[0];
|
tr = image.SampleLevel(pointSampler, v_in.uv + ur, level) * smoothKernel3[0];
|
||||||
cl = image.Sample(pointSampler, v_in.uv + l) * smoothKernel3[1];
|
cl = image.SampleLevel(pointSampler, v_in.uv + l, level) * smoothKernel3[1];
|
||||||
cc = image.Sample(pointSampler, v_in.uv) * smoothKernel3[2];
|
cc = image.SampleLevel(pointSampler, v_in.uv, level) * smoothKernel3[2];
|
||||||
cr = image.Sample(pointSampler, v_in.uv + r) * smoothKernel3[1];
|
cr = image.SampleLevel(pointSampler, v_in.uv + r, level) * smoothKernel3[1];
|
||||||
bl = image.Sample(pointSampler, v_in.uv + dl) * smoothKernel3[0];
|
bl = image.SampleLevel(pointSampler, v_in.uv + dl, level) * smoothKernel3[0];
|
||||||
bc = image.Sample(pointSampler, v_in.uv + d) * smoothKernel3[1];
|
bc = image.SampleLevel(pointSampler, v_in.uv + d, level) * smoothKernel3[1];
|
||||||
br = image.Sample(pointSampler, v_in.uv + dr) * smoothKernel3[0];
|
br = image.SampleLevel(pointSampler, v_in.uv + dr, level) * smoothKernel3[0];
|
||||||
|
|
||||||
return tl + tc + tr + cl + cc + cr + bl + bc + br;
|
return tl + tc + tr + cl + cc + cr + bl + bc + br;
|
||||||
}
|
}
|
||||||
|
@ -145,15 +135,6 @@ technique Linear
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
technique Bilinear
|
|
||||||
{
|
|
||||||
pass
|
|
||||||
{
|
|
||||||
vertex_shader = VSDefault(v_in);
|
|
||||||
pixel_shader = PSBilinear(v_in);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
technique Sharpen
|
technique Sharpen
|
||||||
{
|
{
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in a new issue