[SHADER] Sonic The Fighters-style model lighting (v2)

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: 214
Joined: Thu Jun 28, 2018 9:13 pm
Location: Venezuela

[SHADER] Sonic The Fighters-style model lighting (v2)

#1

Post by TDRR » Sat Apr 25, 2020 4:32 am

Can't download? Try this link instead: https://forum.zdoom.org/viewtopic.php?f ... 8#p1148678

Here's a Sonic The Fighters/Superhot style model lighting shader for Zandronum 3.0 (Which might work with map geometry, haven't tested). Thanks to Kevin over at learnopengles.com for his great help, without it I wouldn't have done this at all.
STF_Lighting_Shader_Zandro.zip
For usage, set up a brightmapped model as you normally would in GLDEFS and MODELDEFS, but set "map" to "shader/null.png" (included in the pk3 file)
NOTE: If your brightmaps have any alpha translucency, that section of the brightmap will be interpreted as "needs flat shading" (This also completely discards RGB info the brightmap set in that pixel!). Use only black and white brightmaps if you need normal Zandronum/GZDoom behavior.

I recommend keeping the shader itself as a separate addon, for compatibility with future Zandronum versions. Since this overrides func_brightmap.fp, and GZDoom itself has already completely switched to using a different method for brightmaps (They are internally treated as materials, and old shaders replacing it won't work correctly) it's to be expected Zandronum will too, so please avoid making this an absolute requirement so people will be able to run your mod with newer Zandronum versions.
Spoiler: Features (Open)
-Gives your models in Zandronum a lot more contrast and a e s t h e t i c !

-Allows you to choose exactly which models/surfaces get affected by the lighting, and which ones don't!

-Does not sacrifice brightmap functionality!
Spoiler: Customization (Open)
You can also customize light direction by modifying the following line in shaders/glsl/func_brightmap.fp:

Code: Select all

vec3 lightDir = vec3(x, y, z);
Where X is left/right (left is negative, right is positive)
Y is up/down (negative up, positive down)
and Z is depth (positive closer, negative further).
Keep in mind that this doesn't work like a point light, but like a directional light.
Spoiler: Known bugs (Open)
-Zandronum will spit a shader compilation error with "pixelpos" and "xyz", these are false errors and can't be avoided, as far as I'm aware. The shader will still work fine.

-GPUs with Shader Model older than 4.0 may experience issues with light orientation (The lighting will appear to be "painted" into the model, and will rotate with it).
Screenshot of how it looks (might look nicer with higher poly models, or some with better triangle distribution):
stf_light_style.png
You do not have the required permissions to view the files attached to this post.
Last edited by TDRR on Sat Apr 25, 2020 6:48 pm, edited 1 time in total.
"I will find joy in Yahweh. I will delight in my Elohim. He has dressed me in the clothes of salvation. He has wrapped me in the robe of righteousness like a bridegroom with a priest’s turban, like a bride with her jewels."
-Isaiah 61:10 (Names of God Bible)

User avatar
Ivan
Addicted to Zandronum
Posts: 2219
Joined: Mon Jun 04, 2012 5:38 pm
Location: Omnipresent

Re: [SHADER] Sonic The Fighters-style model lighting (v2)

#2

Post by Ivan » Sat Apr 25, 2020 6:22 am

Does Zandronum even support shaders?
=== RAGNAROK DM ON ... uh... dead forever? ===
=== ALWAYS BET ON ... uh... dead forever? ===
=== Who wanta sum wang? ===
=== Death and Decay - A new Monster/Weapon replacer ===

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

Re: [SHADER] Sonic The Fighters-style model lighting (v2)

#3

Post by TDRR » Sat Apr 25, 2020 7:10 am

Ivan wrote:
Sat Apr 25, 2020 6:22 am
Does Zandronum even support shaders?
Sort of. You can override the built-in shaders, but most of the time this still isn't enough to do anything decent since GZD 1.8.6's renderer (and by extension Zandro's) does not expose anything but the bare essentials for GLSL (and even then, gl_Normal is not among those).

This one works by replacing the brightmap shader, and checking if the processed brightmap texel has any alpha translucency in it (if it doesn't the brightmap is processd as Zandro would normally do), and if it does then it recalculates the currently processed polygon normal, and does other light-related stuff. This way, brightmap functionality is left intact, and a new feature is added without requiring any source code modifications.

Well, almost completely intact, because if a brightmap uses alpha translucency instead of a darker color to indicate less-bright areas (which is not the intended way AFAIK), then the shader assumes it just means "just ignore what the brightmap set for this texel and apply flat shading", so for safety reasons only black and white brightmaps should be used except for a few special cases.
"I will find joy in Yahweh. I will delight in my Elohim. He has dressed me in the clothes of salvation. He has wrapped me in the robe of righteousness like a bridegroom with a priest’s turban, like a bride with her jewels."
-Isaiah 61:10 (Names of God Bible)

Post Reply