Beispiel #1
0
        /// <summary>
        /// Renders the properties in the block.
        /// </summary>
        protected override void OnGUIOpen()
        {
            EditorGUI.BeginChangeCheck();
            float val = EditorGUILayout.Popup(Styles.mappingModeText, (int)m_MappingMode.floatValue, MappingModeNames);

            if (EditorGUI.EndChangeCheck())
            {
                Material material = materialEditor.target as Material;
                Undo.RecordObject(material, "Change Mapping Mode");
                m_MappingMode.floatValue = val;
            }

            AxFMappingMode mappingMode = (AxFMappingMode)m_MappingMode.floatValue;

            m_MappingMask.vectorValue = AxFGUI.AxFMappingModeToMask(mappingMode);

            if (mappingMode >= AxFMappingMode.PlanarXY)
            {
                ++EditorGUI.indentLevel;
                materialEditor.ShaderProperty(m_PlanarSpace, Styles.planarSpaceText);
                --EditorGUI.indentLevel;
            }

            materialEditor.ShaderProperty(m_MaterialTilingOffset, Styles.materialTilingOffsetText);

            // We only display the ray tracing option if the asset supports it
            if ((RenderPipelineManager.currentPipeline as HDRenderPipeline).rayTracingSupported)
            {
                materialEditor.ShaderProperty(m_RayTracingTexFilteringScale, Styles.rayTracingTexFilteringScaleText);
            }
        }
        void DrawMainAxfSurfaceInputsGUI()
        {
            EditorGUI.BeginChangeCheck();
            float val = EditorGUILayout.Popup(Styles.mappingModeText, (int)m_MappingMode.floatValue, MappingModeNames);

            if (EditorGUI.EndChangeCheck())
            {
                Material material = materialEditor.target as Material;
                Undo.RecordObject(material, "Change Mapping Mode");
                m_MappingMode.floatValue = val;
            }

            AxFMappingMode mappingMode = (AxFMappingMode)m_MappingMode.floatValue;

            m_MappingMask.vectorValue = AxFGUI.AxFMappingModeToMask(mappingMode);

            if (mappingMode >= AxFMappingMode.PlanarXY)
            {
                ++EditorGUI.indentLevel;
                materialEditor.ShaderProperty(m_PlanarSpace, Styles.planarSpaceText);
                --EditorGUI.indentLevel;
            }

            materialEditor.ShaderProperty(m_MaterialTilingOffset, Styles.materialTilingOffsetText);
        }
Beispiel #3
0
        /// <summary>
        /// Renders the properties in the block.
        /// </summary>
        protected override void OnGUIOpen()
        {
            materialEditor.PopupShaderProperty(m_MappingMode, Styles.mappingModeText, MappingModeNames);

            AxFMappingMode mappingMode = (AxFMappingMode)m_MappingMode.floatValue;

            m_MappingMask.vectorValue = AxFGUI.AxFMappingModeToMask(mappingMode);

            if (mappingMode >= AxFMappingMode.PlanarXY)
            {
                ++EditorGUI.indentLevel;
                materialEditor.ShaderProperty(m_PlanarSpace, Styles.planarSpaceText);
                --EditorGUI.indentLevel;
            }

            materialEditor.ShaderProperty(m_MaterialTilingOffset, Styles.materialTilingOffsetText);

            // We only display the ray tracing option if the asset supports it
            if ((RenderPipelineManager.currentPipeline as HDRenderPipeline).rayTracingSupported)
            {
                materialEditor.ShaderProperty(m_RayTracingTexFilteringScale, Styles.rayTracingTexFilteringScaleText);
            }
        }
        void DrawAxfSurfaceOptionsGUI()
        {
            //materialEditor.ShaderProperty(m_MappingMode, Styles.mappingModeText);
            EditorGUI.BeginChangeCheck();
            float val = EditorGUILayout.Popup(Styles.mappingModeText, (int)m_MappingMode.floatValue, MappingModeNames);

            if (EditorGUI.EndChangeCheck())
            {
                Material material = materialEditor.target as Material;
                Undo.RecordObject(material, "Change Mapping Mode");
                m_MappingMode.floatValue = val;
            }

            AxFMappingMode mappingMode = (AxFMappingMode)m_MappingMode.floatValue;

            m_MappingMask.vectorValue = AxFGUI.AxFMappingModeToMask(mappingMode);

            if (mappingMode >= AxFMappingMode.PlanarXY)
            {
                ++EditorGUI.indentLevel;
                materialEditor.ShaderProperty(m_PlanarSpace, Styles.planarSpaceText);
                --EditorGUI.indentLevel;
            }

            materialEditor.ShaderProperty(m_MaterialTilingOffset, Styles.materialTilingOffsetText);

            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( "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, 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);
                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;
                    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;
                    materialEditor.TexturePropertySingleLine(Styles.anisoRotationMapText, m_AnisoRotationMap, m_AnisoRotationMapST);
                    --EditorGUI.indentLevel;
                }

                // Clearcoat
                clearcoat = EditorGUILayout.Toggle("Enable Clearcoat", clearcoat);
                if (clearcoat)
                {
                    ++EditorGUI.indentLevel;
                    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.
                    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;

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

                --EditorGUI.indentLevel;
                break;
            }

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

                useHeightMap = 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);

                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;
                }


                //materialEditor.TexturePropertySingleLine(Styles.BTFFlakesMapText, m_CarPaint2_BTFFlakeMap, m_CarPaint2_BTFFlakeMapST);
                materialEditor.TexturePropertySingleLine(Styles.BTFFlakesMapText, m_CarPaint2_BTFFlakeMap, m_CarPaint2_BTFFlakeMapST);
                //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);

                //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);
                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 );
                    //materialEditor.TexturePropertySingleLine(Styles.clearcoatNormalMapText, m_ClearcoatNormalMap);
                    materialEditor.TexturePropertySingleLine(Styles.clearcoatNormalMapText, m_ClearcoatNormalMap, m_ClearcoatNormalMapST);
                    //materialEditor.TexturePropertySingleLine(Styles.clearcoatNormalMapText, m_ClearcoatNormalMap, m_ClearcoatNormalMapST);

//                        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);
                }

//                    cmd.SetGlobalFloat( HDShaderIDs._TexturingModeFlags, *(float*) &texturingModeFlags );

                --EditorGUI.indentLevel;
                break;
            }
            }

            // Finally write back flags:
            flags = GenFlags(anisotropy, clearcoat, clearcoatRefraction, useHeightMap, brdfColorDiagonalClamp,
                             honorMinRoughness);
            m_Flags.floatValue = (float)flags;
        }//DrawAxfSurfaceOptionsGUI