mirror of
https://github.com/italicsjenga/slang-shaders.git
synced 2024-11-26 01:11:32 +11:00
Add Anti-Ringing to spline16 and spline36
- Add a very good anti-ringing code to spline16 and spline36 shaders; - It works best with spline16. - it's ON by default and can be disabled through realtime shader parameter.
This commit is contained in:
parent
cfe2bc9ecf
commit
8766bbc0bf
|
@ -39,8 +39,13 @@ layout(push_constant) uniform Push
|
|||
vec4 OriginalSize;
|
||||
vec4 OutputSize;
|
||||
uint FrameCount;
|
||||
float S16_ANTI_RINGING;
|
||||
} params;
|
||||
|
||||
#pragma parameter S16_ANTI_RINGING "Spline16 Anti-Ringing [ OFF | ON ]" 1.0 0.0 1.0 1.0
|
||||
|
||||
#define S16_ANTI_RINGING params.S16_ANTI_RINGING
|
||||
|
||||
layout(std140, set = 0, binding = 0) uniform UBO
|
||||
{
|
||||
mat4 MVP;
|
||||
|
@ -121,5 +126,15 @@ void main()
|
|||
|
||||
vec3 color = mat4x3( C0, C1, C2, C3 ) * w;
|
||||
|
||||
// Anti-ringing
|
||||
if (S16_ANTI_RINGING == 1.0)
|
||||
{
|
||||
vec3 aux = color;
|
||||
vec3 min_sample = min(min(C0, C1), min(C2, C3));
|
||||
vec3 max_sample = max(max(C0, C1), max(C2, C3));
|
||||
color = clamp(color, min_sample, max_sample);
|
||||
color = mix(aux, color, step(0.0, (C0-C1)*(C2-C3)));
|
||||
}
|
||||
|
||||
FragColor = vec4(color, 1.0);
|
||||
}
|
||||
|
|
|
@ -39,8 +39,13 @@ layout(push_constant) uniform Push
|
|||
vec4 OriginalSize;
|
||||
vec4 OutputSize;
|
||||
uint FrameCount;
|
||||
float S16_ANTI_RINGING;
|
||||
} params;
|
||||
|
||||
#pragma parameter S16_ANTI_RINGING "Spline16 Anti-Ringing [ OFF | ON ]" 1.0 0.0 1.0 1.0
|
||||
|
||||
#define S16_ANTI_RINGING params.S16_ANTI_RINGING
|
||||
|
||||
layout(std140, set = 0, binding = 0) uniform UBO
|
||||
{
|
||||
mat4 MVP;
|
||||
|
@ -121,5 +126,15 @@ void main()
|
|||
|
||||
vec3 color = mat4x3( C0, C1, C2, C3 ) * w;
|
||||
|
||||
// Anti-ringing
|
||||
if (S16_ANTI_RINGING == 1.0)
|
||||
{
|
||||
vec3 aux = color;
|
||||
vec3 min_sample = min(min(C0, C1), min(C2, C3));
|
||||
vec3 max_sample = max(max(C0, C1), max(C2, C3));
|
||||
color = clamp(color, min_sample, max_sample);
|
||||
color = mix(aux, color, step(0.0, (C0-C1)*(C2-C3)));
|
||||
}
|
||||
|
||||
FragColor = vec4(color, 1.0);
|
||||
}
|
||||
|
|
|
@ -39,8 +39,15 @@ layout(push_constant) uniform Push
|
|||
vec4 OriginalSize;
|
||||
vec4 OutputSize;
|
||||
uint FrameCount;
|
||||
float S36_ANTI_RINGING;
|
||||
} params;
|
||||
|
||||
#pragma parameter S36_ANTI_RINGING "Spline36 Anti-Ringing [ OFF | ON ]" 1.0 0.0 1.0 1.0
|
||||
|
||||
#define S36_ANTI_RINGING params.S36_ANTI_RINGING
|
||||
|
||||
#define AR_STRENGTH 0.8
|
||||
|
||||
layout(std140, set = 0, binding = 0) uniform UBO
|
||||
{
|
||||
mat4 MVP;
|
||||
|
@ -131,5 +138,15 @@ void main()
|
|||
|
||||
vec3 color = mat3( C0, C1, C2 ) * w1 + mat3( C3, C4, C5) * w2;
|
||||
|
||||
// Anti-ringing
|
||||
if (S36_ANTI_RINGING == 1.0)
|
||||
{
|
||||
vec3 aux = color;
|
||||
vec3 min_sample = min(min(C1, C2), min(C3, C4));
|
||||
vec3 max_sample = max(max(C1, C2), max(C3, C4));
|
||||
color = clamp(color, min_sample, max_sample);
|
||||
color = mix(aux, color, AR_STRENGTH*step(0.0, (C1-C2)*(C3-C4)));
|
||||
}
|
||||
|
||||
FragColor = vec4(color, 1.0);
|
||||
}
|
||||
|
|
|
@ -39,8 +39,15 @@ layout(push_constant) uniform Push
|
|||
vec4 OriginalSize;
|
||||
vec4 OutputSize;
|
||||
uint FrameCount;
|
||||
float S36_ANTI_RINGING;
|
||||
} params;
|
||||
|
||||
#pragma parameter S36_ANTI_RINGING "Spline36 Anti-Ringing [ OFF | ON ]" 1.0 0.0 1.0 1.0
|
||||
|
||||
#define S36_ANTI_RINGING params.S36_ANTI_RINGING
|
||||
|
||||
#define AR_STRENGTH 0.8
|
||||
|
||||
layout(std140, set = 0, binding = 0) uniform UBO
|
||||
{
|
||||
mat4 MVP;
|
||||
|
@ -131,5 +138,16 @@ void main()
|
|||
|
||||
vec3 color = mat3( C0, C1, C2 ) * w1 + mat3( C3, C4, C5) * w2;
|
||||
|
||||
// Anti-ringing
|
||||
if (S36_ANTI_RINGING == 1.0)
|
||||
{
|
||||
vec3 aux = color;
|
||||
vec3 min_sample = min(min(C1, C2), min(C3, C4));
|
||||
vec3 max_sample = max(max(C1, C2), max(C3, C4));
|
||||
color = clamp(color, min_sample, max_sample);
|
||||
color = mix(aux, color, AR_STRENGTH*step(0.0, (C1-C2)*(C3-C4)));
|
||||
|
||||
}
|
||||
|
||||
FragColor = vec4(color, 1.0);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue