Platform: Added some fun example post processing shaders. exec postproc_*.cfg in console. It should suggest a few.

This commit is contained in:
Marco Cawthorne 2020-09-25 14:03:44 +02:00
parent dbd5b5d566
commit 776790075a
10 changed files with 648 additions and 0 deletions

View File

@ -0,0 +1,49 @@
//
// Copyright (c) 2016-2020 Marco Hladik <marco@icculus.org>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
!!samps screen=0
!!ver 120
#include "sys/defs.h"
varying vec2 texcoord;
#ifdef VERTEX_SHADER
void main()
{
texcoord = v_texcoord.xy;
texcoord.y = 1.0 - texcoord.y;
gl_Position = ftetransform();
}
#endif
#ifdef FRAGMENT_SHADER
uniform vec2 e_sourcesize;
void main(void)
{
vec3 col = texture2D(s_screen, texcoord).rgb;
/* just downconvert to 16-bit... if this was Unreal we'd dither first. */
col.rgb = floor(col.rgb * vec3(32,64,32))/vec3(32,64,32);
gl_FragColor = vec4(col, 1.0);
}
#endif

View File

@ -0,0 +1,96 @@
//
// Copyright (c) 2016-2020 Marco Hladik <marco@icculus.org>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
!!samps screen=0
!!ver 120
#include "sys/defs.h"
varying vec2 texcoord;
#ifdef VERTEX_SHADER
void main()
{
texcoord = v_texcoord.xy;
texcoord.y = 1.0 - texcoord.y;
gl_Position = ftetransform();
}
#endif
#ifdef FRAGMENT_SHADER
uniform vec2 e_sourcesize;
// from https://github.com/hughsk/glsl-dither/blob/master/4x4.glsl
vec3 p_dither(vec2 position, vec3 col)
{
float brightness = col.r + col.g + col.b / 3.0;
int x = int(mod(position.x, 4.0));
int y = int(mod(position.y, 4.0));
int index = x + y * 4;
float limit = 0.0;
if (x < 8) {
if (index == 0) limit = 0.0625;
if (index == 1) limit = 0.5625;
if (index == 2) limit = 0.1875;
if (index == 3) limit = 0.6875;
if (index == 4) limit = 0.8125;
if (index == 5) limit = 0.3125;
if (index == 6) limit = 0.9375;
if (index == 7) limit = 0.4375;
if (index == 8) limit = 0.25;
if (index == 9) limit = 0.75;
if (index == 10) limit = 0.125;
if (index == 11) limit = 0.625;
if (index == 12) limit = 1.0;
if (index == 13) limit = 0.5;
if (index == 14) limit = 0.875;
if (index == 15) limit = 0.375;
}
return col * (brightness < limit ? 0.0 : 1.0);
}
vec3 p_gamma(vec3 col)
{
float gamma = 0.75f;
col.r = pow(col.r, 1.0 / gamma);
col.g = pow(col.g, 1.0 / gamma);
col.b = pow(col.b, 1.0 / gamma);
return col;
}
void main(void)
{
vec2 pos = vec2(gl_FragCoord.x, gl_FragCoord.y);
vec3 col = texture2D(s_screen, texcoord).rgb;
col = p_gamma(col);
// dither me
col = mix(col, p_dither(pos, col), 0.5f);
// 16-bit ify
col.rgb = floor(col.rgb * vec3(32,64,32))/vec3(32,64,32);
gl_FragColor = vec4(col, 1.0);
}
#endif

View File

