Material Feature flags are now also used to statically remove code that is not needed in case there are 2 or more different materials in the same tile (thus preventing us from statically knowing the materialID)
// This method allows us to know at compile time what shader features should be removed from the code when the materialID cannot be known on the whole tile (any combination of 2 or more differnet materials in the same tile)
bool HasMaterialFeatureFlag(int flag)
{
return ((g_FeatureFlags & flag) != 0);
}
// Combination need to be define in increasing "comlexity" order as define by FeatureFlagsToTileVariant
outGBuffer1.a = PackMaterialId(MATERIALID_LIT_STANDARD); // Encode MATERIALID_LIT_SPECULAR as MATERIALID_LIT_STANDARD + GBUFFER_LIT_STANDARD_SPECULAR_COLOR_ID value in GBuffer2
else if (surfaceData.materialId == MATERIALID_LIT_SSS)
else if (surfaceData.materialId == MATERIALID_LIT_SSS && HasMaterialFeatureFlag(MATERIALFEATUREFLAGS_LIT_SSS))
else if (surfaceData.materialId == MATERIALID_LIT_ANISO)
else if (surfaceData.materialId == MATERIALID_LIT_ANISO && HasMaterialFeatureFlag(MATERIALFEATUREFLAGS_LIT_ANISO))
else if (surfaceData.materialId == MATERIALID_LIT_CLEAR_COAT)
else if (surfaceData.materialId == MATERIALID_LIT_CLEAR_COAT && HasMaterialFeatureFlag(MATERIALFEATUREFLAGS_LIT_CLEAR_COAT))
{
// In the cae of clear coat, we want more precision for the coat normal than for the bottom normal (as it is expected to be smooth). So swap the normal encoding storage in Gbuffer.