Ejemplo n.º 1
0
        void DrawAxfSurfaceOptionsGUI()
        {
            AxfBrdfType AxF_BRDFType = (AxfBrdfType)m_AxF_BRDFType.floatValue;

            AxF_BRDFType = (AxfBrdfType)EditorGUILayout.Popup("BRDF Type", (int)AxF_BRDFType, AxfBrdfTypeNames);
            m_AxF_BRDFType.floatValue = (float)AxF_BRDFType;

            // Extract flag:
            uint flags = (uint)m_Flags.floatValue;

            ExtractFlags(flags,
                         out bool anisotropy, out bool clearcoat, out bool clearcoatRefraction, out bool useHeightMap, out bool brdfColorDiagonalClamp,
                         out bool honorMinRoughness);

            switch (AxF_BRDFType)
            {
            case AxfBrdfType.SVBRDF:
            {
                EditorGUILayout.Space();
                ++EditorGUI.indentLevel;

                // Read as compact flags
                //uint    flags = (uint)m_Flags.floatValue;
                uint BRDFType     = (uint)m_SVBRDF_BRDFType.floatValue;
                uint BRDFVariants = (uint)m_SVBRDF_BRDFVariants.floatValue;

                SvbrdfDiffuseType          diffuseType    = (SvbrdfDiffuseType)(BRDFType & 0x1);
                SvbrdfSpecularType         specularType   = (SvbrdfSpecularType)((BRDFType >> 1) & 0x7);
                SvbrdfFresnelVariant       fresnelVariant = (SvbrdfFresnelVariant)(BRDFVariants & 0x3);
                SvbrdfSpecularVariantWard  wardVariant    = (SvbrdfSpecularVariantWard)((BRDFVariants >> 2) & 0x3);
                SvbrdfSpecularVariantBlinn blinnVariant   = (SvbrdfSpecularVariantBlinn)((BRDFVariants >> 4) & 0x3);

                // Expand as user-friendly UI
                EditorGUILayout.LabelField("BRDF Variants", EditorStyles.boldLabel);

                diffuseType  = (SvbrdfDiffuseType)EditorGUILayout.Popup("Diffuse Type", (int)diffuseType, SvbrdfDiffuseTypeNames);
                specularType = (SvbrdfSpecularType)EditorGUILayout.Popup("Specular Type", (int)specularType, SvbrdfSpecularTypeNames);

                if (specularType == SvbrdfSpecularType.WARD)
                {
                    fresnelVariant = (SvbrdfFresnelVariant)EditorGUILayout.Popup("Fresnel Variant", (int)fresnelVariant, SvbrdfFresnelVariantNames);
                    wardVariant    = (SvbrdfSpecularVariantWard)EditorGUILayout.Popup("Ward Variant", (int)wardVariant, SvbrdfSpecularVariantWardNames);
                }
                else if (specularType == SvbrdfSpecularType.BLINN_PHONG)
                {
                    blinnVariant = (SvbrdfSpecularVariantBlinn)EditorGUILayout.Popup("Blinn Variant", (int)blinnVariant, SvbrdfSpecularVariantBlinnNames);
                }

                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Parameters and Maps", EditorStyles.boldLabel);

                // Regular maps
                DrawRightJustifiedHeader(Styles.mapsTilingOffsetText.text);

                materialEditor.TexturePropertySingleLine(Styles.diffuseColorMapText, m_DiffuseColorMap, m_DiffuseColorMapST);
                materialEditor.TexturePropertySingleLine(Styles.specularColorMapText, m_SpecularColorMap, m_SpecularColorMapST);
                materialEditor.TexturePropertySingleLine(Styles.specularLobeMapText, m_SpecularLobeMap, m_SpecularLobeMapST);
                m_SpecularLobeMapScale.floatValue = EditorGUILayout.FloatField(Styles.specularLobeMapScaleText, m_SpecularLobeMapScale.floatValue);

                EditorGUILayout.Space();
                DrawRightJustifiedHeader(Styles.mapsTilingOffsetText.text);

                materialEditor.TexturePropertySingleLine(Styles.fresnelMapText, m_FresnelMap, m_FresnelMapST);
                materialEditor.TexturePropertySingleLine(Styles.normalMapText, m_NormalMap, m_NormalMapST);

                // Alpha
                materialEditor.TexturePropertySingleLine(Styles.alphaMapText, m_AlphaMap, m_AlphaMapST);

                // Displacement
                //TODO: unsupported for now
                //useHeightMap = EditorGUILayout.Toggle("Enable Displacement Map", useHeightMap);
                useHeightMap = false;
                if (useHeightMap)
                {
                    ++EditorGUI.indentLevel;
                    DrawRightJustifiedHeader(Styles.mapsTilingOffsetText.text);
                    materialEditor.TexturePropertySingleLine(Styles.heightMapText, m_HeightMap, m_HeightMapST);
                    materialEditor.ShaderProperty(m_SVBRDF_HeightMapMaxMM, "Max Displacement (mm)");
                    --EditorGUI.indentLevel;
                }

                // Anisotropy
                anisotropy = EditorGUILayout.Toggle("Is Anisotropic", anisotropy);
                if (anisotropy)
                {
                    ++EditorGUI.indentLevel;
                    DrawRightJustifiedHeader(Styles.mapsTilingOffsetText.text);
                    materialEditor.TexturePropertySingleLine(Styles.anisoRotationMapText, m_AnisoRotationMap, m_AnisoRotationMapST);
                    --EditorGUI.indentLevel;
                }

                // Clearcoat
                clearcoat = EditorGUILayout.Toggle("Enable Clearcoat", clearcoat);
                if (clearcoat)
                {
                    ++EditorGUI.indentLevel;
                    DrawRightJustifiedHeader(Styles.mapsTilingOffsetText.text);
                    materialEditor.TexturePropertySingleLine(Styles.clearcoatColorMapText, m_ClearcoatColorMap, m_ClearcoatColorMapST);
                    materialEditor.TexturePropertySingleLine(Styles.clearcoatNormalMapText, m_ClearcoatNormalMap, m_ClearcoatNormalMapST);
                    clearcoatRefraction = EditorGUILayout.Toggle("Enable Refraction", clearcoatRefraction);
                    // The IOR map is always required for the coat F0, while in the CAR_PAINT model, the IOR
                    // is given by a scalar value.
                    DrawRightJustifiedHeader(Styles.mapsTilingOffsetText.text);
                    materialEditor.TexturePropertySingleLine(Styles.clearcoatIORMapText, m_ClearcoatIORMap, m_ClearcoatIORMapST);
                    --EditorGUI.indentLevel;
                }

                BRDFType  = 0;
                BRDFType |= (uint)diffuseType;
                BRDFType |= ((uint)specularType) << 1;

                BRDFVariants  = 0;
                BRDFVariants |= (uint)fresnelVariant;
                BRDFVariants |= ((uint)wardVariant) << 2;
                BRDFVariants |= ((uint)blinnVariant) << 4;

                m_SVBRDF_BRDFType.floatValue     = (float)BRDFType;
                m_SVBRDF_BRDFVariants.floatValue = (float)BRDFVariants;
                --EditorGUI.indentLevel;
                break;
            }

            case AxfBrdfType.CAR_PAINT:
            {
                EditorGUILayout.Space();
                ++EditorGUI.indentLevel;

                // Expand as user-friendly UI

                // Regular maps
                materialEditor.TexturePropertySingleLine(Styles.BRDFColorMapText, m_CarPaint2_BRDFColorMap);
                m_CarPaint2_BRDFColorMapScale.floatValue = EditorGUILayout.FloatField(Styles.BRDFColorMapScaleText, m_CarPaint2_BRDFColorMapScale.floatValue);

                brdfColorDiagonalClamp = EditorGUILayout.Toggle("BRDF Color Table Diagonal Clamping", brdfColorDiagonalClamp);
                if (brdfColorDiagonalClamp)
                {
                    ++EditorGUI.indentLevel;
                    m_CarPaint2_BRDFColorMapUVScale.vectorValue = EditorGUILayout.Vector2Field(Styles.BRDFColorMapUVScaleText, m_CarPaint2_BRDFColorMapUVScale.vectorValue);
                    --EditorGUI.indentLevel;
                }

                DrawRightJustifiedHeader(Styles.BTFFlakesTilingText.text);
                materialEditor.TexturePropertySingleLine(Styles.BTFFlakesMapText, m_CarPaint2_BTFFlakeMap, m_CarPaint2_BTFFlakeMapST);
                //materialEditor.TexturePropertySingleLine(Styles.BTFFlakesMapText, m_CarPaint2_BTFFlakeMap);
                //m_CarPaint2_BTFFlakeMapST.vectorValue = EditorGUILayout.Vector4Field(Styles.BTFFlakesTilingText, m_CarPaint2_BTFFlakeMapST.vectorValue);

                //EditorGUILayout.LabelField( "Texture Dimension = " + m_CarPaint_BTFFlakesMap_sRGB.textureDimension );
                //EditorGUILayout.LabelField( "Texture Format = " + m_CarPaint_BTFFlakesMap_sRGB.textureValue. );
                m_CarPaint2_BTFFlakeMapScale.floatValue = EditorGUILayout.FloatField(Styles.BTFFlakesMapScaleText, m_CarPaint2_BTFFlakeMapScale.floatValue);

                materialEditor.TexturePropertySingleLine(Styles.thetaFI_sliceLUTMapText, m_CarPaint2_FlakeThetaFISliceLUTMap);

                materialEditor.ShaderProperty(m_CarPaint2_FixedColorThetaHForIndirectLight, Styles.CarPaintFixedColorThetaHForIndirectLightText);
                materialEditor.ShaderProperty(m_CarPaint2_FixedFlakesThetaHForIndirectLight, Styles.CarPaintFixedFlakesThetaHForIndirectLightText);

                //m_CarPaint2_FlakeMaxThetaI = FindProperty(m_CarPaint2_FlakeMaxThetaIText);
                //m_CarPaint2_FlakeNumThetaF = FindProperty(m_CarPaint2_FlakeNumThetaFText);
                //m_CarPaint2_FlakeNumThetaI = FindProperty(m_CarPaint2_FlakeNumThetaIText);

                m_CarPaint2_CTDiffuse.floatValue  = EditorGUILayout.FloatField(Styles.CarPaintCTDiffuseText, m_CarPaint2_CTDiffuse.floatValue);
                m_CarPaint2_LobeCount.floatValue  = Mathf.Floor(Mathf.Clamp(EditorGUILayout.FloatField(Styles.CarPaintLobeCountText, m_CarPaint2_LobeCount.floatValue), 0f, 3f));
                m_CarPaint2_CTF0s.vectorValue     = EditorGUILayout.Vector3Field(Styles.CarPaintCTF0sText, m_CarPaint2_CTF0s.vectorValue);
                m_CarPaint2_CTCoeffs.vectorValue  = EditorGUILayout.Vector3Field(Styles.CarPaintCTCoeffsText, m_CarPaint2_CTCoeffs.vectorValue);
                m_CarPaint2_CTSpreads.vectorValue = EditorGUILayout.Vector3Field(Styles.CarPaintCTSpreadsText, m_CarPaint2_CTSpreads.vectorValue);

                if (useHeightMap)
                {
                    materialEditor.ShaderProperty(m_SVBRDF_HeightMapMaxMM, "Max Displacement (mm)");
                }

                // Clearcoat
                clearcoat = EditorGUILayout.Toggle("Enable Clearcoat", clearcoat);
                if (clearcoat)
                {
                    ++EditorGUI.indentLevel;
                    //materialEditor.TexturePropertySingleLine( Styles.clearcoatColorMapText, m_ClearcoatColorMap );

                    DrawRightJustifiedHeader(Styles.clearcoatNormalMapTilingText.text);
                    materialEditor.TexturePropertySingleLine(Styles.clearcoatNormalMapText, m_ClearcoatNormalMap, m_ClearcoatNormalMapST);
                    //materialEditor.TexturePropertySingleLine(Styles.clearcoatNormalMapText, m_ClearcoatNormalMap);
                    //m_ClearcoatNormalMapST.vectorValue = EditorGUILayout.Vector4Field(Styles.clearcoatNormalMapTilingText, m_ClearcoatNormalMapST.vectorValue);

                    //materialEditor.TexturePropertySingleLine( Styles.clearcoatIORMapText, m_ClearcoatIORMap );
                    m_CarPaint2_ClearcoatIOR.floatValue = EditorGUILayout.FloatField(Styles.CarPaintIORText, m_CarPaint2_ClearcoatIOR.floatValue);
                    --EditorGUI.indentLevel;
                    clearcoatRefraction = EditorGUILayout.Toggle("Enable Refraction", clearcoatRefraction);
                }

                --EditorGUI.indentLevel;
                break;
            }
            }

            // Finally write back flags:
            flags = GenFlags(anisotropy, clearcoat, clearcoatRefraction, useHeightMap, brdfColorDiagonalClamp,
                             honorMinRoughness);
            m_Flags.floatValue = (float)flags;
        }//DrawAxfSurfaceOptionsGUI
