mirror of
https://github.com/italicsjenga/slang-shaders.git
synced 2024-11-29 19:01:31 +11:00
Merge pull request #74 from Monroe88/response-time
Add response time shader and update lcd-grid-v2-motionblur presets
This commit is contained in:
commit
49d6595358
|
@ -1,6 +1,6 @@
|
||||||
shaders = "3"
|
shaders = "3"
|
||||||
|
|
||||||
shader0 = "../motionblur/shaders/motionblur-simple.slang"
|
shader0 = "../motionblur/shaders/response-time.slang"
|
||||||
filter_linear0 = "false"
|
filter_linear0 = "false"
|
||||||
scale_type0 = "source"
|
scale_type0 = "source"
|
||||||
scale0 = "1.0"
|
scale0 = "1.0"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
shaders = "3"
|
shaders = "3"
|
||||||
|
|
||||||
shader0 = "../motionblur/shaders/motionblur-simple.slang"
|
shader0 = "../motionblur/shaders/response-time.slang"
|
||||||
filter_linear0 = "false"
|
filter_linear0 = "false"
|
||||||
scale_type0 = "source"
|
scale_type0 = "source"
|
||||||
scale0 = "1.0"
|
scale0 = "1.0"
|
||||||
|
|
28
handheld/lcd-grid-v2-motionblur.glslp
Normal file
28
handheld/lcd-grid-v2-motionblur.glslp
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
shaders = "2"
|
||||||
|
shader0 = "../motionblur/shaders/response-time.glsl"
|
||||||
|
shader1 = "shaders/lcd-cgwg/lcd-grid-v2.glsl"
|
||||||
|
|
||||||
|
scale_type0 = "source"
|
||||||
|
scale0 = "1.0"
|
||||||
|
|
||||||
|
scale_type1 = "viewport"
|
||||||
|
scale1 = "1.0"
|
||||||
|
|
||||||
|
filter_linear0 = "false"
|
||||||
|
filter_linear1 = "false"
|
||||||
|
|
||||||
|
parameters = "RSUBPIX_R;RSUBPIX_G;RSUBPIX_B;GSUBPIX_R;GSUBPIX_G;GSUBPIX_B;BSUBPIX_R;BSUBPIX_G;BSUBPIX_B;gain;gamma;blacklevel;ambient;BGR"
|
||||||
|
RSUBPIX_R = "0.750000"
|
||||||
|
RSUBPIX_G = "0.000000"
|
||||||
|
RSUBPIX_B = "0.000000"
|
||||||
|
GSUBPIX_R = "0.000000"
|
||||||
|
GSUBPIX_G = "0.750000"
|
||||||
|
GSUBPIX_B = "0.000000"
|
||||||
|
BSUBPIX_R = "0.000000"
|
||||||
|
BSUBPIX_G = "0.000000"
|
||||||
|
BSUBPIX_B = "0.750000"
|
||||||
|
gain = "1.500000"
|
||||||
|
gamma = "2.200000"
|
||||||
|
blacklevel = "0.000000"
|
||||||
|
ambient = "0.000000"
|
||||||
|
BGR = "0.000000"
|
|
@ -1,6 +1,6 @@
|
||||||
shaders = "3"
|
shaders = "3"
|
||||||
|
|
||||||
shader0 = "../motionblur/shaders/motionblur-simple.slang"
|
shader0 = "../motionblur/shaders/response-time.slang"
|
||||||
filter_linear0 = "false"
|
filter_linear0 = "false"
|
||||||
scale_type0 = "source"
|
scale_type0 = "source"
|
||||||
scale0 = "1.0"
|
scale0 = "1.0"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
shaders = "3"
|
shaders = "3"
|
||||||
|
|
||||||
shader0 = "../motionblur/shaders/motionblur-simple.slang"
|
shader0 = "../motionblur/shaders/response-time.slang"
|
||||||
filter_linear0 = "false"
|
filter_linear0 = "false"
|
||||||
scale_type0 = "source"
|
scale_type0 = "source"
|
||||||
scale0 = "1.0"
|
scale0 = "1.0"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
shaders = "3"
|
shaders = "3"
|
||||||
|
|
||||||
shader0 = "../motionblur/shaders/motionblur-simple.slang"
|
shader0 = "../motionblur/shaders/response-time.slang"
|
||||||
filter_linear0 = "false"
|
filter_linear0 = "false"
|
||||||
scale_type0 = "source"
|
scale_type0 = "source"
|
||||||
scale0 = "1.0"
|
scale0 = "1.0"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
shaders = "3"
|
shaders = "3"
|
||||||
|
|
||||||
shader0 = "../motionblur/shaders/motionblur-simple.slang"
|
shader0 = "../motionblur/shaders/response-time.slang"
|
||||||
filter_linear0 = "false"
|
filter_linear0 = "false"
|
||||||
scale_type0 = "source"
|
scale_type0 = "source"
|
||||||
scale0 = "1.0"
|
scale0 = "1.0"
|
||||||
|
|
|
@ -2,4 +2,21 @@ shaders = 1
|
||||||
|
|
||||||
shader0 = shaders/lcd-cgwg/lcd-grid-v2.slang
|
shader0 = shaders/lcd-cgwg/lcd-grid-v2.slang
|
||||||
filter_linear0 = false
|
filter_linear0 = false
|
||||||
scale_type_0 = source
|
scale_type0 = "viewport"
|
||||||
|
scale0 = "1.0"
|
||||||
|
|
||||||
|
parameters = "RSUBPIX_R;RSUBPIX_G;RSUBPIX_B;GSUBPIX_R;GSUBPIX_G;GSUBPIX_B;BSUBPIX_R;BSUBPIX_G;BSUBPIX_B;gain;gamma;blacklevel;ambient;BGR"
|
||||||
|
RSUBPIX_R = "0.750000"
|
||||||
|
RSUBPIX_G = "0.000000"
|
||||||
|
RSUBPIX_B = "0.000000"
|
||||||
|
GSUBPIX_R = "0.000000"
|
||||||
|
GSUBPIX_G = "0.750000"
|
||||||
|
GSUBPIX_B = "0.000000"
|
||||||
|
BSUBPIX_R = "0.000000"
|
||||||
|
BSUBPIX_G = "0.000000"
|
||||||
|
BSUBPIX_B = "0.750000"
|
||||||
|
gain = "1.500000"
|
||||||
|
gamma = "2.200000"
|
||||||
|
blacklevel = "0.000000"
|
||||||
|
ambient = "0.000000"
|
||||||
|
BGR = "0.000000"
|
||||||
|
|
5
motionblur/response-time.slangp
Normal file
5
motionblur/response-time.slangp
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
shaders = 1
|
||||||
|
|
||||||
|
shader0 = shaders/response-time.slang
|
||||||
|
filter_linear0 = false
|
||||||
|
scale_type_0 = source
|
76
motionblur/shaders/response-time.slang
Normal file
76
motionblur/shaders/response-time.slang
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
#version 450
|
||||||
|
/*
|
||||||
|
Response Time
|
||||||
|
Based on the response time function from Harlequin's Game Boy and LCD shaders
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by the Free
|
||||||
|
Software Foundation; either version 2 of the License, or (at your option)
|
||||||
|
any later version.
|
||||||
|
*/
|
||||||
|
|
||||||
|
layout(push_constant) uniform Push
|
||||||
|
{
|
||||||
|
float response_time;
|
||||||
|
} params;
|
||||||
|
|
||||||
|
// Simulate response time
|
||||||
|
// Higher values result in longer color transition periods - [0, 1]
|
||||||
|
#pragma parameter response_time "LCD Response Time" 0.333 0.0 0.777 0.111
|
||||||
|
|
||||||
|
layout(std140, set = 0, binding = 0) uniform UBO
|
||||||
|
{
|
||||||
|
mat4 MVP;
|
||||||
|
vec4 OutputSize;
|
||||||
|
vec4 OriginalSize;
|
||||||
|
vec4 SourceSize;
|
||||||
|
} 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 OriginalHistory1;
|
||||||
|
layout(set = 0, binding = 4) uniform sampler2D OriginalHistory2;
|
||||||
|
layout(set = 0, binding = 5) uniform sampler2D OriginalHistory3;
|
||||||
|
layout(set = 0, binding = 6) uniform sampler2D OriginalHistory4;
|
||||||
|
layout(set = 0, binding = 7) uniform sampler2D OriginalHistory5;
|
||||||
|
layout(set = 0, binding = 8) uniform sampler2D OriginalHistory6;
|
||||||
|
layout(set = 0, binding = 9) uniform sampler2D OriginalHistory7;
|
||||||
|
|
||||||
|
// Frame sampling definitions
|
||||||
|
#define curr_rgb texture(Source, vTexCoord).rgb
|
||||||
|
#define prev0_rgb texture(OriginalHistory1, vTexCoord).rgb
|
||||||
|
#define prev1_rgb texture(OriginalHistory2, vTexCoord).rgb
|
||||||
|
#define prev2_rgb texture(OriginalHistory3, vTexCoord).rgb
|
||||||
|
#define prev3_rgb texture(OriginalHistory4, vTexCoord).rgb
|
||||||
|
#define prev4_rgb texture(OriginalHistory5, vTexCoord).rgb
|
||||||
|
#define prev5_rgb texture(OriginalHistory6, vTexCoord).rgb
|
||||||
|
#define prev6_rgb texture(OriginalHistory7, vTexCoord).rgb
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
// Sample color from the current and previous frames, apply response time modifier
|
||||||
|
// Response time effect implmented through an exponential dropoff algorithm
|
||||||
|
vec3 input_rgb = curr_rgb;
|
||||||
|
input_rgb += (prev0_rgb - input_rgb) * params.response_time;
|
||||||
|
input_rgb += (prev1_rgb - input_rgb) * pow(params.response_time, 2.0);
|
||||||
|
input_rgb += (prev2_rgb - input_rgb) * pow(params.response_time, 3.0);
|
||||||
|
input_rgb += (prev3_rgb - input_rgb) * pow(params.response_time, 4.0);
|
||||||
|
input_rgb += (prev4_rgb - input_rgb) * pow(params.response_time, 5.0);
|
||||||
|
input_rgb += (prev5_rgb - input_rgb) * pow(params.response_time, 6.0);
|
||||||
|
input_rgb += (prev6_rgb - input_rgb) * pow(params.response_time, 7.0);
|
||||||
|
|
||||||
|
FragColor = vec4(input_rgb, 0.0);
|
||||||
|
}
|
Loading…
Reference in a new issue