Software Dithering

Remember, just because you request it, that doesn't mean you'll get it.

Moderator: GZDoom Developers

Okgo5555
Posts: 80
Joined: Thu Mar 23, 2017 11:18 am

Software Dithering

Post by Okgo5555 »

Would it be possible to write in a software rendered checkerboard dither as a replacement for translucency and alpha blending? This would be more performant and provide a more "vanilla" approach to something like rendering a translucent fireball. This absolutely can be achieved via Zscript and DECORATE.

However, this is not a a native feature.

You could simply alternate every other pixel and every other frame for a given sprite to make a 1994, software "translucent" fireball. Curently, to achive this, the user would need to manually create dithered frames for any assets for this effect.

It seems like it would be a reasonable option... even if its just added to the gzdoom.pk3 🤷‍♂️
User avatar
Cherno
Posts: 1318
Joined: Tue Dec 06, 2016 11:25 am

Re: Software Dithering

Post by Cherno »

Not for the software renderer as such, but you can use a shader like the one I wrote a short while ago:

Code: Select all

vec4 Process(vec4 color)
{
	//Thanks to arookas for the help
	
	mat4 thresholdMatrix =
    {  vec4(1.0 / 17.0,  9.0 / 17.0,  3.0 / 17.0, 11.0 / 17.0),
      vec4(13.0 / 17.0,  5.0 / 17.0, 15.0 / 17.0,  7.0 / 17.0),
      vec4(4.0 / 17.0, 12.0 / 17.0,  2.0 / 17.0, 10.0 / 17.0),
      vec4(16.0 / 17.0,  8.0 / 17.0, 14.0 / 17.0,  6.0 / 17.0)
    };
	
	vec2 texCoord = gl_TexCoord[0].st;
	vec4 texel = getTexel(texCoord);
	
	ivec2 fragCoord = ivec2(gl_FragCoord.xy);
	if (texel.a < thresholdMatrix[int(fragCoord.x) % 4][int(fragCoord.y) % 4]) 
	{
		discard;
	}
	
	return texel * color;
}
Okgo5555
Posts: 80
Joined: Thu Mar 23, 2017 11:18 am

Re: Software Dithering

Post by Okgo5555 »

Understood, but i was proposing an approach that could even be a toggled feature simply with additive assets and zscript actors into the .pk3 ala decals. No big deal. I can cook it up myself. Just something that might be "nice to have" for software render nerds.

Return to “Feature Suggestions [GZDoom]”