Edge Smoothing
- Duran.te
- Topic Author
I was wondering if someone could make an edge softening shader, like a gaussian blur filter limited to the edges.
I'm not a fan of rough edges. it feels like smooth edges seems to give more cinematic look to the scene.
Not to mention all those games that uses too aggressive sharpening filters, causing ringing artifacts around the edges:
I applied gaussian blur to the whole image and then I made a mask using with the photoshop's "find edges" filter, so that the textures (especially the snow and the threes, in this case) are not affected by the blurriness.
Also, the subtle ringing artifact is gone.
[hr]I know that Reshade's FXAA filter could be a solution, but the problem is that it messes with already anti-aliased images:
(In-game TAA is on)
Please Log in or Create an account to join the conversation.
- brussell
Here's a comparison (left: original, middle: less sharpness for bright pixels, right: standard sharpness)
Of course due to the uneven sharpening some details can look slightly odd (text etc.), but imo it can achive better results than by just clamping the unsharp mask.
Maybe I will post the code here soon. Although it may lack context, here is the important line:
fine *= (1-saturate(pow(abs(color.xyz), 1 / (fSharpen_DynamicCurve + 0.001))));
Please Log in or Create an account to join the conversation.
Created sharpening filter that addresses just that issue using depth high-pass mask and it's already in default repository under FilmicAnamorphSharpen.fx
Depth pass is required for it to work, but you can also try using "Sharpen clamping" setting without depth pass to reduce halos.
If you're looking for more performance-wise version without depth masking, visit my Shaders repository (link under my profile information at the bootom of this post), look for FilmicSharpen.fx
Please Log in or Create an account to join the conversation.
- Duran.te
- Topic Author
Please Log in or Create an account to join the conversation.
- Duran.te
- Topic Author
Topic updated, added reference shots.
Could someone help this case?
Please Log in or Create an account to join the conversation.
- jas01
Please Log in or Create an account to join the conversation.
- Duran.te
- Topic Author
It would also be nice if values like intensity and radius could be controlled with dedicated sliders, rather than just the threshold one.
Thanks for help, anyway.
Please Log in or Create an account to join the conversation.
- Insomnia
Please Log in or Create an account to join the conversation.
- Dom324
Please Log in or Create an account to join the conversation.
- S3r1ous
oh and i use Deband to smooth out some of those banding problems, you can see it really well in the skies in some games
Please Log in or Create an account to join the conversation.
- Duran.te
- Topic Author
You'll find it on PirateKitty's GitHub repository: github.com/Heathen/Pirate-Shaders
Please Log in or Create an account to join the conversation.
- j4712
/**
* Smooth Edges
* by Jakob W. ~ j4712
* made for Duran.te
* NOT FINISHED JUST A CONCEPT FOR NOT USING DEPTH FOR THIS TASK WITHOUT DESTROYING INGAME AA
*/
#include "ReShade.fxh"
#include "ReShadeUI.fxh"
texture TexColorBuffer : COLOR;
sampler SamplerColor
{
Texture = TexColorBuffer;
AddressU = MIRROR;
AddressV = MIRROR;
};
texture blurredColor
{
Width = BUFFER_WIDTH;
Height = BUFFER_HEIGHT;
};
texture edgesTex
{
Width = BUFFER_WIDTH;
Height = BUFFER_HEIGHT;
};
sampler blurredSampler
{
Texture = blurredColor;
};
sampler edgesSampler
{
Texture = edgesTex;
};
float rgbLuma(float3 color)
{
return float3( color.r * 0.2126, color.g * 0.7152, color.b * 0.0722);
}
float3 BlurringPass(float4 vpos : SV_Position, float2 texcoord : TexCoord) : SV_Target
{
float kernel[9] = { 1, 2, 1,
2, 4, 2,
1, 2, 1 };
float3 color = float3(0.f,0.f,0.f);
int kernalSumm = 0;
for (int y = 0; y < 3; y++)
{
for (int x = 0; x < 3; x++)
{
int index = y * 3 + x;
float3 pixelColor = tex2D(ReShade::BackBuffer, texcoord + (float2(x-1, y-1) * ReShade::PixelSize)).rgb;
color += pixelColor * kernel[index];
kernalSumm += kernel[index];
}
}
color /= kernalSumm;
return color;
}
float3 DetectSobelPass(float4 vpos : SV_Position, float2 texcoord : TexCoord) : SV_Target
{
float kernel_x[9] = { -1.f, 0.f, 1.f,
-2.f, 0.f, 2.f,
-1.f, 0.f, 1.f };
float kernel_y[9] = { 1.f, 2.f, 1.f,
0.f, 0.f, 0.f,
-1.f, -2.f, -1.f };
float3 color = float3(0.f, 0.f, 0.f);
float edge_x = 0.f;
float edge_y = 0.f;
float kernelSumm_x = -1.f;
float kernelSumm_y = -1.f;
for (int y = 0; y < 3; y++)
{
for (int x = 0; x < 3; x++)
{
int index = y * 3 + x;
float brightness = rgbLuma(tex2D(blurredSampler, texcoord + (float2(x-1, y-1) * ReShade::PixelSize)).rgb);
edge_x += (brightness * kernel_x[index]);
edge_y += (brightness * kernel_y[index]);
kernelSumm_x += kernel_x[index];
kernelSumm_y += kernel_y[index];
}
}
edge_x = ((edge_x / kernelSumm_x) / 2.f);
edge_y = ((edge_y / kernelSumm_y) / 2.f);
color.r = edge_x;
color.g = edge_y;
return sqrt((color.r * color.r) + (color.g * color.g));
}
float3 EffectPass(float4 vpos : SV_Position, float2 texcoord : TexCoord) : SV_Target
{
float3 oColor = tex2D(SamplerColor, texcoord).rgb;
float3 bColor = tex2D(blurredSampler, texcoord).rgb;
float edgeStrength = 0;
float kernel[9] = { 1, 2, 1,
2, 4, 2,
1, 2, 1 };
int kernalSumm = 0;
for (int y = 0; y < 3; y++)
{
for (int x = 0; x < 3; x++)
{
int index = y * 3 + x;
edgeStrength += tex2D(edgesSampler, texcoord + (float2(x-1, y-1) * ReShade::PixelSize)).r * kernel[index];
kernalSumm += kernel[index];
}
}
edgeStrength /= kernalSumm;
if (edgeStrength < 0.075)
edgeStrength = 0;
edgeStrength = saturate(edgeStrength * 5);
return lerp(oColor, bColor, edgeStrength);
}
technique SoftEdges
{
pass BlurPass
{
VertexShader = PostProcessVS;
PixelShader = BlurringPass;
RenderTarget = blurredColor;
}
pass DetectSobel
{
VertexShader = PostProcessVS;
PixelShader = DetectSobelPass;
RenderTarget = edgesTex;
}
pass Effect
{
VertexShader = PostProcessVS;
PixelShader = EffectPass;
}
}
Please Log in or Create an account to join the conversation.
- Duran.te
- Topic Author
I'd almost given up hope of seeing a custom shader made just for this.
A depth+color detection version with adjustable settings for stuff like threshold, radius and intensity would be so awesome, but I don't want to pressure you about that.
Thanks a lot man, you rock
Please Log in or Create an account to join the conversation.
- prod80
github.com/prod80/prod80-ReShade-Repository
Please Log in or Create an account to join the conversation.