@ -0,0 +1,154 @@
//
// Copyright (c) 2016-2020 Marco Hladik <marco@icculus.org>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
!!samps screen=0
!!ver 120
#include "sys/defs.h"
varying vec2 texcoord;
#ifdef VERTEX_SHADER
void main()
{
texcoord = v_texcoord.xy;
texcoord.y = 1.0 - texcoord.y;
gl_Position = ftetransform();
}
#endif
#ifdef FRAGMENT_SHADER
uniform vec2 e_sourcesize;
// from https://github.com/hughsk/glsl-dither/blob/master/8x8.glsl
vec3 p_dither(vec2 position, vec3 col)
{
float brightness = col.r + col.g + col.b / 3.0;
int x = int(mod(position.x, 8.0));
int y = int(mod(position.y, 8.0));
int index = x + y * 8;
float limit = 0.0;
if (x < 8) {
if (index == 0) limit = 0.015625;
if (index == 1) limit = 0.515625;
if (index == 2) limit = 0.140625;
if (index == 3) limit = 0.640625;
if (index == 4) limit = 0.046875;
if (index == 5) limit = 0.546875;
if (index == 6) limit = 0.171875;
if (index == 7) limit = 0.671875;
if (index == 8) limit = 0.765625;
if (index == 9) limit = 0.265625;
if (index == 10) limit = 0.890625;
if (index == 11) limit = 0.390625;
if (index == 12) limit = 0.796875;
if (index == 13) limit = 0.296875;
if (index == 14) limit = 0.921875;
if (index == 15) limit = 0.421875;
if (index == 16) limit = 0.203125;
if (index == 17) limit = 0.703125;
if (index == 18) limit = 0.078125;
if (index == 19) limit = 0.578125;
if (index == 20) limit = 0.234375;
if (index == 21) limit = 0.734375;
if (index == 22) limit = 0.109375;
if (index == 23) limit = 0.609375;
if (index == 24) limit = 0.953125;
if (index == 25) limit = 0.453125;
if (index == 26) limit = 0.828125;
if (index == 27) limit = 0.328125;
if (index == 28) limit = 0.984375;
if (index == 29) limit = 0.484375;
if (index == 30) limit = 0.859375;
if (index == 31) limit = 0.359375;
if (index == 32) limit = 0.0625;
if (index == 33) limit = 0.5625;
if (index == 34) limit = 0.1875;
if (index == 35) limit = 0.6875;
if (index == 36) limit = 0.03125;
if (index == 37) limit = 0.53125;
if (index == 38) limit = 0.15625;
if (index == 39) limit = 0.65625;
if (index == 40) limit = 0.8125;
if (index == 41) limit = 0.3125;
if (index == 42) limit = 0.9375;
if (index == 43) limit = 0.4375;
if (index == 44) limit = 0.78125;
if (index == 45) limit = 0.28125;
if (index == 46) limit = 0.90625;
if (index == 47) limit = 0.40625;
if (index == 48) limit = 0.25;
if (index == 49) limit = 0.75;
if (index == 50) limit = 0.125;
if (index == 51) limit = 0.625;
if (index == 52) limit = 0.21875;
if (index == 53) limit = 0.71875;
if (index == 54) limit = 0.09375;
if (index == 55) limit = 0.59375;
if (index == 56) limit = 1.0;
if (index == 57) limit = 0.5;
if (index == 58) limit = 0.875;
if (index == 59) limit = 0.375;
if (index == 60) limit = 0.96875;
if (index == 61) limit = 0.46875;
if (index == 62) limit = 0.84375;
if (index == 63) limit = 0.34375;
}
return col * (brightness < limit ? 0.0 : 1.0);
}
vec3 p_gamma(vec3 col)
{
float gamma = 1.5;
float lines = mod(gl_FragCoord.y, 2.0);
// scanlines.
if (lines < 1.0) {
gamma = 1.0f;
}
col.r = pow(col.r, 1.0 / gamma);
col.g = pow(col.g, 1.0 / gamma);
col.b = pow(col.b, 1.0 / gamma);
return col;
}
void main(void)
{
vec2 pos = vec2(gl_FragCoord.x, gl_FragCoord.y);
vec3 col = texture2D(s_screen, texcoord).rgb;
// mess with the gamma
col = p_gamma(col);
// dither comes last... we only want to mix some of it in
col = mix(col, p_dither(pos, col), 0.2f);
// 24 to 16
col.rgb = floor(col.rgb * vec3(32,64,32))/vec3(32,64,32);
gl_FragColor = vec4(col, 1.0);
}
#endif

View File

