Merge pull request #79 from Monroe88/lcd-shaders

sameboy-lcd: Add parameters
This commit is contained in:
hizzlekizzle 2018-03-24 16:34:57 -05:00 committed by GitHub
commit cf7c908776
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 46 additions and 35 deletions

View file

@ -13,10 +13,10 @@
layout(std140, set = 0, binding = 0) uniform UBO
{
mat4 MVP;
vec4 OutputSize;
vec4 OriginalSize;
vec4 SourceSize;
mat4 MVP;
vec4 OutputSize;
vec4 OriginalSize;
vec4 SourceSize;
} global;
#pragma stage vertex
@ -26,8 +26,8 @@ layout(location = 0) out vec2 vTexCoord;
void main()
{
gl_Position = global.MVP * Position;
vTexCoord = TexCoord;
gl_Position = global.MVP * Position;
vTexCoord = TexCoord;
}
#pragma stage fragment

View file

@ -13,19 +13,19 @@
layout(std140, set = 0, binding = 0) uniform UBO
{
mat4 MVP;
vec4 OutputSize;
vec4 OriginalSize;
vec4 SourceSize;
mat4 MVP;
vec4 OutputSize;
vec4 OriginalSize;
vec4 SourceSize;
} global;
layout(push_constant) uniform Push
{
float reflectionBrightness;
float reflectionDistanceX;
float reflectionDistanceY;
float lightBrightness;
} params;
float reflectionBrightness;
float reflectionDistanceX;
float reflectionDistanceY;
float lightBrightness;
}params;
#pragma parameter reflectionBrightness "Reflection brightness" 0.07 0.0 1.0 0.01
#pragma parameter reflectionDistanceX "Reflection Distance X" 0.0 -1.0 1.0 0.005
@ -39,8 +39,8 @@ layout(location = 0) out vec2 vTexCoord;
void main()
{
gl_Position = global.MVP * Position;
vTexCoord = TexCoord;
gl_Position = global.MVP * Position;
vTexCoord = TexCoord;
}
#pragma stage fragment
@ -54,7 +54,7 @@ const float coeff = 2.5;
void main()
{
vec2 reflectionDistance = vec2(params.reflectionDistanceX,params.reflectionDistanceY);
vec2 reflectionDistance = vec2(params.reflectionDistanceX,params.reflectionDistanceY);
float sp = pow(speed, params.lightBrightness);
float dc = pow(decay, -params.lightBrightness);
float s = (sp - dc) / (sp + dc);
@ -69,6 +69,6 @@ void main()
vec4 reflection = texture(Source, vTexCoord - reflectionDistance);
color.rgb += reflection.rgb * params.reflectionBrightness;
color.a = 1.0;
FragColor = color;
FragColor = color;
}

View file

@ -13,10 +13,10 @@
layout(std140, set = 0, binding = 0) uniform UBO
{
mat4 MVP;
vec4 OutputSize;
vec4 OriginalSize;
vec4 SourceSize;
mat4 MVP;
vec4 OutputSize;
vec4 OriginalSize;
vec4 SourceSize;
} global;
#pragma stage vertex
@ -26,8 +26,8 @@ layout(location = 0) out vec2 vTexCoord;
void main()
{
gl_Position = global.MVP * Position;
vTexCoord = TexCoord;
gl_Position = global.MVP * Position;
vTexCoord = TexCoord;
}
#pragma stage fragment

View file

@ -28,12 +28,27 @@
layout(std140, set = 0, binding = 0) uniform UBO
{
vec4 SourceSize;
vec4 OriginalSize;
vec4 OutputSize;
mat4 MVP;
vec4 SourceSize;
vec4 OriginalSize;
vec4 OutputSize;
mat4 MVP;
} global;
layout(push_constant) uniform Push
{
float COLOR_LOW;
float COLOR_HIGH;
float SCANLINE_DEPTH;
} params;
#pragma parameter COLOR_LOW "Color Low" 0.8 0.0 1.5 0.05
#pragma parameter COLOR_HIGH "Color High" 1.0 0.0 1.5 0.05
#pragma parameter SCANLINE_DEPTH "Scanline Depth" 0.1 0.0 2.0 0.05
#define COLOR_LOW params.COLOR_LOW
#define COLOR_HIGH params.COLOR_HIGH
#define SCANLINE_DEPTH params.SCANLINE_DEPTH
#pragma stage vertex
layout(location = 0) in vec4 Position;
layout(location = 1) in vec2 TexCoord;
@ -41,8 +56,8 @@ layout(location = 0) out vec2 vTexCoord;
void main()
{
gl_Position = global.MVP * Position;
vTexCoord = TexCoord;
gl_Position = global.MVP * Position;
vTexCoord = TexCoord;
}
#pragma stage fragment
@ -50,10 +65,6 @@ layout(location = 0) in vec2 vTexCoord;
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform sampler2D Source;
#define COLOR_LOW 0.8
#define COLOR_HIGH 1.0
#define SCANLINE_DEPTH 0.1
void main()
{
vec2 pos = fract(vTexCoord * global.SourceSize.xy);