It would be a big improvement, if there where lots of shader defines and shaders being compiled and used for the needed variations
I receive great workflow results with dynamically compiled shaders, based on the .fx code and a preamble, generated during runtime, used together with the following function:
MATERIAL* avCompileMtl (MATERIAL* m, char* file, char* preamble, char* technique)
{
if (m == NULL)
return NULL;
if (technique != NULL)
m->technique = technique;
if (file != NULL)
{
int s = 0;
void* c = file_load(file, NULL, &s);
if (s != 0)
{
STRING* strShader = NULL;
if (preamble != NULL)
{
strShader = str_create(preamble);
str_cat(strShader, "\n");
str_cat(strShader, c);
effect_load(m, strShader);
}
else
effect_load(m, c);
file_load(NULL, c, NULL);
if (strShader != NULL)
ptr_remove(strShader);
}
}
return m;
}
In your game infrastructure, you just need to create a function that evaluates certain information (like variables and flags) and generate a series of defines (separated with "\n") to generate a preamble, that you can use to structure your HLSL shader-code with #ifdef and #ifndef. You can even use this to dynamically re-arrange samplers, by adding e.g. "#define SKIN_SPEC entSkin3" to your preamble and use SKIN_SPEC in the sampler definition: sampler smpSpecular = sampler_state { Texture = < SKIN_SPEC >; };, whereas the string above is e.g. generated by an int and sprintf.
It would also be great if there was a possibility not to clear the depth buffer before rendering some view
Do you mean the NOSKY flag? I used it to render particles into a SSAO-shaded scene and it works really good.