@ -0,0 +1,65 @@
// fake 3dfx voodoo settings
// aesthetic feature only
seta gl_texturemode GL_LINEAR_MIPMAP_LINEAR
seta d_mipcap 0 1000
// software mode doesn't have any real size limitations
seta gl_max_size 8192
// make sure those gl vars are set to a minimal setting
seta gl_affinemodels 0
seta gl_blendsprites 0
seta gl_flashblend 0
seta gl_overbright 0
seta gl_picmip 0
seta gl_polyblend 1
seta gl_specular 0
seta gl_texture_anisotropic_filtering 0
// interpolation
seta cl_nolerp 0
seta r_noframegrouplerp 0
seta r_nolerp 0
// lighting
seta r_lightmap 0
seta r_lightmap_format rgb8
seta r_nolightdir 0
seta r_loadlit 1
// FBO settings
seta r_renderscale 1
// glsl trickery
seta r_glsl_offsetmapping 0
seta r_softwarebanding 0
seta r_postprocshader ""
seta gl_ldr 1
// 3dfx GL Quake did not bother respecting colormaps, HL doesn't have one
seta r_fb_bmodels 1
seta r_fb_models 1
// shadows
seta r_shadows 2
seta r_shadow_realtime_dlight 0
seta r_shadow_realtime_dlight_shadows 0
seta r_shadow_realtime_world 0
// rest of the video gang
seta r_bloom 0
seta r_coronas 0
seta r_deluxemapping 0
seta r_drawflame 1
seta r_drawflat 0
seta r_dynamic 1
seta r_fastsky 0
seta r_lavastyle 1
seta r_stains 0
seta r_waterstyle 1
seta r_waterwarp 0
seta vid_hardwaregamma 1
// apply
vid_reload

View File

@ -0,0 +1,65 @@
// fake 3dfx voodoo settings
// aesthetic feature only
seta gl_texturemode GL_LINEAR_MIPMAP_LINEAR
seta d_mipcap 0 1000
// no limitations
seta gl_max_size 8192
// make sure those gl vars are set to a minimal setting
seta gl_affinemodels 0
seta gl_blendsprites 0
seta gl_flashblend 0
seta gl_overbright 2
seta gl_picmip 0
seta gl_polyblend 1
seta gl_specular 0
seta gl_texture_anisotropic_filtering 0
// interpolation
seta cl_nolerp 0
seta r_noframegrouplerp 0
seta r_nolerp 0
// lighting
seta r_lightmap 0
seta r_lightmap_format rgb9e5
seta r_nolightdir 0
seta r_loadlit 1
// FBO settings
seta r_renderscale 1
// glsl trickery
seta r_glsl_offsetmapping 0
seta r_softwarebanding 0
seta r_postprocshader ""
seta gl_ldr 0
// colormap related
seta r_fb_bmodels 1
seta r_fb_models 1
// shadows
seta r_shadows 0
seta r_shadow_realtime_dlight 0
seta r_shadow_realtime_dlight_shadows 0
seta r_shadow_realtime_world 0
// rest of the video gang
seta r_bloom 0
seta r_coronas 0
seta r_deluxemapping 0
seta r_drawflame 1
seta r_drawflat 0
seta r_dynamic 1
seta r_fastsky 0
seta r_lavastyle 1
seta r_stains 0
seta r_waterstyle 1
seta r_waterwarp 1
seta vid_hardwaregamma 1
// apply
vid_reload

View File

@ -0,0 +1,65 @@
// fake 3dfx voodoo settings
// aesthetic feature only
seta gl_texturemode GL_NEAREST_MIPMAP_NEAREST
seta d_mipcap 0 1000
// software mode doesn't have any real size limitations
seta gl_max_size 8192
// make sure those gl vars are set to a minimal setting
seta gl_affinemodels 1
seta gl_blendsprites 0
seta gl_flashblend 0
seta gl_overbright 0
seta gl_picmip 0
seta gl_polyblend 1
seta gl_specular 0
seta gl_texture_anisotropic_filtering 0
// interpolation
seta cl_nolerp 1
seta r_noframegrouplerp 0
seta r_nolerp 1
// lighting
seta r_lightmap 0
seta r_lightmap_format rgb8
seta r_nolightdir 1
seta r_loadlit 0
// FBO settings
seta r_renderscale 1
// glsl trickery
seta r_glsl_offsetmapping 0
seta r_softwarebanding 1
seta r_postprocshader postproc_software
seta gl_ldr 1
// 3dfx GL Quake did not bother respecting colormaps, HL doesn't have one
seta r_fb_bmodels 1
seta r_fb_models 1
// shadows
seta r_shadows 0
seta r_shadow_realtime_dlight 0
seta r_shadow_realtime_dlight_shadows 0
seta r_shadow_realtime_world 0
// rest of the video gang
seta r_bloom 0
seta r_coronas 0
seta r_deluxemapping 0
seta r_drawflame 1
seta r_drawflat 0
seta r_dynamic 1
seta r_fastsky 0
seta r_lavastyle 1
seta r_stains 0
seta r_waterstyle 1
seta r_waterwarp 1
seta vid_hardwaregamma 1
// apply
vid_reload

