Exemple #1
0
        // -------------------------------------------------- //
        //                   PRIVATE METHODS                  //
        // -------------------------------------------------- //

        // Convert a DecalDefinitionContext to serializable data
        private void ConvertContextToSerializableData(DecalDefinitionContext context)
        {
            // Common fields
            m_Shader = context.shader;

            // Serializable Decal properties
            if (context.properties != null)
            {
                m_SerializedProperties = new SerializableDecalProperty[context.properties.Count];
                for (int i = 0; i < m_SerializedProperties.Length; i++)
                {
                    m_SerializedProperties[i] = new SerializableDecalProperty()
                    {
                        displayName   = context.properties[i].displayName,
                        referenceName = context.properties[i].referenceName,
                    };
                    if (context.properties[i] as TextureDecalProperty != null)
                    {
                        TextureDecalProperty textureProp = context.properties[i] as TextureDecalProperty;
                        m_SerializedProperties[i].type         = PropertyType.Texture;
                        m_SerializedProperties[i].textureValue = textureProp.value;
                    }
                    else if (context.properties[i] as ColorDecalProperty != null)
                    {
                        ColorDecalProperty colorProp = context.properties[i] as ColorDecalProperty;
                        m_SerializedProperties[i].type       = PropertyType.Color;
                        m_SerializedProperties[i].colorValue = colorProp.value;
                    }
                    else if (context.properties[i] as FloatDecalProperty != null)
                    {
                        FloatDecalProperty floatProp = context.properties[i] as FloatDecalProperty;
                        m_SerializedProperties[i].type       = PropertyType.Float;
                        m_SerializedProperties[i].floatValue = floatProp.value;
                    }
                    else if (context.properties[i] as VectorDecalProperty != null)
                    {
                        VectorDecalProperty vectorProp = context.properties[i] as VectorDecalProperty;
                        m_SerializedProperties[i].type        = PropertyType.Vector;
                        m_SerializedProperties[i].vectorValue = vectorProp.value;
                    }
                    else if (context.properties[i] as KeywordDecalProperty != null)
                    {
                        KeywordDecalProperty keywordProp = context.properties[i] as KeywordDecalProperty;
                        m_SerializedProperties[i].type      = PropertyType.Keyword;
                        m_SerializedProperties[i].boolValue = keywordProp.value;
                    }
                    else
                    {
                        Debug.LogError("Not a valid Property type!");
                    }
                }
            }
        }
Exemple #2
0
        // -------------------------------------------------- //
        //                 ABSTRACT METHODS                   //
        // -------------------------------------------------- //

        /// <summary>
        /// Define the Decal.
        /// </summary>
        /// <param name="context">Context for setting DecalDefinition values.</param>
        public abstract void DefineDecal(out DecalDefinitionContext context);
        public override void DefineDecal(out DecalDefinitionContext context)
        {
            context = new DecalDefinitionContext()
            {
                shader = "Hidden/kDecals/Lit/PBR",
            };

            context.AddDecalProperty(new KeywordDecalProperty(
                                         "Specular Map",
                                         "_SPECGLOSSMAP",
                                         false
                                         ));

            context.AddDecalProperty(new KeywordDecalProperty(
                                         "Normal Map",
                                         "_NORMALMAP",
                                         false
                                         ));

            context.AddDecalProperty(new KeywordDecalProperty(
                                         "Emission",
                                         "_EMISSION",
                                         false
                                         ));

            context.AddDecalProperty(new KeywordDecalProperty(
                                         "Alpha Clip",
                                         "_ALPHATEST",
                                         false
                                         ));

            context.AddDecalProperty(new KeywordDecalProperty(
                                         "Fog",
                                         "_FOG",
                                         true
                                         ));

            context.AddDecalProperty(new TextureDecalProperty(
                                         "Albedo",
                                         "_AlbedoTex",
                                         null
                                         ));

            context.AddDecalProperty(new ColorDecalProperty(
                                         "Color",
                                         "_Color",
                                         Color.white
                                         ));

            context.AddDecalProperty(new TextureDecalProperty(
                                         "Normal",
                                         "_NormalTex",
                                         null
                                         ));

            context.AddDecalProperty(new FloatDecalProperty(
                                         "Normal Scale",
                                         "_NormalScale",
                                         1.0f
                                         ));

            context.AddDecalProperty(new TextureDecalProperty(
                                         "Specular Map",
                                         "_SpecularTex",
                                         null
                                         ));

            context.AddDecalProperty(new ColorDecalProperty(
                                         "Specular Color",
                                         "_Specular",
                                         Color.black
                                         ));

            context.AddDecalProperty(new FloatDecalProperty(
                                         "Smoothness",
                                         "_Smoothness",
                                         0.5f
                                         ));

            context.AddDecalProperty(new TextureDecalProperty(
                                         "Emission Map",
                                         "_EmissionTex",
                                         null
                                         ));

            context.AddDecalProperty(new ColorDecalProperty(
                                         "Emission Color",
                                         "_EmissionColor",
                                         Color.black
                                         ));

            context.AddDecalProperty(new FloatDecalProperty(
                                         "Clip Threshold",
                                         "_Threshold",
                                         0.5f
                                         ));
        }