remove unneeded passes

This commit is contained in:
hunterk 2020-06-26 16:21:12 -05:00
parent 5db5e6572d
commit 67f934f56f
5 changed files with 0 additions and 504 deletions

View file

@ -1,233 +0,0 @@
#version 450
// license:BSD-3-Clause
// copyright-holders:Ryan Holtz,ImJezze
//-----------------------------------------------------------------------------
// Bloom Effect
//-----------------------------------------------------------------------------
layout(push_constant) uniform Push
{
vec4 SourceSize;
vec4 OutputSize;
vec4 OriginalSize;
vec4 FinalViewportSize;
} params;
#include "mame_parameters.inc"
float Level0Weight = global.level0weight;
float Level1Weight = global.level1weight;
float Level2Weight = global.level2weight;
float Level3Weight = global.level3weight;
float Level4Weight = global.level4weight;
float Level5Weight = global.level5weight;
float Level6Weight = global.level6weight;
float Level7Weight = global.level7weight;
float Level8Weight = global.level8weight;
int BloomBlendMode = int(global.bloomblendmode); // 0 brighten, 1 darken
float BloomScale = global.bloomscale;
vec3 BloomOverdrive = vec3(global.bloomoverdrive_r, global.bloomoverdrive_g, global.bloomoverdrive_b);
//-----------------------------------------------------------------------------
// Constants
//-----------------------------------------------------------------------------
const float E = 2.7182817f;
const float Gelfond = 23.140692f; // e^pi (Gelfond constant)
const float GelfondSchneider = 2.6651442f; // 2^sqrt(2) (Gelfond-Schneider constant)
//-----------------------------------------------------------------------------
// Functions
//-----------------------------------------------------------------------------
// www.stackoverflow.com/questions/5149544/can-i-generate-a-random-number-inside-a-pixel-shader/
float random(vec2 seed)
{
// irrationals for pseudo randomness
vec2 i = vec2(Gelfond, GelfondSchneider);
return fract(cos(dot(seed, i)) * 123456.0f);
}
//-----------------------------------------------------------------------------
// Bloom Vertex Shader
//-----------------------------------------------------------------------------
#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 BloomCoord;
void main()
{
gl_Position = global.MVP * Position;
vTexCoord = TexCoord;
BloomCoord = vTexCoord;
}
#pragma stage fragment
layout(location = 0) in vec2 vTexCoord;
layout(location = 1) in vec2 BloomCoord;
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform sampler2D Source;
#define DiffuseSampler Source
#define BloomSamplerA Source
#define BloomSamplerB Source
#define BloomSamplerC Source
#define BloomSamplerD Source
#define BloomSamplerE Source
#define BloomSamplerF Source
#define BloomSamplerG Source
#define BloomSamplerH Source
// vector screen uses twice -1 as many bloom levels
#define BloomSamplerI Source
#define BloomSamplerJ Source
#define BloomSamplerK Source
#define BloomSamplerL Source
#define BloomSamplerM Source
#define BloomSamplerN Source
#define BloomSamplerO Source
vec3 GetNoiseFactor(vec3 n, float random)
{
// smaller n become more noisy
vec3 NoiseFactor;
NoiseFactor.x = 1.0 + random * max(0.0, 0.25 * pow(E, -8. * n.x));
NoiseFactor.y = 1.0 + random * max(0.0, 0.25 * pow(E, -8. * n.y));
NoiseFactor.z = 1.0 + random * max(0.0, 0.25 * pow(E, -8. * n.z));
return NoiseFactor;
}
void main()
{
if(!BloomToggle)
{
FragColor = texture(Source, vTexCoord);
return;
}
else
{
vec3 texel = texture(DiffuseSampler, vTexCoord).rgb;
vec3 texelA = texture(BloomSamplerA, BloomCoord.xy).rgb;
vec3 texelB = texture(BloomSamplerB, BloomCoord.xy).rgb;
vec3 texelC = texture(BloomSamplerC, BloomCoord.xy).rgb;
vec3 texelD = texture(BloomSamplerD, BloomCoord.xy).rgb;
vec3 texelE = texture(BloomSamplerE, BloomCoord.xy).rgb;
vec3 texelF = texture(BloomSamplerF, BloomCoord.xy).rgb;
vec3 texelG = texture(BloomSamplerG, BloomCoord.xy).rgb;
vec3 texelH = texture(BloomSamplerH, BloomCoord.xy).rgb;
vec3 texelI = vec3(0.0, 0.0, 0.0);
vec3 texelJ = vec3(0.0, 0.0, 0.0);
vec3 texelK = vec3(0.0, 0.0, 0.0);
vec3 texelL = vec3(0.0, 0.0, 0.0);
vec3 texelM = vec3(0.0, 0.0, 0.0);
vec3 texelN = vec3(0.0, 0.0, 0.0);
vec3 texelO = vec3(0.0, 0.0, 0.0);
// vector screen uses twice -1 as many bloom levels
if (VectorScreen)
{
texelI = texture(BloomSamplerI, BloomCoord.xy).rgb;
texelJ = texture(BloomSamplerJ, BloomCoord.xy).rgb;
texelK = texture(BloomSamplerK, BloomCoord.xy).rgb;
texelL = texture(BloomSamplerL, BloomCoord.xy).rgb;
texelM = texture(BloomSamplerM, BloomCoord.xy).rgb;
texelN = texture(BloomSamplerN, BloomCoord.xy).rgb;
texelO = texture(BloomSamplerO, BloomCoord.xy).rgb;
}
vec3 blend;
// brighten
if (BloomBlendMode < 0.5)
{
vec3 bloom = vec3(0.0, 0.0, 0.0);
texel *= Level0Weight;
if (VectorScreen)
{
bloom += texelA * Level1Weight;
bloom += texelB * Level2Weight;
bloom += texelC * Level3Weight;
bloom += texelD * Level4Weight;
bloom += texelE * Level5Weight;
bloom += texelF * Level6Weight;
bloom += texelG * Level7Weight;
bloom += texelH * Level8Weight;
}
// vector screen uses twice -1 as many bloom levels
else
{
bloom += texelA * (Level1Weight);
bloom += texelB * (Level1Weight + Level2Weight) * 0.5;
bloom += texelC * (Level2Weight);
bloom += texelD * (Level2Weight + Level3Weight) * 0.5;
bloom += texelE * (Level3Weight);
bloom += texelF * (Level3Weight + Level4Weight) * 0.5;
bloom += texelG * (Level4Weight);
bloom += texelH * (Level4Weight + Level5Weight) * 0.5;
bloom += texelI * (Level5Weight);
bloom += texelJ * (Level5Weight + Level6Weight) * 0.5;
bloom += texelK * (Level6Weight);
bloom += texelL * (Level6Weight + Level7Weight) * 0.5;
bloom += texelM * (Level7Weight);
bloom += texelN * (Level7Weight + Level8Weight) * 0.5;
bloom += texelO * (Level8Weight);
}
bloom *= BloomScale;
vec3 bloomOverdrive;
bloomOverdrive.r = max(0.0, texel.r + bloom.r - 1.0) * BloomOverdrive.r;
bloomOverdrive.g = max(0.0, texel.g + bloom.g - 1.0) * BloomOverdrive.g;
bloomOverdrive.b = max(0.0, texel.b + bloom.b - 1.0) * BloomOverdrive.b;
bloom.r += bloomOverdrive.g * 0.5;
bloom.r += bloomOverdrive.b * 0.5;
bloom.g += bloomOverdrive.r * 0.5;
bloom.g += bloomOverdrive.b * 0.5;
bloom.b += bloomOverdrive.r * 0.5;
bloom.b += bloomOverdrive.g * 0.5;
vec2 NoiseCoord = vTexCoord;
vec3 NoiseFactor = GetNoiseFactor(bloom, random(NoiseCoord));
blend = texel + bloom * NoiseFactor;
}
// darken
else
{
texelA = min(texel, texelA);
texelB = min(texel, texelB);
texelC = min(texel, texelC);
texelD = min(texel, texelD);
texelE = min(texel, texelE);
texelF = min(texel, texelF);
texelG = min(texel, texelG);
texelH = min(texel, texelH);
blend = texel * Level0Weight;
blend = mix(blend, texelA, Level1Weight * BloomScale);
blend = mix(blend, texelB, Level2Weight * BloomScale);
blend = mix(blend, texelC, Level3Weight * BloomScale);
blend = mix(blend, texelD, Level4Weight * BloomScale);
blend = mix(blend, texelE, Level5Weight * BloomScale);
blend = mix(blend, texelF, Level6Weight * BloomScale);
blend = mix(blend, texelG, Level7Weight * BloomScale);
blend = mix(blend, texelH, Level8Weight * BloomScale);
}
FragColor = vec4(blend, 1.0);
}
}