View File

@ -0,0 +1,65 @@
// fake 3dfx voodoo settings
// aesthetic feature only
seta gl_texturemode GL_NEAREST_MIPMAP_NEAREST
seta d_mipcap 0 1000
// software mode doesn't have any real size limitations
seta gl_max_size 8192
// make sure those gl vars are set to a minimal setting
seta gl_affinemodels 1
seta gl_blendsprites 0
seta gl_flashblend 0
seta gl_overbright 2
seta gl_picmip 0
seta gl_polyblend 1
seta gl_specular 0
seta gl_texture_anisotropic_filtering 0
// interpolation
seta cl_nolerp 1
seta r_noframegrouplerp 0
seta r_nolerp 1
// lighting
seta r_lightmap 0
seta r_lightmap_format rgb9e5
seta r_nolightdir 0
seta r_loadlit 0
// FBO settings
seta r_renderscale 1
// glsl trickery
seta r_glsl_offsetmapping 0
seta r_softwarebanding 1
seta r_postprocshader postproc_unreal
seta gl_ldr 0
// 3dfx GL Quake did not bother respecting colormaps, HL doesn't have one
seta r_fb_bmodels 1
seta r_fb_models 1
// shadows
seta r_shadows 0
seta r_shadow_realtime_dlight 0
seta r_shadow_realtime_dlight_shadows 0
seta r_shadow_realtime_world 0
// rest of the video gang
seta r_bloom 0
seta r_coronas 0
seta r_deluxemapping 0
seta r_drawflame 1
seta r_drawflat 0
seta r_dynamic 1
seta r_fastsky 0
seta r_lavastyle 1
seta r_stains 0
seta r_waterstyle 1
seta r_waterwarp 1
seta vid_hardwaregamma 1
// apply
vid_reload

View File

@ -0,0 +1,65 @@
// fake 3dfx voodoo settings
// aesthetic feature only
seta gl_texturemode GL_LINEAR_MIPMAP_LINEAR
seta d_mipcap 0 1000
// 3dfx cards of the time could only handle 256 wide textures
seta gl_max_size 256
// make sure those gl vars are set to a minimal setting
seta gl_affinemodels 0
seta gl_blendsprites 0
seta gl_flashblend 0
seta gl_overbright 0
seta gl_picmip 0
seta gl_polyblend 1
seta gl_specular 0
seta gl_texture_anisotropic_filtering 0
// interpolation
seta cl_nolerp 0
seta r_noframegrouplerp 1
seta r_nolerp 0
// lighting
seta r_lightmap 0
seta r_lightmap_format rgb8
seta r_nolightdir 1
seta r_loadlit 0
// FBO settings
seta r_renderscale 1
// glsl trickery
seta r_glsl_offsetmapping 0
seta r_softwarebanding 0
seta r_postprocshader postproc_voodoo
seta gl_ldr 1
// 3dfx GL Quake did not bother respecting colormaps, HL doesn't have one
seta r_fb_bmodels 0
seta r_fb_models 0
// shadows
seta r_shadows 0
seta r_shadow_realtime_dlight 0
seta r_shadow_realtime_dlight_shadows 0
seta r_shadow_realtime_world 0
// rest of the video gang
seta r_bloom 0
seta r_coronas 0
seta r_deluxemapping 0
seta r_drawflame 1
seta r_drawflat 0
seta r_dynamic 1
seta r_fastsky 0
seta r_lavastyle 1
seta r_stains 0
seta r_waterstyle 1
seta r_waterwarp 0
seta vid_hardwaregamma 1
// apply
vid_reload

View File

@ -0,0 +1,16 @@
postproc_software
{
program postproc_software
{
map $sourcecolour
nodepthtest
}
}
postproc_unreal
{
program postproc_unreal
{
map $sourcecolour
nodepthtest
}
}

View File

@ -0,0 +1,8 @@
postproc_voodoo
{
program postproc_voodoo
{
map $sourcecolour
nodepthtest
}
}