Properties for generating the macros. See toData
and mapGroups.
Optionalon: stringAny further macro hooks specifier; if given, both
the hook key and this specifier are checked (e.g: key and key_on).
The GLSL preprocessor macros defining the mappings for
values, textures, channels, bound outputs of the active pass, etc. See
macroValues, macroOutput, and macroSamples.
Defines all
GLSLpreprocessor macro values,texturesamples, and outputs for the active pass.The macros define the mapping between the active values, their
textures and channels, bound outputs, and other macros useful for a draw pass. Caches the result ifmacrosgeneration is enabled, to help reuse shaders.See
Example: ```javascript const values = [2, 4, 1]; const derives = [2, , [[1, 0], true]]; // Automatically packed values - values across fewer `texture`s/passes. // Only a single `texture` output per pass - values across more passes. const state = { passNow: 0, steps: 2, size: { entries: 2**5 }, maps: mapStep({ values, derives, channelsMax: 4, buffersMax: 1 }) }; macroPass(state); // => '#define gpgpu_texture_1 0\n'+ '#define gpgpu_channels_1 rgba\n'+ '\n'+ '#define gpgpu_texture_0 1\n'+ '#define gpgpu_channels_0 rg\n'+ '\n'+ '#define gpgpu_texture_2 1\n'+ '#define gpgpu_channels_2 b\n'+ '\n'+ '#define gpgpu_entries 32\n'+ '#define gpgpu_textures 2\n'+ '#define gpgpu_passes 2\n'+ '#define gpgpu_stepsPast 1\n'+ '#define gpgpu_steps 2\n'+ '\n'+ '#define gpgpu_passNow 0\n'+ '\n'+ '#define gpgpu_bound_1 0\n'+ '#define gpgpu_attach_1 0\n'+ '#define gpgpu_output_1 gl_FragData[gpgpu_attach_1].rgba\n'+ '\n'; // Next pass and extra step. ++state.steps; ++state.passNow; state.pre = ''; macroPass(state); // => '#define texture_1 0\n'+ '#define channels_1 rgba\n'+ '\n'+ '#define texture_0 1\n'+ '#define channels_0 rg\n'+ '\n'+ '#define texture_2 1\n'+ '#define channels_2 b\n'+ '\n'+ '#define entries 32\n'+ '#define textures 2\n'+ '#define passes 2\n'+ '#define stepsPast 2\n'+ '#define steps 3\n'+ '\n'+ '#define passNow 1\n'+ '\n'+ '#define bound_0 1\n'+ '#define attach_0 0\n'+ '#define output_0 gl_FragData[attach_0].rg\n'+ '\n'+ '#define bound_2 1\n'+ '#define attach_2 0\n'+ '#define output_2 gl_FragData[attach_2].b\n'+ '\n'+ '#define useSamples'+lf+ 'const int samples_l = 3;'+lf+ 'const ivec2 samples_0 = ivec2(0, 1);'+lf+ 'const ivec2 samples_1 = ivec2(1, 1);'+lf+ 'const ivec2 samples_2 = ivec2(0, 0);\n'+ '// Index macro `samples_i` (e.g: `samples_i(0)`) may be slow, '+ 'use name (e.g: `samples_0`) if possible.\n'+ '#define samples_i(i)'+lf+ '((i == 2)? samples_2 : ((i == 1)? samples_1 : samples_0))\n'+ '\n'+ '#define useReads_0'+lf+ 'const int reads_0_l = 1;'+lf+ 'const int reads_0_0 = int(0);\n'+ '// Index macro `reads_0_i` (e.g: `reads_0_i(0)`) may be slow, '+ 'use name (e.g: `reads_0_0`) if possible.\n'+ '#define reads_0_i(i) reads_0_0\n'+ '\n'+ '#define useReads_2'+lf+ 'const int reads_2_l = 4;'+lf+ 'const int reads_2_0 = int(1);'+lf+ 'const int reads_2_1 = int(0);'+lf+ 'const int reads_2_2 = int(2);'+lf+ 'const int reads_2_3 = int(0);\n'+ '// Index macro `reads_2_i` (e.g: `reads_2_i(0)`) may be slow, '+ 'use name (e.g: `reads_2_0`) if possible.\n'+ '#define reads_2_i(i) ((i == 3)? reads_2_3 : ((i == 2)? reads_2_2 '+ ': ((i == 1)? reads_2_1 : reads_2_0)))\n'+ '\n'+ '// States in a `sampler2D[]`; looks up 1D index and 2D `uv`.\n'+ '@todo'; ```