Help with shader

Tue Sep 21, 2021 6:07 pm

I'm trying to learn something about shaders and I thought that looking at some existing ones and then editing them to my own needs would help clue me in. Anyway, I've come across a minor issue.

Looking at one of the shaders invglow.fp from Total Chaos, there is this line:

Code:
    Material material;
   vec4 addEnv = texture(invglow, ((pixelpos.xyz).xy + (timer*30)) * 0.01);


if I change the word invglow to something else (glowscan in my case) I get:

Code:
**** DIED WITH FATAL ERROR:
Shader 'glowscan' could not be compiled:
ERROR: 0:11: 'glowscan' : undeclared identifier
ERROR: 0:11: '' : compilation terminated
ERROR: 2 compilation errors.  No code generated.


If I run it with invglow, it works just fine.

Now, normally I would expect "undeclared identifier" to mean that I need to declare the name "glowscan" somewhere. The problem is, I have searched for invglow inside the shader and the only mention of it is in the above line. So I thought maybe it's declared in some of the GZDoom source files. I have searched through them all (using an automated search) and, again, I can't find the word "invglow".

Googling hasn't helped either.

So, is "invglow" some sort of built-in word that all shaders should know about somehow? If not, where is it declared to allow GZDoom to know about it? And how do I declare any name that I might want to use myself?

Or am I barking up the wrong tree entirely?

Re: Help with shader

Tue Sep 21, 2021 6:11 pm

Nevermind! I figured it out. I had forgotten to change the instances of the word invglow in my gldefs to glowscan too. Doh!

But that's a good lesson because I was getting similar errors with other shaders and now I think I know why for them too.