I wanted to provide simplest possible example, but here is situation I get into.
I want to write big shader that handles different cases like normal mapping on or off.
I'm defining fragment_programs with different preprocessor_defines without NORMAL_MAPPING or with NORMAL_MAPPING=1. I was setting "defaults" like
Code: Select all
#ifndef NORMAL_MAPPING
#define NORMAL_MAPPING 0
#endif
So, in this case NORMAL_MAPPING was always 0. And default could be 1, so it's not always possible to eliminate such code.
Also I want to make define that depends on it.
Code: Select all
#if NORMAL_MAPPING
#define ATTENUATION_I lightDir[i].w
#else
#define ATTENUATION_I attenuation[i]
#endif
Only second was always defined in such case.
I was expecting that such simple constructions would work as they should.