Ejemplo n.º 2
0
        void DrawAxfSurfaceOptionsGUI()
        {
            materialEditor.ShaderProperty(m_MaterialTilingU, "Material Tiling U");
            materialEditor.ShaderProperty(m_MaterialTilingV, "Material Tiling V");

            AxfBrdfType AxF_BRDFType = (AxfBrdfType)m_AxF_BRDFType.floatValue;

            AxF_BRDFType = (AxfBrdfType)EditorGUILayout.Popup("BRDF Type", (int)AxF_BRDFType, AxfBrdfTypeNames);
            m_AxF_BRDFType.floatValue = (float)AxF_BRDFType;

            switch (AxF_BRDFType)
            {
            case AxfBrdfType.SVBRDF:
            {
                EditorGUILayout.Space();
                ++EditorGUI.indentLevel;

                // Read as compact flags
                uint flags        = (uint)m_Flags.floatValue;
                uint BRDFType     = (uint)m_SVBRDF_BRDFType.floatValue;
                uint BRDFVariants = (uint)m_SVBRDF_BRDFVariants.floatValue;

                SvbrdfDiffuseType          diffuseType    = (SvbrdfDiffuseType)(BRDFType & 0x1);
                SvbrdfSpecularType         specularType   = (SvbrdfSpecularType)((BRDFType >> 1) & 0x7);
                SvbrdfFresnelVariant       fresnelVariant = (SvbrdfFresnelVariant)(BRDFVariants & 0x3);
                SvbrdfSpecularVariantWard  wardVariant    = (SvbrdfSpecularVariantWard)((BRDFVariants >> 2) & 0x3);
                SvbrdfSpecularVariantBlinn blinnVariant   = (SvbrdfSpecularVariantBlinn)((BRDFVariants >> 4) & 0x3);

                // Expand as user-friendly UI
//                     EditorGUILayout.LabelField( "Flags", EditorStyles.boldLabel );
                EditorGUILayout.LabelField("BRDF Variants", EditorStyles.boldLabel);

                diffuseType  = (SvbrdfDiffuseType)EditorGUILayout.Popup("Diffuse Type", (int)diffuseType, SvbrdfDiffuseTypeNames);
                specularType = (SvbrdfSpecularType)EditorGUILayout.Popup("Specular Type", (int)specularType, SvbrdfSpecularTypeNames);

                if (specularType == SvbrdfSpecularType.WARD)
                {
                    fresnelVariant = (SvbrdfFresnelVariant)EditorGUILayout.Popup("Fresnel Variant", (int)fresnelVariant, SvbrdfFresnelVariantNames);
                    wardVariant    = (SvbrdfSpecularVariantWard)EditorGUILayout.Popup("Ward Variant", (int)wardVariant, SvbrdfSpecularVariantWardNames);
                }
                else if (specularType == SvbrdfSpecularType.BLINN_PHONG)
                {
                    blinnVariant = (SvbrdfSpecularVariantBlinn)EditorGUILayout.Popup("Blinn Variant", (int)blinnVariant, SvbrdfSpecularVariantBlinnNames);
                }

                // Regular maps
                materialEditor.TexturePropertySingleLine(Styles.diffuseColorMapText, m_DiffuseColorMap);
                materialEditor.TexturePropertySingleLine(Styles.specularColorMapText, m_SpecularColorMap);
                materialEditor.TexturePropertySingleLine(Styles.specularLobeMapText, m_SpecularLobeMap);
                m_SpecularLobeMapScale.floatValue = EditorGUILayout.FloatField(Styles.specularLobeMapScaleText, m_SpecularLobeMapScale.floatValue);
                materialEditor.TexturePropertySingleLine(Styles.fresnelMapText, m_FresnelMap);
                materialEditor.TexturePropertySingleLine(Styles.normalMapText, m_NormalMap);

                // Alpha
                materialEditor.TexturePropertySingleLine(Styles.alphaMapText, m_AlphaMap);

                // Displacement
                bool useDisplacementMap = EditorGUILayout.Toggle("Enable Displacement Map", (flags & 8) != 0);
                if (useDisplacementMap)
                {
                    ++EditorGUI.indentLevel;
                    materialEditor.TexturePropertySingleLine(Styles.heightMapText, m_HeightMap);
                    materialEditor.ShaderProperty(m_SVBRDF_HeightMapMaxMM, "Max Displacement (mm)");
                    --EditorGUI.indentLevel;
                }

                // Anisotropy
                bool isAnisotropic = EditorGUILayout.Toggle("Is Anisotropic", (flags & 1) != 0);
                if (isAnisotropic)
                {
                    ++EditorGUI.indentLevel;
                    materialEditor.TexturePropertySingleLine(Styles.anisoRotationMapText, m_AnisoRotationMap);
                    --EditorGUI.indentLevel;
                }

                // Clearcoat
                bool hasClearcoat            = EditorGUILayout.Toggle("Enable Clearcoat", (flags & 2) != 0);
                bool clearcoatUsesRefraction = (flags & 4) != 0;
                if (hasClearcoat)
                {
                    ++EditorGUI.indentLevel;
                    materialEditor.TexturePropertySingleLine(Styles.clearcoatColorMapText, m_ClearcoatColorMap);
                    materialEditor.TexturePropertySingleLine(Styles.clearcoatNormalMapText, m_ClearcoatNormalMap);
                    clearcoatUsesRefraction = EditorGUILayout.Toggle("Enable Refraction", clearcoatUsesRefraction);
                    if (clearcoatUsesRefraction)
                    {
                        ++EditorGUI.indentLevel;
                        materialEditor.TexturePropertySingleLine(Styles.clearcoatIORMapText, m_ClearcoatIORMap);
                        --EditorGUI.indentLevel;
                    }
                    --EditorGUI.indentLevel;
                }

                // Write back as compact flags
                flags  = 0;
                flags |= isAnisotropic ? 1U : 0U;
                flags |= hasClearcoat ? 2U : 0U;
                flags |= clearcoatUsesRefraction ? 4U : 0U;
                flags |= useDisplacementMap ? 8U : 0U;

                BRDFType  = 0;
                BRDFType |= (uint)diffuseType;
                BRDFType |= ((uint)specularType) << 1;

                BRDFVariants  = 0;
                BRDFVariants |= (uint)fresnelVariant;
                BRDFVariants |= ((uint)wardVariant) << 2;
                BRDFVariants |= ((uint)blinnVariant) << 4;

//                    cmd.SetGlobalFloat( HDShaderIDs._TexturingModeFlags, *(float*) &texturingModeFlags );
                m_Flags.floatValue               = (float)flags;
                m_SVBRDF_BRDFType.floatValue     = (float)BRDFType;
                m_SVBRDF_BRDFVariants.floatValue = (float)BRDFVariants;

                --EditorGUI.indentLevel;
                break;
            }

            case AxfBrdfType.CAR_PAINT:
            {
                EditorGUILayout.Space();
                ++EditorGUI.indentLevel;

                // Read as compact flags
                uint flags = (uint)m_Flags.floatValue;

                bool isAnisotropic      = false;
                bool useDisplacementMap = false;

                // Expand as user-friendly UI

                // Regular maps
                materialEditor.TexturePropertySingleLine(Styles.BRDFColorMapText, m_CarPaint2_BRDFColorMap);
                m_CarPaint2_BRDFColorMapScale.floatValue = EditorGUILayout.FloatField(Styles.BRDFColorMapScaleText, m_CarPaint2_BRDFColorMapScale.floatValue);

                bool brdfColorUseDiagonalClamp = EditorGUILayout.Toggle("BRDF Color Table Diagonal Clamping", (flags & 16) != 0);
                if (brdfColorUseDiagonalClamp)
                {
                    ++EditorGUI.indentLevel;
                    m_CarPaint2_BRDFColorMapUVScale.vectorValue = EditorGUILayout.Vector2Field(Styles.BRDFColorMapUVScaleText, m_CarPaint2_BRDFColorMapUVScale.vectorValue);
                    --EditorGUI.indentLevel;
                }


                materialEditor.TexturePropertySingleLine(Styles.BTFFlakesMapText, m_CarPaint2_BTFFlakeMap);
                //EditorGUILayout.LabelField( "Texture Dimension = " + m_CarPaint_BTFFlakesMap_sRGB.textureDimension );
                //EditorGUILayout.LabelField( "Texture Format = " + m_CarPaint_BTFFlakesMap_sRGB.textureValue. );
                m_CarPaint2_BTFFlakeMapScale.floatValue = EditorGUILayout.FloatField(Styles.BTFFlakesMapScaleText, m_CarPaint2_BTFFlakeMapScale.floatValue);
                m_CarPaint2_FlakeTiling.floatValue      = EditorGUILayout.FloatField(Styles.FlakesTilingText, m_CarPaint2_FlakeTiling.floatValue);

                materialEditor.TexturePropertySingleLine(Styles.thetaFI_sliceLUTMapText, m_CarPaint2_FlakeThetaFISliceLUTMap);

                // m_CarPaint_maxThetaI = FindProperty( m_CarPaint_maxThetaIText, props );
                // m_CarPaint_numThetaF = FindProperty( m_CarPaint_numThetaFText, props );
                // m_CarPaint_numThetaI = FindProperty( m_CarPaint_numThetaIText, props );


                // Clearcoat
                bool hasClearcoat            = EditorGUILayout.Toggle("Enable Clearcoat", (flags & 2) != 0);
                bool clearcoatUsesRefraction = (flags & 4) != 0;
                if (hasClearcoat)
                {
                    ++EditorGUI.indentLevel;
//                        materialEditor.TexturePropertySingleLine( Styles.clearcoatColorMapText, m_ClearcoatColorMap );
                    materialEditor.TexturePropertySingleLine(Styles.clearcoatNormalMapText, m_ClearcoatNormalMap);
//                        if ( clearcoatUsesRefraction ) {
                    {
                        ++EditorGUI.indentLevel;
//                            materialEditor.TexturePropertySingleLine( Styles.clearcoatIORMapText, m_ClearcoatIORMap );
                        m_CarPaint2_ClearcoatIOR.floatValue = EditorGUILayout.FloatField(Styles.CarPaintIORText, m_CarPaint2_ClearcoatIOR.floatValue);
                        --EditorGUI.indentLevel;
                    }
                    --EditorGUI.indentLevel;
                    clearcoatUsesRefraction = EditorGUILayout.Toggle("Enable Refraction", clearcoatUsesRefraction);
                }

                // Write back as compact flags
                flags  = 0;
                flags |= isAnisotropic ? 1U : 0U;
                flags |= hasClearcoat ? 2U : 0U;
                flags |= clearcoatUsesRefraction ? 4U : 0U;
                flags |= useDisplacementMap ? 8U : 0U;
                flags |= brdfColorUseDiagonalClamp ? 16U : 0U;

//                    cmd.SetGlobalFloat( HDShaderIDs._TexturingModeFlags, *(float*) &texturingModeFlags );
                m_Flags.floatValue = (float)flags;

                --EditorGUI.indentLevel;
                break;
            }
            }
        }
