Would it make sense to "clean up" material shaders?

In my current project i use Lighting.j3md extensively, but only ever use DiffuseMap, NormalMap and GlowMap of it. Would it make sense to copy the definition files of that material into my project and throw out all the stuff for the other maps in the shader definitions ?
The code is not executed because the other maps are not defined, but still it is send to the GPU and compiled there from what i understand. So thought maybe it would save a bit of memory and maybe even have a slight performance boost, or would there be no real difference ?

You won’t see a real difference. Anything in the #ifdef won’t be compiled if it is not defined (or so I believe).
You can adapt you stuff to use shader nodes instead, they were designed for the modularity you are looking for.

The #ifdef stuff is not “sent to the GPU”… it’s stripped by the driver during compile. At least that’s my understanding. It’s definitely not hanging around.

Besides, it’s only done once anyway unless you keep changing your defines.

I thought that because you can add attributes that werent set when you first send it to the GPU that the whole thing is sent. Or is the shader code sent again if you set any of the maps in this case that weren’t previously ?

@ryukajiya said: I thought that because you can add attributes that werent set when you first send it to the GPU that the whole thing is sent. Or is the shader code sent again if you set any of the maps in this case that weren't previously ?

If you change a define then the shader is recompiled and resent.

Ok, i guess it makes no sense then if unused code in the #ifdef blocks are removed anyways.
Just thought i could clear some unneeded baggage there because i just use a small part of the materials definitions.
Thanks for clearing it up.

1 Like