I have a shader and I want the compiler to generate the following variants:
SHADOWS_SCREEN SHADOWS_NATIVE LIGHTMAP_OFF
SHADOWS_SCREEN SHADOWS_NATIVE LIGHTMAP_ON
SHADOWS_SCREEN LIGHTMAP_OFF
SHADOWS_SCREEN LIGHTMAP_ON
SHADOWS_OFF LIGHTMAP_OFF
SHADOWS_OFF LIGHTMAP_ON
But I can’t seem to find a way how to get just these. My workaround is to define the multi compile like this:
#pragma multi_compile SHADOWS_SCREEN SHADOWS_OFF
#pragma multi_compile SHADOWS_NATIVE DUMMY
#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
This however generates 2 shader variants too many, and results using the combo “SHADOWS_OFF SHADOWS_NATIVE LIGHTMAP_OFF” when lighting is ON and lightmap is ON:
SHADOWS_SCREEN SHADOWS_NATIVE LIGHTMAP_OFF
SHADOWS_SCREEN SHADOWS_NATIVE LIGHTMAP_ON
SHADOWS_SCREEN DUMMY LIGHTMAP_OFF
SHADOWS_SCREEN DUMMY LIGHTMAP_ON
SHADOWS_OFF SHADOWS_NATIVE LIGHTMAP_OFF
SHADOWS_OFF SHADOWS_NATIVE LIGHTMAP_ON
SHADOWS_OFF DUMMY LIGHTMAP_OFF
SHADOWS_OFF DUMMY LIGHTMAP_ON
In unity 5 I can solve this problem by doing something like
#pragma multi_compile_fwdbase
#pragma skip_variants DIRLIGHTMAP_ON DIRLIGHTMAP_OFF
but skip_variants is not a feature in unity 4.
Is there a way to conditionally define multi_compile?
#ifdef SHADOWS_SCREEN
#pragma multi_compile SHADOWS_NATIVE _
#endif
…or is there a way to define custom combos? Something like:
#pragma compile SHADOWS_SCREEN SHADOWS_NATIVE LIGHTMAP_OFF
#pragma compile SHADOWS_SCREEN SHADOWS_NATIVE LIGHTMAP_ON
#pragma compile SHADOWS_SCREEN LIGHTMAP_OFF
etc…