FArchive& operator<<(FArchive& Ar,FVertexFactoryType*& TypeRef) { if(Ar.IsSaving()) { FName TypeName = TypeRef ? FName(TypeRef->GetName()) : NAME_None; Ar << TypeName; } else if(Ar.IsLoading()) { FName TypeName = NAME_None; Ar << TypeName; TypeRef = FindVertexFactoryType(TypeName); } return Ar; }
/** * Should the shader for this material with the given platform, shader type and vertex * factory type combination be compiled * * @param Platform The platform currently being compiled for * @param ShaderType Which shader is being compiled * @param VertexFactory Which vertex factory is being compiled (can be NULL) * * @return true if the shader should be compiled */ virtual bool ShouldCache(EShaderPlatform Platform, const FShaderType* ShaderType, const FVertexFactoryType* VertexFactoryType) const { // only generate the needed shaders (which should be very restrictive for fast recompiling during editing) // @todo: Add a FindShaderType by fname or something if( Material->IsUIMaterial() ) { if (FCString::Stristr(ShaderType->GetName(), TEXT("TSlateMaterialShaderPS"))) { return true; } } { bool bEditorStatsMaterial = Material->bIsMaterialEditorStatsMaterial; // Always allow HitProxy shaders. if (FCString::Stristr(ShaderType->GetName(), TEXT("HitProxy"))) { return true; } // we only need local vertex factory for the preview static mesh if (VertexFactoryType != FindVertexFactoryType(FName(TEXT("FLocalVertexFactory"), FNAME_Find))) { //cache for gpu skinned vertex factory if the material allows it //this way we can have a preview skeletal mesh if (bEditorStatsMaterial || !IsUsedWithSkeletalMesh() || (VertexFactoryType != FindVertexFactoryType(FName(TEXT("TGPUSkinVertexFactoryfalse"), FNAME_Find)) && VertexFactoryType != FindVertexFactoryType(FName(TEXT("TGPUSkinVertexFactorytrue"), FNAME_Find)))) { return false; } } if (bEditorStatsMaterial) { TArray<FString> ShaderTypeNames; TArray<FString> ShaderTypeDescriptions; GetRepresentativeShaderTypesAndDescriptions(ShaderTypeNames, ShaderTypeDescriptions); //Only allow shaders that are used in the stats. return ShaderTypeNames.Find(ShaderType->GetName()) != INDEX_NONE; } // look for any of the needed type bool bShaderTypeMatches = false; // For FMaterialResource::GetRepresentativeInstructionCounts if (FCString::Stristr(ShaderType->GetName(), TEXT("BasePassPSTDistanceFieldShadowsAndLightMapPolicyHQ"))) { bShaderTypeMatches = true; } else if (FCString::Stristr(ShaderType->GetName(), TEXT("BasePassPSFNoLightMapPolicy"))) { bShaderTypeMatches = true; } else if (FCString::Stristr(ShaderType->GetName(), TEXT("CachedPointIndirectLightingPolicy"))) { bShaderTypeMatches = true; } else if (FCString::Stristr(ShaderType->GetName(), TEXT("BasePassPSFSelfShadowedTranslucencyPolicy"))) { bShaderTypeMatches = true; } // Pick tessellation shader based on material settings else if(FCString::Stristr(ShaderType->GetName(), TEXT("BasePassVSFNoLightMapPolicy")) || FCString::Stristr(ShaderType->GetName(), TEXT("BasePassHSFNoLightMapPolicy")) || FCString::Stristr(ShaderType->GetName(), TEXT("BasePassDSFNoLightMapPolicy"))) { bShaderTypeMatches = true; } else if (FCString::Stristr(ShaderType->GetName(), TEXT("DepthOnly"))) { bShaderTypeMatches = true; } else if (FCString::Stristr(ShaderType->GetName(), TEXT("ShadowDepth"))) { bShaderTypeMatches = true; } else if (FCString::Stristr(ShaderType->GetName(), TEXT("TDistortion"))) { bShaderTypeMatches = true; } else if (FCString::Stristr(ShaderType->GetName(), TEXT("TBasePassForForwardShading"))) { bShaderTypeMatches = true; } return bShaderTypeMatches; } }