Hi,

I'm implementing a shader framework where I have 1 ubershader and a bulk of different permutations/ 'defined combinations'. So when I render I select the right one, based on the scene and material.

Now I'm wondering if there's a better/ more efficient way to compile the whole bunch of combinations.

Below is the matrix of all possible combinations I need to compile.

Any input is appreciated, about ways to do this other then say 100+ lines of code with just different 'true's' and 'false's'.

I also thought about maybe defining some sort of 'key', to identify all the true's and false's with 1 key, which also might help in selecting the needed version of the effect.

/** Possible defines and combinations Scene specific: AMBIENT FOG Y/N DIRLIGHTS Y/N POINTLIGHTS Y/N NUM DIR LIGHTS 0/1/2/3 NUM POINT LIGHTS 4/8 Material specific: NORMALMAP Y/N SPECULAR Y/N // might be more later on, specular map, gloss map etc. **/ /* HLSL_DEFINES fullDefines; fullDefines.AmbientHemi = true; fullDefines.Fog = true; fullDefines.NormalMapping = true; fullDefines.Specular = true; fullDefines.DirLights = true; fullDefines.PointLights = true; fullDefines.NumDirLights = 2; fullDefines.NumPointLights = 8;*/ if(!mEffects[0].Compile(mFilename, mD3ddev, mEffectPool, HLSL_DEFINES(true, true, true, true, true, true, 2, 8))) return false;

**Edited by cozzie, 20 June 2014 - 08:46 AM.**