コード例 #1
0
 public TextureReferences(TextureSemantic semantic, float scale)
 {
     Semantic                 = semantic;
     Scale                    = scale;
     SmoothnessSource         = null;
     SmoothnessTextureChannel = 0;
 }
コード例 #2
0
 public TextureReferences(TextureSemantic semantic)
 {
     Semantic                 = semantic;
     Scale                    = 1.0f;
     SmoothnessSource         = null;
     SmoothnessTextureChannel = 0;
 }
コード例 #3
0
 public TextureReferences(TextureSemantic semantic, float scale, Texture source,
                          SmoothnessTextureChannel smoothnessTextureChannel)
 {
     Semantic                 = semantic;
     Scale                    = scale;
     SmoothnessSource         = source;
     SmoothnessTextureChannel = smoothnessTextureChannel;
 }
コード例 #4
0
 private float _MapTextureChannelToFloat(SmoothnessTextureChannel workflowMode)
 {
     if (workflowMode == SmoothnessTextureChannel.metallicSpecular)
     {
         return(0f);
     }
     else
     {
         return(1f);
     }
 }
コード例 #5
0
        public void OnBeforeTintTexture(Material sourceMat, string shaderTexturePropertyName)
        {
            if (m_workflowMode == WorkflowMode.unknown)
            {
                if (sourceMat.HasProperty("_WorkflowMode"))
                {
                    m_workflowMode = _MapFloatToWorkflowMode(sourceMat.GetFloat("_WorkflowMode"));
                }
            }
            else
            {
                if (sourceMat.HasProperty("_WorkflowMode") && _MapFloatToWorkflowMode(sourceMat.GetFloat("_WorkflowMode")) != m_workflowMode)
                {
                    Debug.LogError("Using the Universal Render Pipeline TextureBlender to blend non-texture-propertyes. Some of the source materials used different 'WorkflowModes'. These " +
                                   " cannot be blended properly. Results will be unpredictable.");
                }
            }

            if (m_smoothnessTextureChannel == SmoothnessTextureChannel.unknown)
            {
                if (sourceMat.HasProperty("_SmoothnessTextureChannel"))
                {
                    m_smoothnessTextureChannel = _MapFloatToTextureChannel(sourceMat.GetFloat("_SmoothnessTextureChannel"));
                }
            }
            else
            {
                if (sourceMat.HasProperty("_SmoothnessTextureChannel") && _MapFloatToTextureChannel(sourceMat.GetFloat("_SmoothnessTextureChannel")) != m_smoothnessTextureChannel)
                {
                    Debug.LogError("Using the Universal Render Pipeline TextureBlender to blend non-texture-properties. Some of the source materials store smoothness in the Albedo texture alpha" +
                                   " and some source materials store smoothness in the Metallic/Specular texture alpha channel. The result material can only read smoothness from one or the other. Results will be unpredictable.");
                }
            }

            if (shaderTexturePropertyName.Equals("_BaseMap"))
            {
                propertyToDo = Prop.doColor;
                if (sourceMat.HasProperty("_BaseColor"))
                {
                    m_tintColor = sourceMat.GetColor("_BaseColor");
                }
                else
                {
                    m_tintColor = m_generatingTintedAtlaColor;
                }
            }
            else if (shaderTexturePropertyName.Equals("_SpecGlossMap"))
            {
                propertyToDo = Prop.doSpecular;
                m_specColor  = m_generatingTintedAtlaSpecular;
                if (sourceMat.GetTexture("_SpecGlossMap") != null)
                {
                    m_hasSpecGlossMap = true;
                }
                else
                {
                    m_hasSpecGlossMap = false;
                }

                if (sourceMat.HasProperty("_SpecColor"))
                {
                    m_specColor = sourceMat.GetColor("_SpecColor");
                }
                else
                {
                    m_specColor = new Color(0f, 0f, 0f, 1f);
                }

                if (sourceMat.HasProperty("_Smoothness") && m_workflowMode == WorkflowMode.specular)
                {
                    m_smoothness = sourceMat.GetFloat("_Smoothness");
                    Debug.LogError("TODO smooth " + sourceMat + "  " + m_smoothness);
                }
                else if (m_workflowMode == WorkflowMode.specular)
                {
                    m_smoothness = 1f;
                }
            }
            else if (shaderTexturePropertyName.Equals("_MetallicGlossMap"))
            {
                propertyToDo = Prop.doMetallic;
                if (sourceMat.GetTexture("_MetallicGlossMap") != null)
                {
                    m_hasMetallicGlossMap = true;
                }
                else
                {
                    m_hasMetallicGlossMap = false;
                }

                if (sourceMat.HasProperty("_Metallic"))
                {
                    m_metallic = sourceMat.GetFloat("_Metallic");
                }
                else
                {
                    m_metallic = 0f;
                }

                if (sourceMat.HasProperty("_Smoothness") && m_workflowMode == WorkflowMode.metallic)
                {
                    m_smoothness = sourceMat.GetFloat("_Smoothness");
                }
                else if (m_workflowMode == WorkflowMode.metallic)
                {
                    m_smoothness = 0f;
                }
            }
            else if (shaderTexturePropertyName.Equals("_BumpMap"))
            {
                propertyToDo = Prop.doBump;
                if (sourceMat.HasProperty(shaderTexturePropertyName))
                {
                    if (sourceMat.HasProperty("_BumpScale"))
                    {
                        m_bumpScale = sourceMat.GetFloat("_BumpScale");
                    }
                }
                else
                {
                    m_bumpScale = m_generatingTintedAtlaBumpScale;
                }
            }
            else if (shaderTexturePropertyName.Equals("_EmissionMap"))
            {
                propertyToDo         = Prop.doEmission;
                m_shaderDoesEmission = sourceMat.IsKeywordEnabled("_EMISSION");
                if (sourceMat.HasProperty("_EmissionColor"))
                {
                    m_emissionColor = sourceMat.GetColor("_EmissionColor");
                }
                else
                {
                    m_generatingTintedAtlaColor = m_notGeneratingAtlasDefaultEmisionColor;
                }
            }
            else
            {
                propertyToDo = Prop.doNone;
            }
        }