combine both vhs shaders
not sure why i didnt think of this lul saves us another screen texture copy and draw so shit is even faster
This commit is contained in:
1 parent
d60d9d5611
commit
df8f167549
4 files changed
+14
-56
No files matched your search
@@ -199,8 +199,7 @@ enum
|
||||
SHADER_POSTPROCESS_WATER,
|
||||
SHADER_POSTPROCESS_HEAT,
|
||||
|
||||
SHADER_VHS_FUZZ,
|
||||
SHADER_VHS_BAR,
|
||||
SHADER_VHS,
|
||||
|
||||
NUMSHADERTARGETS
|
||||
};
|
||||
|
||||
@@ -59,11 +59,8 @@ static struct {
|
||||
// heat postprocess shader
|
||||
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_POSTPROCESS_FRAGMENT_HEAT},
|
||||
|
||||
// vhs fuzz
|
||||
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_VHS_FUZZ_SHADER},
|
||||
|
||||
// vhs bars
|
||||
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_VHS_BAR_SHADER},
|
||||
// VHS effect
|
||||
{GLSL_DEFAULT_VERTEX_SHADER, GLSL_VHS_SHADER},
|
||||
|
||||
{NULL, NULL},
|
||||
};
|
||||
@@ -458,8 +455,7 @@ customshaderxlat_t shaderxlat[] =
|
||||
{"UIColormapFade", SHADER_UI_COLORMAP_FADE},
|
||||
{"PostProcessWater", SHADER_POSTPROCESS_WATER},
|
||||
{"PostProcessHeat", SHADER_POSTPROCESS_HEAT},
|
||||
{"VHSFuzz", SHADER_VHS_FUZZ},
|
||||
{"VHSBar", SHADER_VHS_BAR},
|
||||
{"VHS", SHADER_VHS},
|
||||
{NULL, 0},
|
||||
};
|
||||
|
||||
|
||||
@@ -409,15 +409,20 @@
|
||||
"gl_FragColor = texture2D(tex, uv);\n" \
|
||||
"}\0"
|
||||
|
||||
// screen fuzzyness
|
||||
// VHS effect as a shader
|
||||
// basically just what we did before as a shader lul
|
||||
// the bars are just the RR heat shader repurposed
|
||||
// thanks "stackoverflow.com/a/4275343" for the pseudo random stuff for glsl
|
||||
#define GLSL_VHS_FUZZ_SHADER \
|
||||
// and thanks "thndl.com/triangle-waves" and "gamedev.stackexchange.com/q/191829"
|
||||
// for the maths since im super bad at stuff
|
||||
// 0.159155 = 1/pi*2
|
||||
#define GLSL_VHS_SHADER \
|
||||
"#version 120\n" \
|
||||
"uniform sampler2D tex;\n" \
|
||||
"uniform vec2 scr_resolution;\n" \
|
||||
"uniform vec2 scr_tex_size;\n" \
|
||||
"uniform float vhs_time;\n" \
|
||||
"uniform float vhs_rewind;\n" \
|
||||
"uniform float scr_dup;\n" \
|
||||
"void main(void) {\n" \
|
||||
"vec2 uv = gl_TexCoord[0].st;\n" \
|
||||
@@ -426,27 +431,6 @@
|
||||
"float ystep = (2.0 / scr_resolution.y) * scr_dup / 4.0;\n" \
|
||||
"float rand = fract(sin((floor(y / ystep) + vhs_time) * 12.9898 + 78.233) * 43758.5453);\n" \
|
||||
"uv.x -= floor(rand * 128.0) / -22000.0;\n" \
|
||||
"uv.y = clamp(uv.y, 0.0, maxuv.y - 0.0001);\n" \
|
||||
"uv.x = mod(uv.x, maxuv.x - 0.0001);\n" \
|
||||
"gl_FragColor = texture2D(tex, uv);\n" \
|
||||
"}\0"
|
||||
|
||||
// repurposed the RR heat shader
|
||||
// since it kinda matched the vhs bars lul
|
||||
// thanks "thndl.com/triangle-waves" and "gamedev.stackexchange.com/q/191829"
|
||||
// for the maths since im super bad at stuff
|
||||
// 0.159155 = 1/pi*2
|
||||
#define GLSL_VHS_BAR_SHADER \
|
||||
"#version 120\n" \
|
||||
"uniform sampler2D tex;\n" \
|
||||
"uniform vec2 scr_resolution;\n" \
|
||||
"uniform vec2 scr_tex_size;\n" \
|
||||
"uniform float vhs_time;\n" \
|
||||
"uniform float vhs_rewind;\n" \
|
||||
"void main(void) {\n" \
|
||||
"vec2 uv = gl_TexCoord[0].st;\n" \
|
||||
"vec2 maxuv = scr_resolution / scr_tex_size;\n" \
|
||||
"float y = 1.0 - uv.y;\n" \
|
||||
"float updistort = (vhs_rewind > 0.5) ? 0.266667 : 0.16;\n" \
|
||||
"float downdistort = updistort / 2.0;\n" \
|
||||
"float downspd = (vhs_rewind > 0.5) ? 2.0 : 1.0;\n" \
|
||||
@@ -460,14 +444,13 @@
|
||||
"vec4 color = texture2D(tex, uv);\n" \
|
||||
"float downcol = step(0.00001, downbar);\n" \
|
||||
"float upcol = step(0.00001, upbar);\n" \
|
||||
"color.rgb = mix(color.rgb, color.rgb * (220.0 / 255.0), downcol);\n" \
|
||||
"color.rgb = mix(color.rgb, color.rgb * (220.0 / 255.0), upcol);\n" \
|
||||
"color.rgb = mix(color.rgb, color.rgb * (210.0 / 255.0), downcol);\n" \
|
||||
"color.rgb = mix(color.rgb, color.rgb * (210.0 / 255.0), upcol);\n" \
|
||||
"color.a = mix(color.a, color.a * (250.0 / 255.0), downcol);\n" \
|
||||
"color.a = mix(color.a, color.a * (250.0 / 255.0), upcol);\n" \
|
||||
"gl_FragColor = color;\n" \
|
||||
"}\0"
|
||||
|
||||
|
||||
// ================
|
||||
// Fallback shaders
|
||||
// ================
|
||||
|
||||
@@ -3906,7 +3906,7 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8
|
||||
pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]);
|
||||
tex_downloaded = screenTextures[HWD_SCREENTEXTURE_VHS];
|
||||
|
||||
GL_SetShader(HWR_GetShaderFromTarget(SHADER_VHS_FUZZ));
|
||||
GL_SetShader(HWR_GetShaderFromTarget(SHADER_VHS));
|
||||
GL_Shader_SetUniforms(NULL, NULL, NULL, NULL);
|
||||
pglColor4ubv(white);
|
||||
|
||||
@@ -3916,26 +3916,6 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8
|
||||
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
GL_UnSetShader();
|
||||
|
||||
// Upward and Downward bars
|
||||
// theyre combined since the original shader also did this
|
||||
// also saves us another screen copy + draw anyways
|
||||
GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS);
|
||||
pglActiveTexture(GL_TEXTURE0);
|
||||
pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]);
|
||||
tex_downloaded = screenTextures[HWD_SCREENTEXTURE_VHS];
|
||||
|
||||
GL_SetShader(HWR_GetShaderFromTarget(SHADER_VHS_BAR));
|
||||
GL_Shader_SetUniforms(NULL, NULL, NULL, NULL);
|
||||
pglColor4ubv(white);
|
||||
|
||||
pglEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
pglTexCoordPointer(2, GL_FLOAT, 0, fix);
|
||||
pglVertexPointer(3, GL_FLOAT, 0, defaultscreenVerts);
|
||||
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
GL_UnSetShader();
|
||||
|
||||
}
|
||||
else // fallback fixed function version, this is quite slow
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user