SoftShade - Palette-Friendly Dithering v0.9

SoftShade - Palette-Friendly Dithering v0.9

Postby DenisBelmondo » Sun Feb 06, 2022 1:24 am

welcome...... to the world of true fake 8-bit randering......

A mod that adds ordered dithering to your screen-device.

Image

Download

First and foremost, 80% of the implementation was blatantly lifted from Marisa Kirisame's impeccable MariFX shader suite, which contains a post processing shader that gracefully, with dithering, quantizes the fragment colors to those of a particular palette out of a finite set of palettes. In other words: if you were playing a mod that has a custom palette, those cool new shades of cerulean will not at all be present in the pre-computed Doom Palette LUT and will end up being snapped to or stippled between Doom's blue or grey. My modified implementation aims to fix that issue and fully respects the PLAYPAL lump.

Spoiler: More screenshots


what the shit is this black magic

Seeing that you cannot pass PLAYPAL as a texture uniform, there's no actual way to access the palette as-is in a shader. After kicking around a few solutions, I found one that came to me like a flash of lightning. So, when ZDoom wants to translate a truecolor image, it must first convert it to an indexed image. It doesn't matter if it's a completely meaningless translation like 0:0=0:0, ZDoom will convert it. I exploited this by taking a netural color LUT, fed it into TEXTURES as a patch, and told it to have the aforementioned 0:0=0:0 translation. ZDoom perfectly creates what is essentially a LUT out of whatever array of colors PLAYPAL contains. I then fed that "composited" texture into the shader as a uniform, and from there it's cake.

This is an 0.9 release, meaning that it only goes uphill from here (: Also, It would be nice in future releases to have some kind of Floyd-Steinberg or Ylilouma style dithering. Who knows! Anyhow, hope you enjoy.
Last edited by DenisBelmondo on Sun Feb 06, 2022 2:38 am, edited 2 times in total.
User avatar
DenisBelmondo
now is time to the i386 heart on fire
 
Joined: 06 Jun 2008
Location: Two-Key Return

Re: SoftShade - Palette-Aware Dithering v0.9

Postby Rachael » Sun Feb 06, 2022 1:31 am

Interesting way to downmix the LUT - I hadn't actually thought of that. That being said - I have actually been planning a shader just like this for a couple weeks now.
User avatar
Rachael
^ walking stack of unfinished projects ^
Admin
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle

Re: SoftShade - Palette-Aware Dithering v0.9

Postby DenisBelmondo » Sun Feb 06, 2022 2:09 am

Oh wow, if it made it in as an engine feature that would be fabulous. The existing palette shader is cool, but dithering definitely elevates it and gives it a way more slick #retro type look as well.
User avatar
DenisBelmondo
now is time to the i386 heart on fire
 
Joined: 06 Jun 2008
Location: Two-Key Return

Re: SoftShade - Palette-Aware Dithering v0.9

Postby Rachael » Sun Feb 06, 2022 2:39 am

No - no engine feature for something like this. I just had a different take on how I would have done something like this.
User avatar
Rachael
^ walking stack of unfinished projects ^
Admin
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle

Re: SoftShade - Palette-Friendly Dithering v0.9

Postby DenisBelmondo » Sun Feb 06, 2022 2:46 am

Ahhh my mistake. In any case, I'm sure I can speak on behalf of all softwareheads by saying we will willingly embrace anything that will bring us closer to that type of aesthetic :o
User avatar
DenisBelmondo
now is time to the i386 heart on fire
 
Joined: 06 Jun 2008
Location: Two-Key Return

Re: SoftShade - Palette-Friendly Dithering v0.9

Postby Rachael » Sun Feb 06, 2022 3:05 am

Well - this is what I had originally planned. The only difference here is - I had originally planned on providing downmixed LUTs for every game - so instead I went with your idea (which was a LOT better) to force the downmix with an empty translation method. I was also possibly planning on doing a 3rd and 4th correction (basically a 2x2 dither) - but - this is more or less the proof of concept plus the work I had done up to the point before I saw you post this.

This uses a simple error diffusion algorithm in a checkerboard pattern. You will have to view this in a lower resolution in order to see the actual dithering.

I did this in a way that, this is also compatible with Raze.

Feel free to do whatever you want from this - if this gives you ideas to improve your's, you're welcome to use it.

(Will put it in a separate thread - it is *not* my intention to thread hijack this)
User avatar
Rachael
^ walking stack of unfinished projects ^
Admin
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle

Re: SoftShade - Palette-Friendly Dithering v0.9

Postby Nash » Sun Feb 06, 2022 10:09 am

I may use this in a future project. :) DenisBelmondo, what's the license on this?
User avatar
Nash
AKA Nash Muhandes! Twitter/Facebook/Youtube: nashmuhandes
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Twitch ID: nashmuhandes
Github ID: nashmuhandes