Ejemplo n.º 3
0
        // All Setup Keyword functions must be static. It allow to create script to automatically update the shaders with a script if code change
        static public void SetupAxFKeywordsAndPass(Material material)
        {
            material.SetupBaseUnlitKeywords();
            material.SetupBaseUnlitPass();

            AxfBrdfType BRDFType = (AxfBrdfType)material.GetFloat(kAxF_BRDFType);

            CoreUtils.SetKeyword(material, "_AXF_BRDF_TYPE_SVBRDF", BRDFType == AxfBrdfType.SVBRDF);
            CoreUtils.SetKeyword(material, "_AXF_BRDF_TYPE_CAR_PAINT", BRDFType == AxfBrdfType.CAR_PAINT);
            //unsupported for now: CoreUtils.SetKeyword(material, "_AXF_BRDF_TYPE_BTF", BRDFType == AxfBrdfType.BTF);


            // Mapping Modes:
            AxFMappingMode mappingMode = (AxFMappingMode)material.GetFloat(kMappingMode);

            // Make sure the mask is synched:
            material.SetVector(kMappingMask, AxFMappingModeToMask(mappingMode));

            bool mappingIsPlanar = (mappingMode >= AxFMappingMode.PlanarXY) && (mappingMode < AxFMappingMode.Triplanar);
            bool planarIsLocal   = (material.GetFloat(kPlanarSpace) > 0.0f);

            CoreUtils.SetKeyword(material, "_MAPPING_PLANAR", mappingIsPlanar);
            CoreUtils.SetKeyword(material, "_MAPPING_TRIPLANAR", mappingMode == AxFMappingMode.Triplanar);

            if (mappingIsPlanar || mappingMode == AxFMappingMode.Triplanar)
            {
                CoreUtils.SetKeyword(material, "_PLANAR_LOCAL", planarIsLocal);
            }

            // Note: for ShaderPass defines for vertmesh/varyingmesh setup, we still use the same
            // defines _REQUIRE_UV2 and _REQUIRE_UV3, and thus if eg _REQUIRE_UV3 is defined, _REQUIRE_UV2 will
            // be assumed to be needed. But here in the AxFData sampling code, we use these to indicate precisely
            // the single set used (if not using planar/triplanar) only and thus add _REQUIRE_UV1.
            // Extra UVs might be transfered but we only need and support a single set at a time for the whole material.
            CoreUtils.SetKeyword(material, "_REQUIRE_UV1", mappingMode == AxFMappingMode.UV1);
            CoreUtils.SetKeyword(material, "_REQUIRE_UV2", mappingMode == AxFMappingMode.UV2);
            CoreUtils.SetKeyword(material, "_REQUIRE_UV3", mappingMode == AxFMappingMode.UV3);

            // Keywords for opt-out of decals and SSR:
            bool decalsEnabled = material.HasProperty(kEnableDecals) && material.GetFloat(kEnableDecals) > 0.0f;

            CoreUtils.SetKeyword(material, "_DISABLE_DECALS", !decalsEnabled);

            bool ssrEnabled = false;

            if (material.GetSurfaceType() == SurfaceType.Transparent)
            {
                ssrEnabled = material.HasProperty(kReceivesSSRTransparent) ? material.GetFloat(kReceivesSSRTransparent) != 0 : false;
            }
            else
            {
                ssrEnabled = material.HasProperty(kReceivesSSR) ? material.GetFloat(kReceivesSSR) != 0 : false;
            }
            CoreUtils.SetKeyword(material, "_DISABLE_SSR", material.HasProperty(kReceivesSSR) && material.GetFloat(kReceivesSSR) == 0.0f);
            CoreUtils.SetKeyword(material, "_DISABLE_SSR_TRANSPARENT", material.HasProperty(kReceivesSSRTransparent) && material.GetFloat(kReceivesSSRTransparent) == 0.0);
            CoreUtils.SetKeyword(material, "_ENABLE_GEOMETRIC_SPECULAR_AA", material.HasProperty(kEnableGeometricSpecularAA) && material.GetFloat(kEnableGeometricSpecularAA) > 0.0f);
            CoreUtils.SetKeyword(material, "_SPECULAR_OCCLUSION_NONE", material.HasProperty(kSpecularOcclusionMode) && material.GetFloat(kSpecularOcclusionMode) == 0.0f);

            BaseLitGUI.SetupStencil(material, receivesSSR: ssrEnabled, useSplitLighting: false);

            if (material.HasProperty(kAddPrecomputedVelocity))
            {
                CoreUtils.SetKeyword(material, "_ADD_PRECOMPUTED_VELOCITY", material.GetInt(kAddPrecomputedVelocity) != 0);
            }
            //
            // Patch for raytracing for now: mirror int props as float explicitly
            //
            uint flags = (uint)material.GetFloat(kFlags);

            flags |= (uint)AxF.FeatureFlags.AxfDebugTest; // force bit 23 = 1
            material.SetFloat(kFlagsB, flags);

            uint SVBRDFType     = (uint)material.GetFloat(kSVBRDF_BRDFType);
            uint SVBRDFVariants = (uint)material.GetFloat(kSVBRDF_BRDFVariants);

            SvbrdfDiffuseType          diffuseType    = (SvbrdfDiffuseType)(SVBRDFType & 0x1);
            SvbrdfSpecularType         specularType   = (SvbrdfSpecularType)((SVBRDFType >> 1) & 0x7);
            SvbrdfFresnelVariant       fresnelVariant = (SvbrdfFresnelVariant)(SVBRDFVariants & 0x3);
            SvbrdfSpecularVariantWard  wardVariant    = (SvbrdfSpecularVariantWard)((SVBRDFVariants >> 2) & 0x3);
            SvbrdfSpecularVariantBlinn blinnVariant   = (SvbrdfSpecularVariantBlinn)((SVBRDFVariants >> 4) & 0x3);

            material.SetFloat(kSVBRDF_BRDFType_DiffuseType, (float)diffuseType);
            material.SetFloat(kSVBRDF_BRDFType_SpecularType, (float)specularType);
            material.SetFloat(kSVBRDF_BRDFVariants_FresnelType, (float)fresnelVariant);
            material.SetFloat(kSVBRDF_BRDFVariants_WardType, (float)wardVariant);
            material.SetFloat(kSVBRDF_BRDFVariants_BlinnType, (float)blinnVariant);

            material.SetFloat(kCarPaint2_FlakeMaxThetaI + kIntPropAsFloatSuffix, material.GetFloat(kCarPaint2_FlakeMaxThetaI));
            material.SetFloat(kCarPaint2_FlakeNumThetaF + kIntPropAsFloatSuffix, material.GetFloat(kCarPaint2_FlakeNumThetaF));
            material.SetFloat(kCarPaint2_FlakeNumThetaI + kIntPropAsFloatSuffix, material.GetFloat(kCarPaint2_FlakeNumThetaI));
        }