Shader related: timer and tex uniforms should not be explicitly declared.

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
Enjay
 
 
Posts: 27115
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Shader related: timer and tex uniforms should not be explicitly declared.

Post by Enjay »

I have noticed, with recent Git builds, that the following message has started appearing at the console for some mods:

Code: Select all

timer and tex uniforms should not be explicitly declared.
Unfortunately, the message doesn't identify which files or lines within are causing the problem. I *think*, however, I have tracked it down to certain shaders. The problem is, beyond that, I'm lost.

For example, if I allocate the following shader (from BoA) to a texture, the error message appears twice in the console:

Code: Select all

uniform float timer;

// Defines are in boashaders.txt, and are used to configure the shader.
#define NOISE_SCALE 1.
#define NOISE_DISTANCE 768.
#define OVERLAY_SCALE_X 1.5
#define OVERLAY_SCALE_Y 1.5
#define OVERLAY_OPACITY .5

vec4 Process(vec4 color) // color is white for some reason.. A GZDoom bug?
{
	// Get initial colour for the effect
	vec4 texColor = getTexel(vTexCoord.xy);
	vec4 finalColor = texColor;
	// Calculate "fbm" (Fractional Brownian Motion) noise.
	vec2 fbmUv = vTexCoord.xy; fbmUv.y -= timer;
	vec4 fbmColor = texture(fbmnoise, fbmUv);
	fbmColor *= texColor; // Colorize fbm
	fbmColor *= min(1., NOISE_DISTANCE / pixelpos.w);
	// Calculate UV coordinates for overlay texture
	vec2 overlayUv = vTexCoord.xy;
	overlayUv *= vec2(OVERLAY_SCALE_X, OVERLAY_SCALE_Y);
	overlayUv.y -= timer * .5;
	// Compose the effects together for the final colour
	finalColor = mix(finalColor, getTexel(overlayUv), OVERLAY_OPACITY);
	finalColor += fbmColor;
	return finalColor;
}
So, presumably, whatever triggers this message appears twice in that shader definition, but I simply don't know enough about it to figure out which lines or how to fix them.

Can anyone give me any insight? Perhaps if I can be clued in to this one, then I *might* be able to figure out others myself. Maybe.


Edit:
Hmmm... I wonder if I'm barking up the wrong tree? ChatGPT (I know, I know) told me that declarations like "uniform float timer;" could be the problem. So, I have commented them out in several shaders and I'm still getting the warning messages. :?


Edit2: Meh! I got it sorted. Apparently commenting works differently in shaders. Simply putting //Enjay in front of the relevant line wasn't enough:

Code: Select all

//Enjay uniform float timer
Deleting the line entirely made the error messages go away, and the shaders still work.
(Is that expected behaviour with comments in Shaders? Maybe it's something else - like changing the number of lines forced a recompile but simply commenting it out didn't?)
Post Reply

Return to “Assets (and other stuff)”