[FTEQW] Bandither - A "Retro" Dithering and Colorband Shader

Discuss programming topics that involve the OpenGL API.
Post Reply
Immorpher
Posts: 6
Joined: Sun May 01, 2022 12:54 am
Contact:

[FTEQW] Bandither - A "Retro" Dithering and Colorband Shader

Post by Immorpher »

I am new to this forum, but I already see a lot of familiar people! I decided to join as I seen some FTEQW and shader talk here, so I thought I would share the shader I just released. Bandither is a non-linear "software-like" color banding and dithering shader for FTEQW (and GZDoom). This does not use the specific palette, rather it non-linearly quantizes each color channel which works well as an all-around shader darker games like Quake and modern colored lighting. It has 5 different dithering modes all adjustable from pure color bands to full dithering. The amount of colors and their non-linear banding can be adjusted too.

Download Here: https://github.com/Immorpher/Bandither/releases/


Screenshots:
All screenshots were taken at half resolution (to show off the dither better), with 8 color levels per channel (512 total colors), and a banding curve of 5 (which has more darker color levels). Color levels can be reduced to 2 per channel or increased much higher. Refer to the twitter post: https://twitter.com/immorpher64/status/ ... 0229944320


Videos:
It is hard to see the dither effects through the YouTube video compression. But you can catch glimpses of it in HD resolution.
Dither Type: Bayer 8x8, Dither Amount: 0.5 https://youtu.be/-wo27fVaBcE
Dither Type: Scanline, Dither Amount: 1 https://youtu.be/teG4uWo2Q10
Dither Type: Scanline, Dither Amount: 0.5 https://youtu.be/6ujS4py7pDw
Dither Type: Motion Noise, Dither Amount: 0.5 https://youtu.be/7ZElNXh4laI


FTEQW Instructions:
To install this shader, move the "glsl" and "scripts" folder into the "id1" directory within the FTEQW directory. To use this shader, either add "r_postprocshader bandither" text to your fte.cfg or autoexec.cfg file, or when the game is loaded open the console with the "'" key and type the command in. This only works with OpenGL rendering with FTEQW.

Within the "glsl" folder there is a "bandither.glsl" file which has options you can use to cusomize the shader:
"coloramt" is the amount of colors per channel (red,green,blue). The lower the number, the more more bands and less colors used.
"bandcurve" is the amount to non-linearly skew banding. Higher numbers have smoother darks and band brights more, which is good for dark games.
"ditheramt" is the amount of dithering from 0 to 1, and inbetween. A value of 0 produces sharp color bands, while 1 is completely dithered.
"ditherscale" is the pixel scale for dithering. Normally it should be 1, but if you are playing at a lower resolution, this may need to be increased to match pixel size.
"dithertype" has five styles of dithering which include: Bayer 2x2, Bayer 8x8, static noise, motion noise, and scanline dithering.[/spoiler]


Feel free to offer suggestions, as I am new to making shaders and wouldn't mind adding some features. I would like to eventually learn how to apply this shader directly to the resized textures for a "Serious Sam"-like detail effect. Also since FTEQW gives access to the depth buffer (which I learned from this forum), I would like to make an ambient occlusion shader (like the KEX Quake). Learning these advanced shader techniques has been slow though!
Eukara
Posts: 22
Joined: Fri Jul 22, 2011 3:00 pm
Location: /dev/cdrom
Contact:

Re: [FTEQW] Bandither - A "Retro" Dithering and Colorband Shader

Post by Eukara »

Wow! Awesome release.

I have nothing to add, besides perhaps suggesting that the install process is as simple as renaming the .zip from your Releases page on GitHub to a .pk3 extension and you can plop them whole thing into id1/ as-is! That's all. Cool work!
Immorpher
Posts: 6
Joined: Sun May 01, 2022 12:54 am
Contact:

Re: [FTEQW] Bandither - A "Retro" Dithering and Colorband Shader

Post by Immorpher »

I completely forgot that FTEQW had PK3 with its Quake 3 support. That will be easy to do!

I have also made a recent update to add more dither types as well: https://twitter.com/immorpher64/status/ ... 1604486144

I am still looking into ambient occlusion; I think I will start badgering more knowledgeable people haha.
Eukara
Posts: 22
Joined: Fri Jul 22, 2011 3:00 pm
Location: /dev/cdrom
Contact:

Re: [FTEQW] Bandither - A "Retro" Dithering and Colorband Shader

Post by Eukara »

Spike would probably know exactly where to start in regards to SSAO!
Immorpher
Posts: 6
Joined: Sun May 01, 2022 12:54 am
Contact:

Re: [FTEQW] Bandither - A "Retro" Dithering and Colorband Shader

Post by Immorpher »

Eukara wrote: Thu May 05, 2022 4:47 pm Spike would probably know exactly where to start in regards to SSAO!
Oh I bet! I have pestered poor Spike so much in the past haha.

From my researching I will need a depth buffer, which from the shader showcase it seems to have. A "normal" buffer with angles will help too. But if not, normals can be calculated from the depth buffer.
Immorpher
Posts: 6
Joined: Sun May 01, 2022 12:54 am
Contact:

Re: [FTEQW] Bandither - A "Retro" Dithering and Colorband Shader

Post by Immorpher »

Perhaps jumping the shark with this one! The latest Bandither update lets you blend dither styles. This is to quench my obsession to add a bit of noise to dithers. But also I found you could get some funky results by blending two unrelated style. Also the motion noise now varies with time, so you can add some time-varying noise to any dither. To make up for jumping the shark, I did clean some of the code! https://github.com/Immorpher/Bandither/releases/

I will eventually get the FTEQW shader in a pk3 as well, once I learn how to set some of the shader options as CVars. I seen you could do that in the GLSL showreel, just need to learn from that!
Eukara
Posts: 22
Joined: Fri Jul 22, 2011 3:00 pm
Location: /dev/cdrom
Contact:

Re: [FTEQW] Bandither - A "Retro" Dithering and Colorband Shader

Post by Eukara »

For cvars in GLSL shaders, you can add something like:

Code: Select all

!!cvardf r_skipFoobar
At the top of the shader (after your samplers)

and then inside your functions:

Code: Select all

	#if r_skipFoobar == 0
		// inactive
	#else
		// active
	#endif
Immorpher
Posts: 6
Joined: Sun May 01, 2022 12:54 am
Contact:

Re: [FTEQW] Bandither - A "Retro" Dithering and Colorband Shader

Post by Immorpher »

Eukara wrote: Thu May 12, 2022 6:36 pm For cvars in GLSL shaders, you can add something like:

Code: Select all

!!cvardf r_skipFoobar
At the top of the shader (after your samplers)

and then inside your functions:

Code: Select all

	#if r_skipFoobar == 0
		// inactive
	#else
		// active
	#endif
Nice that seems simple enough! Is there a way to set a default value for the cvar? Like... !!cvardf r_skipFoobar = 0

I am going to see if I can find info on that.
Immorpher
Posts: 6
Joined: Sun May 01, 2022 12:54 am
Contact:

Re: [FTEQW] Bandither - A "Retro" Dithering and Colorband Shader

Post by Immorpher »

On a google search I seen something like this

!!cvardf r_glsl_turbscale_reflect=1

So it looks like thats how its done! Ill get working on it
Eukara
Posts: 22
Joined: Fri Jul 22, 2011 3:00 pm
Location: /dev/cdrom
Contact:

Re: [FTEQW] Bandither - A "Retro" Dithering and Colorband Shader

Post by Eukara »

Cool! Can't wait to see what's next :biggrin:
Post Reply