Example #1
0
#pragma warning restore 0162

        bool ApplyMaterial()
        {
            var colorGradient = MaterialManager.ColorGradient.Off;

            if (m_Master.colorMode == ColorMode.Gradient)
            {
                var precision = Utils.GetFloatPackingPrecision();
                colorGradient = precision == Utils.FloatPackingPrecision.High ? MaterialManager.ColorGradient.MatrixHigh : MaterialManager.ColorGradient.MatrixLow;
            }

            Debug.Assert((int)BlendingMode.Additive == (int)MaterialManager.BlendingMode.Additive);
            Debug.Assert((int)BlendingMode.SoftAdditive == (int)MaterialManager.BlendingMode.SoftAdditive);
            Debug.Assert((int)BlendingMode.TraditionalTransparency == (int)MaterialManager.BlendingMode.TraditionalTransparency);

            var staticProps = new MaterialManager.StaticProperties
            {
                blendingMode     = (MaterialManager.BlendingMode)m_Master.blendingMode,
                noise3D          = isNoiseEnabled ? MaterialManager.Noise3D.On : MaterialManager.Noise3D.Off,
                depthBlend       = isDepthBlendEnabled ? MaterialManager.DepthBlend.On : MaterialManager.DepthBlend.Off,
                colorGradient    = colorGradient,
                dynamicOcclusion = m_Master._INTERNAL_DynamicOcclusionMode_Runtime,
                meshSkewing      = m_Master.hasMeshSkewing ? MaterialManager.MeshSkewing.On : MaterialManager.MeshSkewing.Off,
                shaderAccuracy   = (m_Master.shaderAccuracy == ShaderAccuracy.Fast) ? MaterialManager.ShaderAccuracy.Fast : MaterialManager.ShaderAccuracy.High
            };

            Material mat = null;

            if (!shouldUseGPUInstancedMaterial)
            {
                mat = m_CustomMaterial;
                if (mat)
                {
                    staticProps.ApplyToMaterial(mat);
                }
            }
            else
            {
                mat = MaterialManager.GetInstancedMaterial(m_Master._INTERNAL_InstancedMaterialGroupID, staticProps);
            }

            meshRenderer.material = mat;
            return(mat != null);
        }
Example #2
0
#pragma warning restore 0162

        bool ApplyMaterial()
        {
            var colorGradient = MaterialManager.ColorGradient.Off;

            if (m_Master.colorMode == ColorMode.Gradient)
            {
                var precision = Utils.GetFloatPackingPrecision();
                colorGradient = precision == Utils.FloatPackingPrecision.High ? MaterialManager.ColorGradient.MatrixHigh : MaterialManager.ColorGradient.MatrixLow;
            }

            Debug.Assert((int)BlendingMode.Additive == (int)MaterialManager.BlendingMode.Additive);
            Debug.Assert((int)BlendingMode.SoftAdditive == (int)MaterialManager.BlendingMode.SoftAdditive);
            Debug.Assert((int)BlendingMode.TraditionalTransparency == (int)MaterialManager.BlendingMode.TraditionalTransparency);

            var staticProps = new MaterialManager.StaticProperties
            {
                blendingMode  = (MaterialManager.BlendingMode)m_Master.blendingMode,
                noise3D       = isNoiseEnabled ? MaterialManager.Noise3D.On : MaterialManager.Noise3D.Off,
                depthBlend    = isDepthBlendEnabled ? MaterialManager.DepthBlend.On : MaterialManager.DepthBlend.Off,
                colorGradient = colorGradient,
                clippingPlane = isClippingPlaneEnabled ? MaterialManager.ClippingPlane.On : MaterialManager.ClippingPlane.Off
            };

            Material mat = null;

            if (Config.Instance.actualRenderingMode != RenderingMode.GPUInstancing)
            {
                mat = m_CustomMaterial;
                if (mat)
                {
                    staticProps.ApplyToMaterial(mat);
                }
            }
            else
            {
                mat = MaterialManager.GetInstancedMaterial(m_Master._INTERNAL_InstancedMaterialGroupID, staticProps);
            }

            meshRenderer.material = mat;
            return(mat != null);
        }