[PSA] Always initialize your shader variables!

Ask about editing graphics, sounds, models, music, etc here!
Shaders (GLSL) and SNDINFO questions also go here!

Moderators: GZDoom Developers, Raze Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Post Reply
User avatar
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

[PSA] Always initialize your shader variables!

Post by Nash »

With the Vulkan renderer on the horizon, you might find a little surprise with your existing shaders (be it post processing, or materials). Before panicking that your shaders "mess up in Vulkan", check one one of the most basic things:

Uninitialized variables!

For Vulkan, uninitialized variables might produce strange results in your shader. It is recommended that you always initialize your variables.

Code: Select all

// might "work" in OpenGL but produce strange results in Vulkan
vec4 newColor;

// this is safer and will ensure consistency in both OpenGL and Vulkan
vec4 newColor = vec4(0.0, 0.0, 0.0, 0.0);
it is generally recommended to initialize your variables in shaders because of how driver-dependent their behaviour can be, even with OpenGL.

Happy shading!
Dark Jaguar
Posts: 28
Joined: Fri Jul 13, 2018 9:35 am

Re: [PSA] Always initialize your shader variables!

Post by Dark Jaguar »

I wonder if GZDoom is going to be renamed VZDoom? Or maybe just drop that and simply call it all "ZDoom" again?

In short, thank you for the alert! Vulkan support is sure to be interesting!
User avatar
Tormentor667
Posts: 13533
Joined: Wed Jul 16, 2003 3:52 am
Contact:

Re: [PSA] Always initialize your shader variables!

Post by Tormentor667 »

The G doesn’t stand for GL but Graf (Zahl) ;)
Dark Jaguar
Posts: 28
Joined: Fri Jul 13, 2018 9:35 am

Re: [PSA] Always initialize your shader variables!

Post by Dark Jaguar »

Tormentor667 wrote:The G doesn’t stand for GL but Graf (Zahl) ;)
I have seen the truth! It is.... glorious!
Post Reply

Return to “Assets (and other stuff)”