Per documentation the way to pass defines to a shaderMaterial is as follows:
defines["MyDefine"]
But it actually just pastes MyDefine
into the shader code
#define WEBGL2
MyDefine
#define NUM_BONE_INFLUENCERS 0
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:
https://www.babylonjs-playground.com/#1OH09K#271
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 https://www.babylonjs-playground.com/#1OH09K#272
Indeed, you can consider this as a feature of the define array 