mirror of
https://github.com/italicsjenga/slang-shaders.git
synced 2024-11-26 01:11:32 +11:00
add lcd3x and tweak ds-hybrid-view
This commit is contained in:
parent
b8816f559c
commit
2e8f7794d3
4
handheld/lcd3x.slangp
Normal file
4
handheld/lcd3x.slangp
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
shaders = 1
|
||||||
|
|
||||||
|
shader0 = shaders/lcd3x.slang
|
||||||
|
filter_linear0 = false
|
|
@ -14,9 +14,11 @@ layout(push_constant) uniform Push
|
||||||
vec4 OutputSize;
|
vec4 OutputSize;
|
||||||
uint FrameCount;
|
uint FrameCount;
|
||||||
float screen_toggle;
|
float screen_toggle;
|
||||||
|
float scale_correction;
|
||||||
} params;
|
} params;
|
||||||
|
|
||||||
#pragma parameter screen_toggle "Screen Toggle" 0.0 0.0 0.5 0.5
|
#pragma parameter screen_toggle "Screen Toggle" 0.0 0.0 0.5 0.5
|
||||||
|
#pragma parameter aspect_correction "Aspect Correction" 1.0 0.5 5.0 0.01
|
||||||
|
|
||||||
layout(std140, set = 0, binding = 0) uniform UBO
|
layout(std140, set = 0, binding = 0) uniform UBO
|
||||||
{
|
{
|
||||||
|
@ -34,7 +36,7 @@ void main()
|
||||||
video_scale = floor(params.SourceSize.w * params.OutputSize.y);
|
video_scale = floor(params.SourceSize.w * params.OutputSize.y);
|
||||||
vec2 integer_scale = video_scale * params.SourceSize.xy;
|
vec2 integer_scale = video_scale * params.SourceSize.xy;
|
||||||
gl_Position = (global.MVP * Position);
|
gl_Position = (global.MVP * Position);
|
||||||
vTexCoord = TexCoord * (params.OutputSize.xy / vec2(integer_scale));
|
vTexCoord = TexCoord * (params.OutputSize.xy / vec2(integer_scale)) * vec2(params.aspect_correction, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma stage fragment
|
#pragma stage fragment
|
||||||
|
@ -46,6 +48,6 @@ layout(set = 0, binding = 2) uniform sampler2D Source;
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec2 bigCoord = vTexCoord * vec2(0.3570) + vec2(0.0, 0.0 + params.screen_toggle);
|
vec2 bigCoord = vTexCoord * vec2(0.3570) + vec2(0.0, 0.0 + params.screen_toggle);
|
||||||
vec2 smallCoord = vTexCoord * vec2(1.05) + vec2(-2.942, -0.275);
|
vec2 smallCoord = vTexCoord * vec2(1.05,1.00) + vec2(-2.94, -0.2);
|
||||||
FragColor = texture(Source, bigCoord) + texture(Source, smallCoord);
|
FragColor = texture(Source, bigCoord) + texture(Source, smallCoord);
|
||||||
}
|
}
|
59
handheld/shaders/lcd3x.slang
Normal file
59
handheld/shaders/lcd3x.slang
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
#version 450
|
||||||
|
|
||||||
|
/*
|
||||||
|
Author: Gigaherz
|
||||||
|
License: Public domain
|
||||||
|
*/
|
||||||
|
|
||||||
|
layout(push_constant) uniform Push
|
||||||
|
{
|
||||||
|
vec4 SourceSize;
|
||||||
|
vec4 OriginalSize;
|
||||||
|
vec4 OutputSize;
|
||||||
|
uint FrameCount;
|
||||||
|
float brighten_scanlines;
|
||||||
|
float brighten_lcd;
|
||||||
|
} params;
|
||||||
|
|
||||||
|
#pragma parameter brighten_scanlines "Brighten Scanlines" 16.0 1.0 32.0 0.5
|
||||||
|
#define brighten_scanlines params.brighten_scanlines
|
||||||
|
#pragma parameter brighten_lcd "Brighten LCD" 4.0 1.0 12.0 0.1
|
||||||
|
#define brighten_lcd params.brighten_lcd
|
||||||
|
|
||||||
|
layout(std140, set = 0, binding = 0) uniform UBO
|
||||||
|
{
|
||||||
|
mat4 MVP;
|
||||||
|
} global;
|
||||||
|
|
||||||
|
vec2 omega = vec2(3.141592654) * vec2(2.0) * params.SourceSize.xy;
|
||||||
|
const vec3 offsets = vec3(3.141592654) * vec3(1.0/2,1.0/2 - 2.0/3,1.0/2-4.0/3);
|
||||||
|
|
||||||
|
#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;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
vec3 res = texture(Source, vTexCoord).xyz;
|
||||||
|
|
||||||
|
vec2 angle = vTexCoord * omega;
|
||||||
|
|
||||||
|
float yfactor = (brighten_scanlines + sin(angle.y)) / (brighten_scanlines + 1);
|
||||||
|
vec3 xfactors = (brighten_lcd + sin(angle.x + offsets)) / (brighten_lcd + 1);
|
||||||
|
|
||||||
|
vec3 color = yfactor * xfactors * res;
|
||||||
|
|
||||||
|
FragColor = vec4(color.x, color.y, color.z, 1.0);
|
||||||
|
}
|
Loading…
Reference in a new issue