首页 > 其他分享 >shadowDepth变体条件

shadowDepth变体条件

时间:2023-02-09 18:44:48浏览次数:29  
标签:const Parameters shadowDepth MaterialParameters return Platform && 条件 变体

投射动态shadow函数

inline bool ShouldCastDynamicShadows() const
    {
        return !GetShadingModels().HasOnlyShadingModel(MSM_SingleLayerWater) &&
                (GetBlendMode() == BLEND_Opaque
                  || GetBlendMode() == BLEND_Masked
                   || (GetBlendMode() == BLEND_Translucent && GetCastDynamicShadowAsMasked()));
    }

变量赋值

FMaterialShaderParameters(const FMaterial* InMaterial)
    {
        // Make sure to zero-initialize so we get consistent hashes
        FMemory::Memzero(*this);

        ……
        bShouldCastDynamicShadows = InMaterial->ShouldCastDynamicShadows();

TshadowDepthVS的should函数

/**
* A vertex shader for rendering the depth of a mesh.
*/
template <EShadowDepthVertexShaderMode ShaderMode, bool bRenderReflectiveShadowMap, bool bUsePositionOnlyStream, bool bIsForGeometryShader = false>
class TShadowDepthVS : public FShadowDepthVS
{
    DECLARE_SHADER_TYPE(TShadowDepthVS, MeshMaterial);
public:

    TShadowDepthVS(const ShaderMetaType::CompiledShaderInitializerType& Initializer) :
        FShadowDepthVS(Initializer)
    {
    }

    TShadowDepthVS() {}

    static bool ShouldCompilePermutation(const FMeshMaterialShaderPermutationParameters& Parameters)
    {
        const EShaderPlatform Platform = Parameters.Platform;

        static const auto SupportAllShaderPermutationsVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportAllShaderPermutations"));
        const bool bForceAllPermutations = SupportAllShaderPermutationsVar && SupportAllShaderPermutationsVar->GetValueOnAnyThread() != 0;
        const bool bSupportPointLightWholeSceneShadows = CVarSupportPointLightWholeSceneShadows.GetValueOnAnyThread() != 0 || bForceAllPermutations;
        const bool bRHISupportsShadowCastingPointLights = RHISupportsGeometryShaders(Platform) || RHISupportsVertexShaderLayer(Platform);

        if (bIsForGeometryShader && ShaderMode == VertexShadowDepth_VSLayer)
        {
            return false;
        }

        if (bIsForGeometryShader && (!bSupportPointLightWholeSceneShadows || !bRHISupportsShadowCastingPointLights))
        {
            return false;
        }

        //Note: This logic needs to stay in sync with OverrideWithDefaultMaterialForShadowDepth!
        // Compile for special engine materials.
        if (bRenderReflectiveShadowMap)
        {
            static const auto SupportLPV = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.LightPropagationVolume"));
            if (SupportLPV && SupportLPV->GetValueOnAnyThread() == 0)
            {
                return false;
            }
            else
            {
                // Reflective shadow map shaders must be compiled for every material because they access the material normal
                return !bUsePositionOnlyStream
                    // Don't render ShadowDepth for translucent unlit materials, unless we're injecting emissive
                    && (Parameters.MaterialParameters.bShouldCastDynamicShadows || Parameters.MaterialParameters.bShouldInjectEmissiveIntoLPV || Parameters.MaterialParameters.bShouldBlockGI)
                    && IsFeatureLevelSupported(Platform, ERHIFeatureLevel::SM5);
            }
        }
        else
        {
            return (Parameters.MaterialParameters.bIsSpecialEngineMaterial
                // Masked and WPO materials need their shaders but cannot be used with a position only stream.
                || ((!Parameters.MaterialParameters.bWritesEveryPixelShadowPass || Parameters.MaterialParameters.bMaterialMayModifyMeshPosition) && !bUsePositionOnlyStream))
                // Only compile one pass point light shaders for feature levels >= SM5
                && ((ShaderMode != VertexShadowDepth_OnePassPointLight && ShaderMode != VertexShadowDepth_VSLayer) || IsFeatureLevelSupported(Platform, ERHIFeatureLevel::SM5))
                // Only compile position-only shaders for vertex factories that support it. (Note: this assumes that a vertex factor which supports PositionOnly, supports also PositionAndNormalOnly)
                && (!bUsePositionOnlyStream || Parameters.VertexFactoryType->SupportsPositionOnly())
                // Don't render ShadowDepth for translucent unlit materials
                && Parameters.MaterialParameters.bShouldCastDynamicShadows;
        }
    }

需要材质参数的shouldCastDynamicShadows为true。

 

 

标签:const,Parameters,shadowDepth,MaterialParameters,return,Platform,&&,条件,变体
From: https://www.cnblogs.com/Shaojunping/p/17106679.html

相关文章

  • Python中合法标识符需要满足什么条件?
    所谓的标识符就是用户在定义变量的时候,使用的一种名字,也可以说是一种符号,可应用于不同的环境,而且每一个符号都表示着不同的意思。在Python中,对于标识符的定义是有一定要......
  • mybatisPlus条件构造器
      Wrapper:条件构造抽象类,最顶端父类AbstractWrapper:用于查询条件封装,生成sql的where条件QueryWrapper:Entity对象封装操作类,不是用lambda......
  • 建筑CAD制图:如何按各专业要求转条件图?
    在进行建筑CAD制图的时候,有些时候会需要按各专业要求转条件图/绘制立剖面,具体该如何进行操作呢?接下来的建筑CAD制图教程就让小编来给大家介绍一下国产CAD软件——浩辰CAD建......
  • ⑤ 查询条件动态生成
    1实现效果2单个查询框组件根据接口返回的conditions_configs字段动态生成查询框ConditionOne2.1模板<template><!--日期--><DatePicker2v-if="......
  • react 开始 六 条件渲染
    functionIn(props){return<div>111</div>}functionOut(props){return<div>000</div>}functionInOut(props){constv=props.value;//根据v决......
  • js 判断条件分支优化
    优化前:  1.简单分支优化:  2.复杂分支优化:    3.抽离分支:   ......
  • ⑩ 添加筛选条件
    1实现效果2应用2.1父组件调用模板<template><Row><Formlabel-position="right":label-width="80"><Colspan="24"v-for="(conditionItem,key,index......
  • 什么是BFC?它的触发条件有哪些?
    1.什么是BFC?BlockFromattingContext,即块级格式上下文。W3C对BFC的定义如下:浮动元素和绝对定位元素,非块级盒子的块级容器,以及overflow值不为"visiable"的块级盒子,都会......
  • 【SpringBoot】条件装配 @profile
    profile使用说明:@profile注解的作用是指定类或方法在特定的Profile环境生效,任何@Component或@Configuration注解的类都可以使用@Profile注解。在使用DI来依赖注入的......
  • sort()排序以及多个属性数组对象排序(按条件排序)
    原生排序letarr=[5,2,1,4,9,8]for(leti=0;i<arr.length;i++){for(letj=0;j<arr.length-1;j++){if(arr[j]>......