View file

@ -1,63 +0,0 @@
#version 450
// license:BSD-3-Clause
// copyright-holders:Ryan Holtz,ImJezze
//-----------------------------------------------------------------------------
// Downsample Effect
//-----------------------------------------------------------------------------
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 vec4 TexCoord01;
layout(location = 1) out vec4 TexCoord23;
const vec2 Coord0Offset = vec2(-0.5, -0.5);
const vec2 Coord1Offset = vec2( 0.5, -0.5);
const vec2 Coord2Offset = vec2(-0.5, 0.5);
const vec2 Coord3Offset = vec2( 0.5, 0.5);
void main()
{
gl_Position = global.MVP * Position;
vec2 HalfTargetTexelDims = 0.5 * params.SourceSize.zw;
TexCoord01.xy = TexCoord + Coord0Offset * HalfTargetTexelDims;
TexCoord01.zw = TexCoord + Coord1Offset * HalfTargetTexelDims;
TexCoord23.xy = TexCoord + Coord2Offset * HalfTargetTexelDims;
TexCoord23.zw = TexCoord + Coord3Offset * HalfTargetTexelDims;
}
#pragma stage fragment
layout(location = 0) in vec4 TexCoord01;
layout(location = 1) in vec4 TexCoord23;
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform sampler2D Source;
#define DiffuseSampler Source
void main()
{
vec3 texel0 = texture(DiffuseSampler, TexCoord01.xy).rgb;
vec3 texel1 = texture(DiffuseSampler, TexCoord01.zw).rgb;
vec3 texel2 = texture(DiffuseSampler, TexCoord23.xy).rgb;
vec3 texel3 = texture(DiffuseSampler, TexCoord23.zw).rgb;
vec3 outTexel = (texel0 + texel1 + texel2 + texel3) / 4.0;
FragColor = vec4(outTexel, 1.0);
}

