mirror of
https://github.com/italicsjenga/slang-shaders.git
synced 2024-11-22 15:51:30 +11:00
add gristleVHS shaders and preset
This commit is contained in:
parent
2fe1341361
commit
fa2304804a
48
blurs/sunset_gaussian/sunset_horz.slang
Normal file
48
blurs/sunset_gaussian/sunset_horz.slang
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
#version 450
|
||||||
|
|
||||||
|
layout(push_constant) uniform Push
|
||||||
|
{
|
||||||
|
vec4 SourceSize;
|
||||||
|
vec4 OriginalSize;
|
||||||
|
vec4 OutputSize;
|
||||||
|
uint FrameCount;
|
||||||
|
} params;
|
||||||
|
|
||||||
|
layout(std140, set = 0, binding = 0) uniform UBO
|
||||||
|
{
|
||||||
|
mat4 MVP;
|
||||||
|
} global;
|
||||||
|
|
||||||
|
#pragma stage vertex
|
||||||
|
layout(location = 0) in vec4 Position;
|
||||||
|
layout(location = 1) in vec2 TexCoord;
|
||||||
|
layout(location = 0) out vec2 vTexCoord;
|
||||||
|
layout(location = 1) out vec2 blurCoordinates[5];
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = global.MVP * Position;
|
||||||
|
vTexCoord = TexCoord;
|
||||||
|
blurCoordinates[0] = vTexCoord.xy;
|
||||||
|
blurCoordinates[1] = vTexCoord.xy + params.OutputSize.zw * vec2(1.407333,0.0);
|
||||||
|
blurCoordinates[2] = vTexCoord.xy - params.OutputSize.zw * vec2(1.407333,0.0);
|
||||||
|
blurCoordinates[3] = vTexCoord.xy + params.OutputSize.zw * vec2(3.294215,0.0);
|
||||||
|
blurCoordinates[4] = vTexCoord.xy - params.OutputSize.zw * vec2(3.294215,0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma stage fragment
|
||||||
|
layout(location = 0) in vec2 vTexCoord;
|
||||||
|
layout(location = 1) in vec2 blurCoordinates[5];
|
||||||
|
layout(location = 0) out vec4 FragColor;
|
||||||
|
layout(set = 0, binding = 2) uniform sampler2D Source;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
vec4 sum = vec4(0.0);
|
||||||
|
sum += texture(Source, blurCoordinates[0]) * 0.204164;
|
||||||
|
sum += texture(Source, blurCoordinates[1]) * 0.304005;
|
||||||
|
sum += texture(Source, blurCoordinates[2]) * 0.304005;
|
||||||
|
sum += texture(Source, blurCoordinates[3]) * 0.093913;
|
||||||
|
sum += texture(Source, blurCoordinates[4]) * 0.093913;
|
||||||
|
FragColor = sum;
|
||||||
|
}
|
48
blurs/sunset_gaussian/sunset_vert.slang
Normal file
48
blurs/sunset_gaussian/sunset_vert.slang
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
#version 450
|
||||||
|
|
||||||
|
layout(push_constant) uniform Push
|
||||||
|
{
|
||||||
|
vec4 SourceSize;
|
||||||
|
vec4 OriginalSize;
|
||||||
|
vec4 OutputSize;
|
||||||
|
uint FrameCount;
|
||||||
|
} params;
|
||||||
|
|
||||||
|
layout(std140, set = 0, binding = 0) uniform UBO
|
||||||
|
{
|
||||||
|
mat4 MVP;
|
||||||
|
} global;
|
||||||
|
|
||||||
|
#pragma stage vertex
|
||||||
|
layout(location = 0) in vec4 Position;
|
||||||
|
layout(location = 1) in vec2 TexCoord;
|
||||||
|
layout(location = 0) out vec2 vTexCoord;
|
||||||
|
layout(location = 1) out vec2 blurCoordinates[5];
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = global.MVP * Position;
|
||||||
|
vTexCoord = TexCoord;
|
||||||
|
blurCoordinates[0] = vTexCoord.xy;
|
||||||
|
blurCoordinates[1] = vTexCoord.xy + params.OutputSize.zw * vec2(0.0,1.407333);
|
||||||
|
blurCoordinates[2] = vTexCoord.xy - params.OutputSize.zw * vec2(0.0,1.407333);
|
||||||
|
blurCoordinates[3] = vTexCoord.xy + params.OutputSize.zw * vec2(0.0,3.294215);
|
||||||
|
blurCoordinates[4] = vTexCoord.xy - params.OutputSize.zw * vec2(0.0,3.294215);
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma stage fragment
|
||||||
|
layout(location = 0) in vec2 vTexCoord;
|
||||||
|
layout(location = 1) in vec2 blurCoordinates[5];
|
||||||
|
layout(location = 0) out vec4 FragColor;
|
||||||
|
layout(set = 0, binding = 2) uniform sampler2D Source;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
vec4 sum = vec4(0.0);
|
||||||
|
sum += texture(Source, blurCoordinates[0]) * 0.204164;
|
||||||
|
sum += texture(Source, blurCoordinates[1]) * 0.304005;
|
||||||
|
sum += texture(Source, blurCoordinates[2]) * 0.304005;
|
||||||
|
sum += texture(Source, blurCoordinates[3]) * 0.093913;
|
||||||
|
sum += texture(Source, blurCoordinates[4]) * 0.093913;
|
||||||
|
FragColor = sum;
|
||||||
|
}
|
24
vhs/gristleVHS.slangp
Normal file
24
vhs/gristleVHS.slangp
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
shaders = 4
|
||||||
|
|
||||||
|
shader0 = shaders/gristleVHS/HorizontalSoften.slang
|
||||||
|
scale_type0 = absolute
|
||||||
|
scale_y0 = 480
|
||||||
|
scale_x0 = 333
|
||||||
|
frame_count_mod0 = 256
|
||||||
|
filter_linear0 = true
|
||||||
|
|
||||||
|
shader1 = ../blurs/sunset_gaussian/sunset_horz.slang
|
||||||
|
scale_type1 = absolute
|
||||||
|
scale_x1 = 80
|
||||||
|
scale_y1 = 480
|
||||||
|
filter_linear1 = true
|
||||||
|
|
||||||
|
shader2 = shaders/gristleVHS/VHS.slang
|
||||||
|
scale_type2 = absolute
|
||||||
|
scale_y2 = 480
|
||||||
|
scale_x2 = 333
|
||||||
|
frame_count_mod2 = 256
|
||||||
|
filter_linear2 = true
|
||||||
|
|
||||||
|
shader3 = ../stock.slang
|
||||||
|
filter_linear3 = true
|
42
vhs/shaders/gristleVHS/HorizontalSoften.slang
Normal file
42
vhs/shaders/gristleVHS/HorizontalSoften.slang
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
#version 450
|
||||||
|
|
||||||
|
layout(push_constant) uniform Push
|
||||||
|
{
|
||||||
|
vec4 SourceSize;
|
||||||
|
vec4 OriginalSize;
|
||||||
|
vec4 OutputSize;
|
||||||
|
uint FrameCount;
|
||||||
|
} params;
|
||||||
|
|
||||||
|
layout(std140, set = 0, binding = 0) uniform UBO
|
||||||
|
{
|
||||||
|
mat4 MVP;
|
||||||
|
} global;
|
||||||
|
|
||||||
|
#pragma stage vertex
|
||||||
|
layout(location = 0) in vec4 Position;
|
||||||
|
layout(location = 1) in vec2 TexCoord;
|
||||||
|
layout(location = 0) out vec2 vTexCoord;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = global.MVP * Position;
|
||||||
|
vTexCoord = TexCoord;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma stage fragment
|
||||||
|
layout(location = 0) in vec2 vTexCoord;
|
||||||
|
layout(location = 0) out vec4 FragColor;
|
||||||
|
layout(set = 0, binding = 2) uniform sampler2D Source;
|
||||||
|
|
||||||
|
const float rndtable[256] = float[](
|
||||||
|
0.000, 0.031, 0.427, 0.863, 0.871, 0.945, 0.584, 0.420, 0.294, 0.973, 0.996, 0.549, 0.063, 0.259, 0.290, 0.082, 0.827, 0.184, 0.314, 0.949, 0.604, 0.106, 0.804, 0.502, 0.631, 0.349, 0.302, 0.141, 0.373, 0.431, 0.333, 0.188, 0.831, 0.549, 0.827, 0.976, 0.086, 0.310, 0.784, 0.196, 0.110, 0.737, 0.204, 0.549, 0.792, 0.471, 0.267, 0.569, 0.243, 0.275, 0.722, 0.745, 0.357, 0.773, 0.596, 0.878, 0.584, 0.408, 0.098, 0.698, 0.988, 0.714, 0.792, 0.714, 0.553, 0.773, 0.016, 0.318, 0.710, 0.949, 0.569, 0.165, 0.153, 0.890, 0.612, 0.776, 0.882, 0.757, 0.859, 0.365, 0.478, 0.686, 0.976, 0.000, 0.686, 0.561, 0.275, 0.937, 0.180, 0.965, 0.639, 0.208, 0.639, 0.427, 0.659, 0.529, 0.008, 0.922, 0.098, 0.361, 0.078, 0.569, 0.541, 0.302, 0.271, 0.651, 0.306, 0.690, 0.678, 0.831, 0.651, 0.443, 0.369, 0.631, 0.161, 0.196, 0.937, 0.192, 0.435, 0.643, 0.275, 0.235, 0.008, 0.145, 0.671, 0.294, 0.533, 0.612, 0.043, 0.220, 0.165, 0.573, 0.541, 0.898, 0.286, 0.573, 0.302, 0.239, 0.384, 0.769, 0.529, 0.416, 0.247, 0.773, 0.765, 0.337, 0.376, 0.796, 0.443, 0.396, 0.667, 0.969, 0.710, 0.443, 0.314, 0.980, 0.424, 0.027, 1.000, 0.929, 0.506, 0.886, 0.310, 0.420, 0.439, 0.651, 0.404, 0.945, 0.094, 0.875, 0.937, 0.471, 0.776, 0.227, 0.235, 0.322, 0.502, 0.012, 0.722, 0.259, 0.561, 0.878, 0.569, 0.878, 0.318, 0.808, 0.639, 0.176, 0.247, 0.353, 0.659, 0.447, 0.231, 0.129, 0.624, 0.373, 0.110, 0.545, 0.482, 0.384, 0.490, 0.769, 0.059, 0.275, 0.761, 0.992, 0.212, 0.055, 0.427, 0.886, 0.278, 0.067, 0.631, 0.365, 0.729, 0.341, 0.957, 0.541, 0.078, 0.204, 0.482, 0.984, 0.102, 0.141, 0.067, 0.180, 0.204, 0.906, 0.910, 0.298, 0.122, 0.867, 0.329, 0.145, 0.847, 0.647, 0.831, 0.416, 0.773, 0.949, 0.384, 0.169, 0.153, 0.686, 0.996, 0.569, 0.745, 0.329, 0.463, 0.871, 0.733, 0.533, 0.471, 0.639, 0.925, 0.976
|
||||||
|
);
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
vec3 Image = texture(Source, vTexCoord + vec2(params.SourceSize.z * rndtable[params.FrameCount] * 0.4, 0.0)).xyz
|
||||||
|
+ texture(Source, vTexCoord - vec2(params.SourceSize.z * rndtable[params.FrameCount] * 0.4, 0.0)).xyz;
|
||||||
|
|
||||||
|
FragColor = vec4(Image * 0.5, 1.0);
|
||||||
|
}
|
48
vhs/shaders/gristleVHS/VHS.slang
Normal file
48
vhs/shaders/gristleVHS/VHS.slang
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
#version 450
|
||||||
|
|
||||||
|
layout(push_constant) uniform Push
|
||||||
|
{
|
||||||
|
vec4 SourceSize;
|
||||||
|
vec4 OriginalSize;
|
||||||
|
vec4 OutputSize;
|
||||||
|
uint FrameCount;
|
||||||
|
} params;
|
||||||
|
|
||||||
|
layout(std140, set = 0, binding = 0) uniform UBO
|
||||||
|
{
|
||||||
|
mat4 MVP;
|
||||||
|
} global;
|
||||||
|
|
||||||
|
#pragma stage vertex
|
||||||
|
layout(location = 0) in vec4 Position;
|
||||||
|
layout(location = 1) in vec2 TexCoord;
|
||||||
|
layout(location = 0) out vec2 vTexCoord;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = global.MVP * Position;
|
||||||
|
vTexCoord = TexCoord;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma stage fragment
|
||||||
|
layout(location = 0) in vec2 vTexCoord;
|
||||||
|
layout(location = 0) out vec4 FragColor;
|
||||||
|
layout(set = 0, binding = 2) uniform sampler2D Source;
|
||||||
|
layout(set = 0, binding = 3) uniform sampler2D Original;
|
||||||
|
|
||||||
|
#define RGB_to_YIQ mat3x3( 0.299 , 0.595716 , 0.211456 , 0.587 , -0.274453 , -0.522591 , 0.114 , -0.321263 , 0.311135 )
|
||||||
|
#define YIQ_to_RGB mat3x3( 1.0 , 1.0 , 1.0 , 0.9563 , -0.2721 , -1.1070 , 0.6210 , -0.6474 , 1.7046 )
|
||||||
|
|
||||||
|
const float rndtable[256] = float[](
|
||||||
|
0.000, 0.031, 0.427, 0.863, 0.871, 0.945, 0.584, 0.420, 0.294, 0.973, 0.996, 0.549, 0.063, 0.259, 0.290, 0.082, 0.827, 0.184, 0.314, 0.949, 0.604, 0.106, 0.804, 0.502, 0.631, 0.349, 0.302, 0.141, 0.373, 0.431, 0.333, 0.188, 0.831, 0.549, 0.827, 0.976, 0.086, 0.310, 0.784, 0.196, 0.110, 0.737, 0.204, 0.549, 0.792, 0.471, 0.267, 0.569, 0.243, 0.275, 0.722, 0.745, 0.357, 0.773, 0.596, 0.878, 0.584, 0.408, 0.098, 0.698, 0.988, 0.714, 0.792, 0.714, 0.553, 0.773, 0.016, 0.318, 0.710, 0.949, 0.569, 0.165, 0.153, 0.890, 0.612, 0.776, 0.882, 0.757, 0.859, 0.365, 0.478, 0.686, 0.976, 0.000, 0.686, 0.561, 0.275, 0.937, 0.180, 0.965, 0.639, 0.208, 0.639, 0.427, 0.659, 0.529, 0.008, 0.922, 0.098, 0.361, 0.078, 0.569, 0.541, 0.302, 0.271, 0.651, 0.306, 0.690, 0.678, 0.831, 0.651, 0.443, 0.369, 0.631, 0.161, 0.196, 0.937, 0.192, 0.435, 0.643, 0.275, 0.235, 0.008, 0.145, 0.671, 0.294, 0.533, 0.612, 0.043, 0.220, 0.165, 0.573, 0.541, 0.898, 0.286, 0.573, 0.302, 0.239, 0.384, 0.769, 0.529, 0.416, 0.247, 0.773, 0.765, 0.337, 0.376, 0.796, 0.443, 0.396, 0.667, 0.969, 0.710, 0.443, 0.314, 0.980, 0.424, 0.027, 1.000, 0.929, 0.506, 0.886, 0.310, 0.420, 0.439, 0.651, 0.404, 0.945, 0.094, 0.875, 0.937, 0.471, 0.776, 0.227, 0.235, 0.322, 0.502, 0.012, 0.722, 0.259, 0.561, 0.878, 0.569, 0.878, 0.318, 0.808, 0.639, 0.176, 0.247, 0.353, 0.659, 0.447, 0.231, 0.129, 0.624, 0.373, 0.110, 0.545, 0.482, 0.384, 0.490, 0.769, 0.059, 0.275, 0.761, 0.992, 0.212, 0.055, 0.427, 0.886, 0.278, 0.067, 0.631, 0.365, 0.729, 0.341, 0.957, 0.541, 0.078, 0.204, 0.482, 0.984, 0.102, 0.141, 0.067, 0.180, 0.204, 0.906, 0.910, 0.298, 0.122, 0.867, 0.329, 0.145, 0.847, 0.647, 0.831, 0.416, 0.773, 0.949, 0.384, 0.169, 0.153, 0.686, 0.996, 0.569, 0.745, 0.329, 0.463, 0.871, 0.733, 0.533, 0.471, 0.639, 0.925, 0.976
|
||||||
|
);
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
vec3 ChromaPass = texture(Source, vTexCoord - vec2(params.SourceSize.z*0.333,0.0)).xyz * RGB_to_YIQ;
|
||||||
|
vec3 LuminaPass = texture(Original, vTexCoord).xyz * RGB_to_YIQ;
|
||||||
|
|
||||||
|
vec3 MergedPass= vec3(LuminaPass.x,ChromaPass.yz) * YIQ_to_RGB;
|
||||||
|
|
||||||
|
FragColor = vec4(MergedPass, 1.0);
|
||||||
|
}
|
Loading…
Reference in a new issue