mirror of
https://github.com/italicsjenga/slang-shaders.git
synced 2024-11-22 15:51:30 +11:00
A couple of MAD optimizations, some formatting and ensure the shader
works a little bit better. If the blending_mode macro on gb-pass1 is set to 0, we'll get only the green background color.
This commit is contained in:
parent
11f0af188c
commit
70d30ead4b
|
@ -59,7 +59,7 @@ layout(location = 3) out vec2 one_texel;
|
|||
|
||||
|
||||
// Largest integer scale of input video that will fit in the current output (y axis would typically be limiting on widescreens)
|
||||
#define video_scale floor(global.OutputSize.y / global.SourceSize.y)
|
||||
#define video_scale floor(global.OutputSize.y * global.SourceSize.w)
|
||||
|
||||
// Size of the scaled video
|
||||
#define scaled_video_out (global.SourceSize.xy * vec2(video_scale))
|
||||
|
@ -130,7 +130,8 @@ void main()
|
|||
input_rgb += (prev5_rgb - input_rgb) * pow(response_time, 6.0);
|
||||
input_rgb += (prev6_rgb - input_rgb) * pow(response_time, 7.0);
|
||||
|
||||
float rgb_to_alpha = (input_rgb.r + input_rgb.g + input_rgb.b) / 3.0 + (is_on_dot * baseline_alpha);
|
||||
float rgb_to_alpha = (input_rgb.r + input_rgb.g + input_rgb.b) * 0.333333333
|
||||
+ (is_on_dot * baseline_alpha);
|
||||
|
||||
// Apply foreground color and assign alpha value
|
||||
// Apply the foreground color to all texels -
|
||||
|
|
|
@ -14,7 +14,8 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
|
||||
// 0 - only the space between dots is blending
|
||||
// 1 - all texels are blended
|
||||
#define blending_mode 0
|
||||
/* TODO/FIXME - When set to zero, frame will be a solid green color */
|
||||
#define blending_mode 1
|
||||
|
||||
// The amount of alpha swapped between neighboring texels
|
||||
#define adjacent_texel_alpha_blending 0.1755
|
||||
|
|
|
@ -39,12 +39,12 @@ layout(location = 3) out vec2 upper_bound;
|
|||
|
||||
void main()
|
||||
{
|
||||
gl_Position = global.MVP * Position;
|
||||
vTexCoord = TexCoord;
|
||||
|
||||
texel = global.SourceSize.zw;
|
||||
lower_bound = vec2(0.0);
|
||||
upper_bound = vec2(texel * (global.OutputSize.xy - 1.0));
|
||||
gl_Position = global.MVP * Position;
|
||||
vTexCoord = TexCoord;
|
||||
|
||||
texel = global.SourceSize.zw;
|
||||
lower_bound = vec2(0.0);
|
||||
upper_bound = vec2(texel * (global.OutputSize.xy - 1.0));
|
||||
}
|
||||
|
||||
#pragma stage fragment
|
||||
|
@ -98,16 +98,16 @@ void main()
|
|||
0.10164546793794160274995705611009,
|
||||
0.08167444001912718529866079800870 );
|
||||
|
||||
//sample the current fragment and apply its weight
|
||||
// Sample the current fragment and apply its weight
|
||||
vec4 out_color = texture(Source, clamp(vTexCoord, lower_bound, upper_bound)) * weights[0];
|
||||
|
||||
//iterate across the offsets in both directions sampling texels and adding their weighted alpha values to the total
|
||||
// Iterate across the offsets in both directions sampling texels
|
||||
// and adding their weighted alpha values to the total
|
||||
for (int i = 1; i < 5; i++)
|
||||
{
|
||||
out_color.a += texture(Source, clamp(vTexCoord + vec2(0.0, offsets[i] * texel.y), lower_bound, upper_bound)).a * weights[i];
|
||||
out_color.a += texture(Source, clamp(vTexCoord - vec2(0.0, offsets[i] * texel.y), lower_bound, upper_bound)).a * weights[i];
|
||||
}
|
||||
|
||||
//return the new value
|
||||
FragColor = vec4(out_color.rgb, 1.0);
|
||||
FragColor = out_color;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue