ZanShaders v1.0

Looking for Resources for your mod/project? Want to share some of your creations so others can use them? Post them here!
Post Reply
User avatar
TDRR
Forum Regular
Posts: 163
Joined: Thu Jun 28, 2018 9:13 pm
Location: Venezuela

ZanShaders v1.0

#1

Post by TDRR » Thu Dec 17, 2020 4:36 am

As it turns out, Zandronum has supported GZDoom's hardware shader definitions in GLDEFS since... version 2.0?! that's a very long time ago! Even then, this feature has gone largely unused since it's introduction, until now, so here's a pack of shaders built for Zandronum.
It includes:
-Mario Galaxy-style water
-More water-like warping effect (waterwarp.fp)
-Specular mapping (specular4.fp 4-light version, specular1.fp is 1-light version)
-Fake environment mapping (envmap.fp)
-Flat lighting, a-la Sonic the Fighters/SuperHot/some generic indie game or whatever (flat_light.fp)
-Toon lighting (toon_light.fp)


Previews: (click the images to enlarge)
Image
Image

The texture SMGWATER is used for opaque blue water while SMGWTXLU is used for translucent water, which doesn't have any color by itself (it's blended in with whatever is under it).
Spoiler: Installing the shaders into your mod (Open)
Just throw the ZanShaders.pk3 contents into your Zandronum mod's pk3. If some shaders stop working in future versions, all that needs to be done is remove the #ifdef, #else and #endif statements from the .fp files, as well as the second Process() function (all of which can be done with an external patch as well) on the affected shaders.

If I still haven't died of age when the next major renderer update comes by, I'll update this post with a patch to make the shaders compatible again.
Spoiler: Using the shaders (Open)
Shaders are applied onto a texture by using:

Code: Select all

HardwareShader texture TextureName {Shader "shader/shadername"}
Some shaders (the SMG water and waterwarp shaders specifically) take in a Speed parameter. This changes the speed at which the animation moves, and is a floating point number, which defaults to 1.0.

Some other shaders, require another texture to work. Since the HardwareShader syntax does not support a secondary texture to be used by the shader, this texture needs to be written into the main texture's alpha channel. This can be rather difficult since there's no programs to do this, but if you have ImageMagick installed, this .bat file can be used to do this for you:

Code: Select all

@echo off
set /p image1=Type the name of the texture (include extension):
set /p image2=Type the name of the secondary texture:
set /p image3=Type the name of the output image:
magick convert %image1% %image2% -alpha off -compose CopyOpacity -composite %image3%
pause
In the case of the water warp shader, this involves scaling the SMGWATER image to the target image's resolution, and running this bat file on it.
For the specular mapping shader, the specular map is like any regular specular map seen elsewhere, black means the specular highlight won't be visible, gray means it'll be there but with half intensity, and white means full intensity.

For shaders to be applicable to models, the model textures need to be in the textures namespace (by this, I mean in the textures folder of a PK3, ideally), and these can't be longer than 8 characters (not sure if there's a workaround for that). After that, just apply them in MODELDEFs and set their shader with GLDEFs as normal.
Spoiler: Water effect usage guide (Open)
To have opaque blue water, merely using the SMGWATER texture is enough.

However, more complex effects can be done with translucent water. Here's two I've currently made:

Reflective water with Sector_SetPlaneReflection (NOT SWIMMABLE):
1. Make your sector with the water floor that's going to be reflective.

2. Set up a normal 3D floor on this sector with exactly 254 alpha (or one less than the max, in case it's not the same in Doom Builder X compared to the others), SMGWTXLU set as it's top flat texture, and - (a.k.a none) as the bottom texture. Make sure the 3D sector has no height (identical floor and ceiling height values), and is one unit above the floor of the target sector.

3. Then the sector that has the 3D floor applied to it should have Sector_SetPlaneReflection assigned via ACS. If you want to add some tint, use a solid-color texture of the desired color, and tweak the Sector_SetPlaneReflection reflectivity amount until you're satisfied with the resulting color.
If you don't want any tint on the floor, just use 255 as the reflectivity amount.


3D floor water (swimmable):
1. Make your 3D floor water as usual, except you must set the top texture to SMGWTXLU, and the 3D floor's alpha to 254. Set the control sector's light color to whatever color you want the water to be, and that's pretty much it.

But that doesn't have to be all, you can add some warp with ANIMDEFS to the walls and floor of a 3D floor water pool to make a slightly more convincing water effect, or use some cubemapping shader + warp to make a lightweight realistic reflective warping water surface. The limit is your imagination! (and GZDoom/Zandro's own limitations, sorry!)
Spoiler: Known issues (Open)
-Fog effect in 3D floors is not supported, and displays a single incorrect color for the water surface. This can be worked around by making the water surface a separate 3D floor that just displays SMGWTXLU, is zero-height and is one unit above the actual water.

-Zandronum doesn't draw pixels I set to have less than 0.5 alpha, so the effect for translucent water had to be made less subtle in that port. Other than that it works perfectly fine.

-Specular mapping currently only works correctly on non-sloped flats. You can assign it to other surfaces if you want, but the highlight won't be consistent with the floor/ceiling.
Spoiler: Credits (Open)
Cherno, dpJudas and Graf Zahl: Creation and cleanup, respectively, of the SimSun shader used as the basis for the flat/toon lighting shaders.

HAL9000 and Striker: Original versions of the fake environment mapping shader for GZDoom.

Michael "Jasper" Ashworth: His amazing breakdown on how the Super Mario Galaxy water works. The water shader is mostly based off his explanation.
Download:
ZanShaders_v1.0.zip
Comes with a test map, goes over MAP01 and uses Doom 2 resources.
Last edited by TDRR on Thu Jan 14, 2021 7:01 pm, edited 5 times in total.
No Gucci, no Prada, no Supreme, but my sadness got an ending, my smile shining like bling-bling, i'm so blessed feeling like a king!

play with my bots or bad stuff will happen to u >:c

User avatar
Ænima
Addicted to Zandronum
Posts: 3494
Joined: Tue Jun 05, 2012 6:12 pm

Re: Mario Galaxy-esque water (Zandro and GZDoom compat!)

#2

Post by Ænima » Tue Dec 29, 2020 8:13 pm

Ha, YouTube recommended me that same video like a year ago. As soon as I saw this thread’s title I was like “someone finally did it in Doom”.

Very clever technique. Looks good in GZDoom, too. Well done.
­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­
Doom64: Unabsolved: New weapons, monsters, and gameplay features for coop !


ZandroSkins
: a pack made by our community

User avatar
TDRR
Forum Regular
Posts: 163
Joined: Thu Jun 28, 2018 9:13 pm
Location: Venezuela

Re: ZanShaders v1.0

#3

Post by TDRR » Thu Jan 14, 2021 3:50 am

Updated. Now, instead of just water effect, this is now a shader pack taking advantage of Zandronum's HardwareShader support, which means that no functionality is removed or replaced, only added.

As the first post states, this update currently includes:
-Mario Galaxy-style water
-More water-like warping effect
-Specular mapping
-Fake environment mapping
-Flat lighting, a-la Sonic the Fighters/SuperHot/some generic indie game or whatever
-Toon lighting

With more to possibly come in the future.
No Gucci, no Prada, no Supreme, but my sadness got an ending, my smile shining like bling-bling, i'm so blessed feeling like a king!

play with my bots or bad stuff will happen to u >:c

Post Reply