ShaderMaterial defines don't work as documented

Per documentation the way to pass defines to a shaderMaterial is as follows:
But it actually just pastes MyDefine into the shader code
#define WEBGL2
Which means that the shader won’t compile. So you have to pass defines like this:
defines["#define MyDefine"]

Here’s an example with both methods:

Maybe the doc is not clear enough, but MyDefine is a placeholder. You can either pass #define TEST or #define TEST 3 or anything that is syntactically correct for a #define instruction.

My bad, that’s not how I understood it. Though it seems weird that it does just paste a string into the shader, since that means that it doesn’t actually have to be a #define instruction. See

Indeed, you can consider this as a feature of the define array :wink: