mirror of
https://github.com/italicsjenga/slang-shaders.git
synced 2024-11-24 16:41:31 +11:00
add old 3dfx shader
This commit is contained in:
parent
a4892fa2a3
commit
91a3e4d8d9
18
3dfx/shaders/old/3dfx_4x1.slangp
Normal file
18
3dfx/shaders/old/3dfx_4x1.slangp
Normal file
|
@ -0,0 +1,18 @@
|
|||
shaders = 6
|
||||
shader0 = 3dfx_pass_0.slang
|
||||
shader1 = 3dfx_pass_1.slang
|
||||
shader2 = 3dfx_pass_2.slang
|
||||
shader3 = 3dfx_pass_2.slang
|
||||
shader4 = 3dfx_pass_2.slang
|
||||
shader5 = 3dfx_pass_2.slang
|
||||
|
||||
filter_linear0 = true
|
||||
filter_linear1 = true
|
||||
filter_linear2 = true
|
||||
filter_linear3 = true
|
||||
filter_linear4 = true
|
||||
|
||||
scale_type_x0 = "source"
|
||||
scale_x0 = "1.000000"
|
||||
scale_type_y0 = "source"
|
||||
scale_y0 = "1.000000"
|
147
3dfx/shaders/old/3dfx_pass_0.slang
Normal file
147
3dfx/shaders/old/3dfx_pass_0.slang
Normal file
|
@ -0,0 +1,147 @@
|
|||
#version 450
|
||||
|
||||
// "LeiFX" shader - "dither" and reduction process
|
||||
//
|
||||
// Copyright (C) 2013-2014 leilei
|
||||
//
|
||||
// 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.
|
||||
|
||||
// This table came from the wikipedia article about Ordered Dithering. NOT MAME. Just to clarify.
|
||||
float erroredtable[16] = {
|
||||
16,4,13,1,
|
||||
8,12,5,9,
|
||||
14,2,15,3,
|
||||
6,10,7,11
|
||||
};
|
||||
|
||||
layout(push_constant) uniform Push
|
||||
{
|
||||
vec4 SourceSize;
|
||||
vec4 OriginalSize;
|
||||
vec4 OutputSize;
|
||||
uint FrameCount;
|
||||
} params;
|
||||
|
||||
#define saturate(c) clamp(c, 0.0, 1.0)
|
||||
#define lerp(c) mix(c)
|
||||
#define mul(a,b) (b*a)
|
||||
#define fmod(c) mod(c)
|
||||
#define frac(c) fract(c)
|
||||
#define tex2D(c,d) texture(c,d)
|
||||
#define float2 vec2
|
||||
#define float3 vec3
|
||||
#define float4 vec4
|
||||
#define int2 ivec2
|
||||
#define int3 ivec3
|
||||
#define int4 ivec4
|
||||
#define bool2 bvec2
|
||||
#define bool3 bvec3
|
||||
#define bool4 bvec4
|
||||
#define float2x2 mat2x2
|
||||
#define float3x3 mat3x3
|
||||
#define float4x4 mat4x4
|
||||
|
||||
layout(std140, set = 0, binding = 0) uniform UBO
|
||||
{
|
||||
mat4 MVP;
|
||||
} global;
|
||||
|
||||
#define DITHERAMOUNT 0.5f // was 0.33f
|
||||
#define DITHERBIAS -1 // 0 to 16, biases the value of the dither up. - was 8
|
||||
|
||||
#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()
|
||||
{
|
||||
float2 res;
|
||||
float3 outcolor = tex2D(Source, vTexCoord).rgb;
|
||||
res.x = params.SourceSize.x;
|
||||
res.y = params.SourceSize.y;
|
||||
|
||||
float2 ditheu = vTexCoord.xy * res.xy;
|
||||
|
||||
ditheu.x = vTexCoord.x * res.x;
|
||||
ditheu.y = vTexCoord.y * res.y;
|
||||
|
||||
// Dither. Total rewrite.
|
||||
// NOW, WHAT PIXEL AM I!??
|
||||
|
||||
int ditdex = int(mod(ditheu.x, 4.0)) * 4 + int(mod(ditheu.y, 4.0)); // 4x4!
|
||||
vec3 color;
|
||||
vec3 colord;
|
||||
color.r = outcolor.r * 255;
|
||||
color.g = outcolor.g * 255;
|
||||
color.b = outcolor.b * 255;
|
||||
float yeh = 0.0;
|
||||
float ohyes = 0.0;
|
||||
|
||||
// for (yeh=ditdex; yeh<(ditdex+16); yeh++) ohyes = pow(erroredtable[yeh-15], 0.72f);
|
||||
if (yeh++==ditdex) ohyes = erroredtable[0];
|
||||
else if (yeh++==ditdex) ohyes = erroredtable[1];
|
||||
else if (yeh++==ditdex) ohyes = erroredtable[2];
|
||||
else if (yeh++==ditdex) ohyes = erroredtable[3];
|
||||
else if (yeh++==ditdex) ohyes = erroredtable[4];
|
||||
else if (yeh++==ditdex) ohyes = erroredtable[5];
|
||||
else if (yeh++==ditdex) ohyes = erroredtable[6];
|
||||
else if (yeh++==ditdex) ohyes = erroredtable[7];
|
||||
else if (yeh++==ditdex) ohyes = erroredtable[8];
|
||||
else if (yeh++==ditdex) ohyes = erroredtable[9];
|
||||
else if (yeh++==ditdex) ohyes = erroredtable[10];
|
||||
else if (yeh++==ditdex) ohyes = erroredtable[11];
|
||||
else if (yeh++==ditdex) ohyes = erroredtable[12];
|
||||
else if (yeh++==ditdex) ohyes = erroredtable[13];
|
||||
else if (yeh++==ditdex) ohyes = erroredtable[14];
|
||||
else if (yeh++==ditdex) ohyes = erroredtable[15];
|
||||
|
||||
colord.r = color.r + ohyes;
|
||||
colord.g = color.g + (ohyes / 2);
|
||||
colord.b = color.b + ohyes;
|
||||
outcolor.rgb = colord.rgb * 0.003921568627451; // divide by 255, i don't trust em
|
||||
|
||||
//
|
||||
// Reduce to 16-bit color
|
||||
//
|
||||
|
||||
float3 why = float3(1.0);
|
||||
float3 reduceme = float3(1.0);
|
||||
float radooct = 32; // 32 is usually the proper value
|
||||
|
||||
reduceme.r = pow(outcolor.r, why.r);
|
||||
reduceme.r *= radooct;
|
||||
reduceme.r = int(floor(reduceme.r));
|
||||
reduceme.r /= radooct;
|
||||
reduceme.r = pow(reduceme.r, why.r);
|
||||
|
||||
reduceme.g = pow(outcolor.g, why.g);
|
||||
reduceme.g *= radooct * 2;
|
||||
reduceme.g = int(floor(reduceme.g));
|
||||
reduceme.g /= radooct * 2;
|
||||
reduceme.g = pow(reduceme.g, why.g);
|
||||
|
||||
reduceme.b = pow(outcolor.b, why.b);
|
||||
reduceme.b *= radooct;
|
||||
reduceme.b = int(floor(reduceme.b));
|
||||
reduceme.b /= radooct;
|
||||
reduceme.b = pow(reduceme.b, why.b);
|
||||
|
||||
outcolor.rgb = reduceme.rgb;
|
||||
|
||||
FragColor = vec4(outcolor, 1.0);
|
||||
}
|
92
3dfx/shaders/old/3dfx_pass_1.slang
Normal file
92
3dfx/shaders/old/3dfx_pass_1.slang
Normal file
|
@ -0,0 +1,92 @@
|
|||
#version 450
|
||||
|
||||
// "LeiFX" shader - Gamma process
|
||||
//
|
||||
// Copyright (C) 2013-2014 leilei
|
||||
//
|
||||
// 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
|
||||
{
|
||||
vec4 SourceSize;
|
||||
vec4 OriginalSize;
|
||||
vec4 OutputSize;
|
||||
uint FrameCount;
|
||||
} params;
|
||||
|
||||
layout(std140, set = 0, binding = 0) uniform UBO
|
||||
{
|
||||
mat4 MVP;
|
||||
} global;
|
||||
|
||||
#define saturate(c) clamp(c, 0.0, 1.0)
|
||||
#define lerp(c) mix(c)
|
||||
#define mul(a,b) (b*a)
|
||||
#define fmod(c) mod(c)
|
||||
#define frac(c) fract(c)
|
||||
#define tex2D(c,d) texture(c,d)
|
||||
#define float2 vec2
|
||||
#define float3 vec3
|
||||
#define float4 vec4
|
||||
#define int2 ivec2
|
||||
#define int3 ivec3
|
||||
#define int4 ivec4
|
||||
#define bool2 bvec2
|
||||
#define bool3 bvec3
|
||||
#define bool4 bvec4
|
||||
#define float2x2 mat2x2
|
||||
#define float3x3 mat3x3
|
||||
#define float4x4 mat4x4
|
||||
|
||||
float mod2(float x, float y)
|
||||
{
|
||||
return x - y * floor (x/y);
|
||||
}
|
||||
|
||||
#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()
|
||||
{
|
||||
float3 outcolor = tex2D(Source, vTexCoord).rgb;
|
||||
|
||||
float2 res;
|
||||
res.x = params.SourceSize.x;
|
||||
res.y = params.SourceSize.y;
|
||||
|
||||
// Gamma scanlines
|
||||
// the Voodoo drivers usually supply a 1.3 gamma setting whether people liked it or not
|
||||
// but it was enough to brainwash the competition for looking 'too dark'
|
||||
|
||||
float gammaed = 0.15;
|
||||
|
||||
float leifx_linegamma = gammaed;
|
||||
float2 dithet = vTexCoord.xy * res.xy;
|
||||
dithet.y = vTexCoord.y * res.y;
|
||||
float horzline1 = (mod2(dithet.y, 2.0));
|
||||
if (horzline1 < 1) leifx_linegamma = 0;
|
||||
float leifx_gamma = 1.3 - gammaed + leifx_linegamma;
|
||||
|
||||
|
||||
outcolor.r = pow(outcolor.r, 1.0 / leifx_gamma);
|
||||
outcolor.g = pow(outcolor.g, 1.0 / leifx_gamma);
|
||||
outcolor.b = pow(outcolor.b, 1.0 / leifx_gamma);
|
||||
|
||||
FragColor = vec4(outcolor, 1.0);
|
||||
}
|
114
3dfx/shaders/old/3dfx_pass_2.slang
Normal file
114
3dfx/shaders/old/3dfx_pass_2.slang
Normal file
|
@ -0,0 +1,114 @@
|
|||
#version 450
|
||||
|
||||
|
||||
// "LeiFX" shader - Pixel filtering process
|
||||
//
|
||||
// Copyright (C) 2013-2014 leilei
|
||||
//
|
||||
// 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
|
||||
{
|
||||
vec4 SourceSize;
|
||||
vec4 OriginalSize;
|
||||
vec4 OutputSize;
|
||||
uint FrameCount;
|
||||
float LEIFX_BLURFACTOR;
|
||||
} params;
|
||||
|
||||
#pragma parameter LEIFX_BLURFACTOR "LeiFX Blur Factor" 0.69 0.00 1.00 0.01
|
||||
|
||||
#define LEIFX_BLURFACTOR params.LEIFX_BLURFACTOR
|
||||
|
||||
layout(std140, set = 0, binding = 0) uniform UBO
|
||||
{
|
||||
mat4 MVP;
|
||||
} global;
|
||||
|
||||
#define saturate(c) clamp(c, 0.0, 1.0)
|
||||
#define lerp(c) mix(c)
|
||||
#define mul(a,b) (b*a)
|
||||
#define fmod(c) mod(c)
|
||||
#define frac(c) fract(c)
|
||||
#define tex2D(c,d) texture(c,d)
|
||||
#define float2 vec2
|
||||
#define float3 vec3
|
||||
#define float4 vec4
|
||||
#define int2 ivec2
|
||||
#define int3 ivec3
|
||||
#define int4 ivec4
|
||||
#define bool2 bvec2
|
||||
#define bool3 bvec3
|
||||
#define bool4 bvec4
|
||||
#define float2x2 mat2x2
|
||||
#define float3x3 mat3x3
|
||||
#define float4x4 mat4x4
|
||||
|
||||
#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()
|
||||
{
|
||||
float3 outcolor = tex2D(Source, vTexCoord).rgb;
|
||||
|
||||
float2 pixel;
|
||||
|
||||
pixel.x = params.SourceSize.z;
|
||||
pixel.y = params.SourceSize.w;
|
||||
|
||||
// Sample things.
|
||||
|
||||
float blendy; // to blend unblended with blend... trying to smooth the jag :(
|
||||
float blenda;
|
||||
|
||||
float blendfactor;
|
||||
|
||||
float3 pixel1 = tex2D(Source, vTexCoord + float2((pixel.x * 0.15), 0)).rgb;
|
||||
float3 pixel2 = tex2D(Source, vTexCoord + float2(-pixel.x * 0.22, 0)).rgb;
|
||||
float3 pixel0 = tex2D(Source, vTexCoord + float2(0, 0)).rgb;
|
||||
|
||||
float3 pixelblend;
|
||||
|
||||
|
||||
float gary1 = dot(pixel1.rgb,float3(1.0));
|
||||
float gary2 = dot(pixel2.rgb,float3(1.0));
|
||||
|
||||
float mean = 1.0;
|
||||
mean = gary1 - gary2;
|
||||
|
||||
if (mean < 0) mean *= -1;
|
||||
if (mean > 1) mean = 1;
|
||||
mean = pow(mean, LEIFX_BLURFACTOR);
|
||||
|
||||
if (mean > 1)
|
||||
mean = 1;
|
||||
|
||||
{
|
||||
// variably BLEND IT ALL TO H*CK!!!!
|
||||
blendy = 1 - mean;
|
||||
blenda = 1 - blendy;
|
||||
pixel0 /= 3;
|
||||
pixel1 /= 3;
|
||||
pixel2 /= 3;
|
||||
pixelblend.rgb = pixel0 + pixel1 + pixel2;
|
||||
outcolor.rgb = (pixelblend.rgb * blendy) + (outcolor.rgb * blenda);
|
||||
}
|
||||
|
||||
FragColor = vec4(outcolor, 1.0);
|
||||
}
|
Loading…
Reference in a new issue