Re: SoftShade - Palette-Friendly Dithering v0.9

Postby Marisa the Magician » Sun Feb 06, 2022 10:59 am

Ah, that's a very clever thing to do.
User avatar
Marisa the Magician
ZScript Crimester
 
 
 
Joined: 08 Feb 2008
Location: Vigo, Galicia
Discord: Marisa the Magician#1666
Twitch ID: MarisaDOOM
Github ID: OrdinaryMagician
Operating System: Other Linux 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: SoftShade - Palette-Friendly Dithering v0.9

Postby DenisBelmondo » Mon Feb 07, 2022 2:01 pm

Thanks all! I am really glad that you found it interesting or even a possible use for it.

Rachael wrote:snip


No worries Rachael, I appreciate your insight. I booted it up and it looks fantastic especially in low resolutions like you specified.

Nash wrote:I may use this in a future project. :) DenisBelmondo, what's the license on this?


Thanks for taking interest Nash! Since I borrowed from Marisa's work so liberally, I want to say the licensing is transitive. I suppose what I actually borrowed is an implementation of positioned dithering, which I think itself is public domain? In that case, I would say my license is "Public Domain but I get a real kick out of seeing my name in the credits" (:
User avatar
DenisBelmondo
now is time to the i386 heart on fire
 
Joined: 06 Jun 2008
Location: Two-Key Return

Re: SoftShade - Palette-Friendly Dithering v0.9

Postby Gez » Tue Feb 08, 2022 4:10 am

DenisBelmondo wrote:what the shit is this black magic

Seeing that you cannot pass PLAYPAL as a texture uniform, there's no actual way to access the palette as-is in a shader. After kicking around a few solutions, I found one that came to me like a flash of lightning. So, when ZDoom wants to translate a truecolor image, it must first convert it to an indexed image. It doesn't matter if it's a completely meaningless translation like 0:0=0:0, ZDoom will convert it. I exploited this by taking a netural color LUT, fed it into TEXTURES as a patch, and told it to have the aforementioned 0:0=0:0 translation. ZDoom perfectly creates what is essentially a LUT out of whatever array of colors PLAYPAL contains. I then fed that "composited" texture into the shader as a uniform, and from there it's cake.


Just out of curiosity, if the aim is to have a texture with every single palette color in it, why not just use a paletted picture with every color in it? Like this one?
You do not have the required permissions to view the files attached to this post.
Gez
 
 
 
Joined: 06 Jul 2007

Re: SoftShade - Palette-Friendly Dithering v0.9

Postby Rachael » Tue Feb 08, 2022 4:11 am

Because then you would actually have to do colormatching. Doing a downmixed LUT means that the colormatching is already done for you beforehand.

Most modern GPU's can handle the colormatching okay but if you can avoid putting the extra work on your GPU, it's better to.

GZDoom's palette tonemap already uses this exact same technique internally - I don't know if the LUT itself is exactly the same, but it is definitely the same size as DenisBalmodo's, and it works the same way.

Providing a 256-color table like that means that you will have to actually scan the entire table for every pixel and find a closest match - and you will have to do that for every pixel on the screen. Like I said, modern GPU's can handle it - but it's definitely not desirable to do this. Especially since you'll have to pow(color, 2.2) for every match *and* every pixel with it, as well, in order to ensure the matches are in the linear colour space - that will cost a little more processing power on top of that.
User avatar
Rachael
^ walking stack of unfinished projects ^
Admin
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle


Return to Shaders

Who is online

Users browsing this forum: No registered users and 0 guests