Grayscale Bump Map + Parallax Shader v3.0 (11/08/23)

Maps, modifications, add-ons, projects, and other releases for Zandronum. Also includes announcers.
Post Reply
User avatar
TDRR
Forum Regular
Posts: 214
Joined: Thu Jun 28, 2018 9:13 pm
Location: Venezuela

Grayscale Bump Map + Parallax Shader v3.0 (11/08/23)

#1

Post by TDRR » Sat Sep 25, 2021 3:58 am

NOTE: This probably can't run on most GL2 cards, so expect GL3.0 as a minimum.

NOTE 2: This requires "Use shaders for lights" enabled in the dynamic lights options. It appears to be disabled by default, so be careful. And as a rule of thumb, if you can't enable it, then your GPU is probably too old (or you're on Linux and are the victim of a to-be-fixed bug with Zandronum).

Here's a grayscale bump mapping shader. So, basically normal mapping, but with a "heightmap", so it can be put in the texture's alpha channel.
Unlike the normal mapping shader, this one doesn't require a func_brightmap.fp replacement, so it should be a lot safer for inclusion in any project.
It also includes parallax mapping so textures should pop out like never before.

NOTE: This ONLY works with Zandronum (wouldn't be hard to update it to work with GZDoom though)!

DOWNLOAD!
phpBB [media]

Spoiler: Credits (Open)
https://www.geeks3d.com/20130122/normal ... e-vectors/
The implementation I mostly borrowed from.

dpJudas
Made the original parallax mapping shader. I think. Couldn't contact him to confirm as he's not in the ZDoom server at the moment.

https://community.khronos.org/t/manual- ... er/58504/1
The texture2d_bilinear sampler implementation I used for the parallax map.
Spoiler: Usage (Open)
You should first copy the "shaders" from the test pk3 folder into your project's pk3.

First, you need a texture and a grayscale bump map (or a height map, though height maps for displacement/parallax usually are darker and have less variation in brightness, so they may not work as well).
Avoid using pitch-black in the bump map, as this will be interpreted as transparency! Anything slightly higher should be okay, though.

If you have Image Magick installed, you can use this bat file to put the bump map into the main texture's alpha channel, so it's ready for use:

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
Once you've done that you can put the output image under the textures folder on your pk3 of choice. The name must be 8 characters long.

Then the GLDEFS code for it is this:

Code: Select all

HardwareShader texture TEXNAME {Shader "shaders/gs_bump.fp"}
Where TEXNAME is the texture name without the extension.
There seems to be some sort of bug in Zandronum 3.x, where sometimes wall textures need "flat" instead of "texture" (the example pk3 does this out of necessity, too).

Once that's done you can use your texture like normal! Do note that obviously dynamic lights need to be around to provide some visible effect.
Spoiler: Changelog (Open)
v3.0 (11/08/2023)
-Added parallax mapping! Controllable with PARALLAX_MAP, PARALLAX_SCALE and BILINEAR_PARALLAX_SAMPLE.

-Added NO_SPECULAR to disable the specular highlight. This makes the shader parallax mapping only, and should help performance too.

-Removed NO_XLU. It doesn't really do anything anyway.

v2.0 (02/06/2023)
-Removed FAST_MODE. It was actually slower on basically any GPU I've tried it on.

-Added SPECULAR_FACTOR to customize the specular intensity. Higher means smaller, lower means bigger.

-Added DEBUG_SHOW_NORMAL to display the generated surface normals. Only really useful for debugging.

-Added NO_XLU to allow 0 alpha to be interpreted as "no specular" (so basically a 1-bit specular map).

v1.1 (12/02/2022)
-Added an option to adjust target texture size on the shader. And changed the default to 64px, makes nearest neighbor (pixelated) look MUCH cleaner and removes the banding compared to the first version.

-Added an option to allow specular highlights to extend past their light's regular size. It defaults to on, but the increase is very slight (it extends 15% further), this is mostly to avoid pop-in and highlights cut off after going outside their subsector.

-Fixed a bug with transparent textures. Now 0% alpha isn't shown as black, but rather invisible as it is in Doom (thanks to Reddevilhunter for pointing this out!).
Last edited by TDRR on Sat Aug 12, 2023 1:19 am, edited 6 times 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
inkoalawetrust
Registered just to make one post
Posts: 1
Joined: Thu Aug 12, 2021 4:55 pm

Re: Grayscale Bump Map Shader v1.0

#2

Post by inkoalawetrust » Mon Sep 27, 2021 1:47 am

Just tried this out, the shader doesn't work on my OpenGL 2 SFF Optiplex 760, which is no surprise.

thumbnail

But I also asked two other people to test it out on their newer PCs*, and weirdly, it doesn't seem to work on OpenGL 3+ either.

thumbnail

thumbnail
*I myself do have a newer PC, with an RTX 2060 and i5-11400f, but the i5 died for no reason and I'm still trying to wrangle Intel into sending me a replacement or refund

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

Re: Grayscale Bump Map Shader v1.0

#3

Post by TDRR » Tue Sep 28, 2021 2:40 am

Thanks for reporting this issue.

After some brief testing on the ZDoom Discord, we concluded it was the "Use Shaders for Lights" option, which is disabled by default. Added a note about this in the OP.
"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
TDRR
Forum Regular
Posts: 214
Joined: Thu Jun 28, 2018 9:13 pm
Location: Venezuela

Re: Grayscale Bump Map Shader v1.1 (12/02/22)

#4

Post by TDRR » Sun Feb 13, 2022 4:22 am

Updated! Fixed a bug with transparency being pitch black rather than... actually transparent. Also fixed it looking banded and ugly with nearest neighbor filtering, plus added an option to make the specular highlight extend past the light's range, in the .fp file.
"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
TDRR
Forum Regular
Posts: 214
Joined: Thu Jun 28, 2018 9:13 pm
Location: Venezuela

Re: Grayscale Bump Map Shader v1.1 (12/02/22)

#5

Post by TDRR » Fri Jun 02, 2023 8:50 pm

Updated. Changelog:
-Removed FAST_MODE. It was actually slower on basically any GPU I've tried it on.

-Added SPECULAR_FACTOR to customize the specular intensity. Higher means smaller, lower means bigger.

-Added DEBUG_SHOW_NORMAL to display the generated surface normals. Only really useful for debugging.

-Added NO_XLU to allow 0 alpha to be interpreted as "no specular" (so basically a 1-bit specular map).
"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)

Derddy
New User
Posts: 4
Joined: Sat Oct 30, 2021 8:47 pm

Re: Grayscale Bump Map Shader v1.1 (12/02/22)

#6

Post by Derddy » Fri Aug 11, 2023 6:12 pm

I'm trying to do all the vanilla textures for Hexen. If I use the Image Magick batch then that's all I need to do to the textures? It wasn't clear to me in the instructions. Thanks.

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

Re: Grayscale Bump Map Shader v1.1 (12/02/22)

#7

Post by TDRR » Fri Aug 11, 2023 7:53 pm

Derddy wrote:
Fri Aug 11, 2023 6:12 pm
I'm trying to do all the vanilla textures for Hexen. If I use the Image Magick batch then that's all I need to do to the textures? It wasn't clear to me in the instructions. Thanks.
Well, you need to draw a heightmap in grayscale, which will be the secondary texture fed to the batch file. If the output file looks transparent on the darker pixels of the height map then it's ready to go.
"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
TDRR
Forum Regular
Posts: 214
Joined: Thu Jun 28, 2018 9:13 pm
Location: Venezuela

Re: Grayscale Bump Map + Parallax Shader v3.0 (11/08/23)

#8

Post by TDRR » Sat Aug 12, 2023 1:12 am

Updated. Changelog:
-Added parallax mapping! Controllable with PARALLAX_MAP, PARALLAX_SCALE and BILINEAR_PARALLAX_SAMPLE.

-Added NO_SPECULAR to disable the specular highlight. This makes the shader parallax mapping only, and should help performance too.

-Removed NO_XLU. It doesn't really do anything anyway.

I'm really excited for this update, as parallax mapping is something I've wanted for a pretty long time in Zandronum, and I hope you all enjoy it too.
"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