예제 #1
0
 void CheckTessMode()
 {
     if (tessmode != null)
     {
         int dispIs = (int)tessmode.floatValue;
         if (dispIs == (int)TessWorkflowMode.EdgeLength)
         {
             m_TessWorkflowMode = TessWorkflowMode.EdgeLength;
         }
         else
         {
             m_TessWorkflowMode = TessWorkflowMode.Distance;
         }
     }
 }
예제 #2
0
        static void MaterialChanged(Material material, WorkflowMode workflowMode, TessWorkflowMode tessWorkflowMode)
        {
            SetupMaterialWithBlendMode(material, (BlendMode)material.GetFloat("_Mode"));

            SetMaterialKeywords(material, workflowMode, tessWorkflowMode);
        }
예제 #3
0
        static void SetMaterialKeywords(Material material, WorkflowMode workflowMode, TessWorkflowMode tessWorkflowMode)
        {
            // Note: keywords must be based on Material value not on MaterialProperty due to multi-edit & material animation
            // (MaterialProperty value might come from renderer material property block)
            SetKeyword(material, "_NORMALMAP", material.GetTexture("_BumpMap") || material.GetTexture("_DetailNormalMap"));
            if (workflowMode == WorkflowMode.Specular)
            {
                SetKeyword(material, "_SPECGLOSSMAP", material.GetTexture("_SpecGlossMap"));
            }
            else if (workflowMode == WorkflowMode.Metallic)
            {
                SetKeyword(material, "_METALLICGLOSSMAP", material.GetTexture("_MetallicGlossMap"));
            }
            SetKeyword(material, "_PARALLAXMAP", material.GetTexture("_ParallaxMap"));
            SetKeyword(material, "_DETAIL_MULX2", material.GetTexture("_DetailAlbedoMap") || material.GetTexture("_DetailNormalMap"));

            // We're setting this so that if the shader Falls back to no tessellation, the parallax height would be right
            material.SetFloat("_Parallax", Mathf.Lerp(0.005f, 0.08f, material.GetFloat("_Displacement")));

            if (tessWorkflowMode == TessWorkflowMode.EdgeLength)
            {
                SetKeyword(material, "FT_EDGE_TESS", true);
            }
            else
            {
                SetKeyword(material, "FT_EDGE_TESS", false);
            }

            // A material's GI flag internally keeps track of whether emission is enabled at all, it's enabled but has no effect
            // or is enabled and may be modified at runtime. This state depends on the values of the current flag and emissive color.
            // The fixup routine makes sure that the material is in the correct state if/when changes are made to the mode or color.
            MaterialEditor.FixupEmissiveFlag(material);
            bool shouldEmissionBeEnabled = (material.globalIlluminationFlags & MaterialGlobalIlluminationFlags.EmissiveIsBlack) == 0;

            SetKeyword(material, "_EMISSION", shouldEmissionBeEnabled);

            if (material.HasProperty("_SmoothnessTextureChannel"))
            {
                SetKeyword(material, "_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A", GetSmoothnessMapChannel(material) == SmoothnessMapChannel.AlbedoAlpha);
            }
        }