View file

@ -1,102 +0,0 @@
#version 450
layout(push_constant) uniform Push
{
vec4 SourceSize;
vec4 OriginalSize;
vec4 OutputSize;
uint FrameCount;
} params;
#include "mame_parameters.inc"
#define saturate(c) clamp(c, 0.0, 1.0)
#define TargetDims params.OutputSize.xy
#define DiffuseSampler Source
float TimeRatio = global.timeratio; // Frame time of the vector (not set)
float TimeScale = global.timescale; // How much frame time affects the vector's fade (not set)
float LengthRatio = global.lengthratio; // Size at which fade is maximum
float LengthScale = global.lengthscale; // How much length affects the vector's fade
float BeamSmooth = global.beamsmooth;
// vec2 SizeInfo;
// vec4 Color;
const vec2 SizeInfo = vec2(1.0);
const vec4 Color = vec4(1.0);
//-----------------------------------------------------------------------------
// Functions
//-----------------------------------------------------------------------------
// www.iquilezles.org/www/articles/distfunctions/distfunctions.htm
float roundBox(vec2 p, vec2 b, float r)
{
return length(max(abs(p) - b + r, 0.0f)) - r;
}
float GetBoundsFactor(vec2 coord, vec2 bounds, float radiusAmount, float smoothAmount)
{
// reduce smooth amount down to radius amount
smoothAmount = min(smoothAmount, radiusAmount);
float range = min(bounds.x, bounds.y);
float amountMinimum = 1.0f / range;
float radius = range * max(radiusAmount, amountMinimum);
float smooth_ = 1.0f / (range * max(smoothAmount, amountMinimum * 2.0f));
// compute box
float box = roundBox(bounds * (coord * 2.0f), bounds, radius);
// apply smooth_
box *= smooth_;
box += 1.0f - pow(smooth_ * 0.5f, 0.5f);
float border = smoothstep(1.0f, 0.0f, box);
return saturate(border);
}
#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()
{
if(!VectorScreen)
{
FragColor = texture(Source, vTexCoord);
return;
}
else
{
vec2 lineSize = SizeInfo / max(TargetDims.x, TargetDims.y); // normalize
float lineLength = lineSize.x;
float lineLengthRatio = params.LengthRatio;
float lineLengthScale = params.LengthScale;
float timeModulate = mix(1.0f, params.TimeRatio, params.TimeScale);
float lengthModulate = 1.0f - clamp(lineLength / lineLengthRatio, 0.0f, 1.0f);
float timeLengthModulate = mix(1.0f, timeModulate * lengthModulate, params.LengthScale);
vec4 outColor = vec4(timeLengthModulate, timeLengthModulate, timeLengthModulate, 1.0f);
outColor *= Color;
float RoundCornerFactor = GetBoundsFactor(vTexCoord - 0.5f, SizeInfo, 1.0f, params.BeamSmooth);
outColor.rgb *= RoundCornerFactor;
FragColor = outColor;
}
}

View file

@ -1,71 +0,0 @@
#version 450
// license:BSD-3-Clause
// copyright-holders:Ryan Holtz, W. M. Martinez
//-----------------------------------------------------------------------------
// Primary Effect
//-----------------------------------------------------------------------------
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;
//-----------------------------------------------------------------------------
// Macros
//-----------------------------------------------------------------------------
#define LUT_TEXTURE_WIDTH 4096.0f
#define LUT_SIZE 64.0f
#define LUT_SCALE vec2(1.0f / LUT_TEXTURE_WIDTH, 1.0f / LUT_SIZE)
#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 MaskTexture;
#define DiffuseSampler Source
#define LutSampler MaskTexture
//-----------------------------------------------------------------------------
// Utilities
//-----------------------------------------------------------------------------
vec3 apply_lut(vec3 color)
{
// NOTE: Do not change the order of parameters here.
vec3 lutcoord = vec3((color.rg * (LUT_SIZE - 1.0f) + 0.5f) *
LUT_SCALE, color.b * (LUT_SIZE - 1.0f));
float shift = floor(lutcoord.z);
lutcoord.x += shift * LUT_SCALE.y;
color.rgb = mix(texture(LutSampler, lutcoord.xy).rgb, texture(LutSampler,
float2(lutcoord.x + LUT_SCALE.y, lutcoord.y)).rgb,
lutcoord.z - shift);
return color;
}
void main()
{
FragColor = vec4(texture(Source, vTexCoord).rgb, 1.0);
}

View file

@ -1,35 +0,0 @@
#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;
void main()
{
FragColor = vec4(texture(Source, vTexCoord).rgb, 1.0);
}