Beispiel #1
0
        ///// <summary>
        ///// Gets or sets the scale v.
        ///// </summary>
        ///// <value>The scale v.</value>
        //[DefaultValue(1.0f)]
        //[DataMember(90)]
        //public float ScaleV { get; set; }

        /// <summary>
        /// Implements the multiply operator in order to support correct calculation of overrides for a particular layer.
        /// </summary>
        /// <param name="left">The left.</param>
        /// <param name="right">The right.</param>
        /// <returns>The result of the operator.</returns>
        public static MaterialOverrides operator *(MaterialOverrides left, MaterialOverrides right)
        {
            var overrides = new MaterialOverrides {
                UVScale = left.UVScale * right.UVScale
            };

            return(overrides);
        }
Beispiel #2
0
 public void PushOverrides(MaterialOverrides overrides)
 {
     if (overrides == null)
     {
         throw new ArgumentNullException("overrides");
     }
     overridesStack.Push(overrides);
     UpdateOverrides();
 }
Beispiel #3
0
 private void UpdateOverrides()
 {
     // Update overrides by squashing them using multiplication
     currentOverrides = new MaterialOverrides();
     foreach (var current in overridesStack)
     {
         currentOverrides *= current;
     }
 }
        public MaterialGeneratorContext(Material material = null)
        {
            this.material = material ?? new Material();
            Parameters    = this.material.Parameters;

            currentOverrides = new MaterialOverrides();

            foreach (MaterialShaderStage stage in Enum.GetValues(typeof(MaterialShaderStage)))
            {
                finalCallbacks[stage] = new List <MaterialGeneratorCallback>();
            }
        }
Beispiel #5
0
        public MaterialGeneratorContext(Material material = null)
        {
            this.material = material ?? new Material();
            Parameters    = this.material.Parameters;

            currentOverrides = new MaterialOverrides();

            foreach (MaterialShaderStage stage in Enum.GetValues(typeof(MaterialShaderStage)))
            {
                finalCallbacks[stage] = new List <MaterialGeneratorCallback>();
            }

            // By default return the asset
            FindAsset            = asset => ((Material)asset).Descriptor;
            GetAssetFriendlyName = asset => ((Material)asset).Descriptor != null ? ((Material)asset).Descriptor.MaterialId.ToString() : string.Empty;
        }
        public void Visit(MaterialGeneratorContext context)
        {
            // Exclude ambient occlusion from uv-scale overrides
            var revertOverrides = new MaterialOverrides();

            revertOverrides.UVScale = 1.0f / context.CurrentOverrides.UVScale;

            context.PushOverrides(revertOverrides);
            context.SetStream(OcclusionStream.Stream, AmbientOcclusionMap, MaterialKeys.AmbientOcclusionMap, MaterialKeys.AmbientOcclusionValue, Color.White);
            context.PopOverrides();

            context.SetStream("matAmbientOcclusionDirectLightingFactor", DirectLightingFactor, null, MaterialKeys.AmbientOcclusionDirectLightingFactorValue);

            if (CavityMap != null)
            {
                context.SetStream(CavityStream.Stream, CavityMap, MaterialKeys.CavityMap, MaterialKeys.CavityValue, Color.White);
                context.SetStream("matCavityDiffuse", DiffuseCavity, null, MaterialKeys.CavityDiffuseValue);
                context.SetStream("matCavitySpecular", SpecularCavity, null, MaterialKeys.CavitySpecularValue);
            }
        }
        public void Visit(MaterialGeneratorContext context)
        {
            // Exclude ambient occlusion from uv-scale overrides
            var revertOverrides = new MaterialOverrides();
            revertOverrides.UVScale = 1.0f / context.CurrentOverrides.UVScale;

            context.PushOverrides(revertOverrides);
            context.SetStream(OcclusionStream.Stream, AmbientOcclusionMap, MaterialKeys.AmbientOcclusionMap, MaterialKeys.AmbientOcclusionValue, Color.White);
            context.PopOverrides();

            context.SetStream("matAmbientOcclusionDirectLightingFactor", DirectLightingFactor, null, MaterialKeys.AmbientOcclusionDirectLightingFactorValue);

            if (CavityMap != null)
            {
                context.SetStream(CavityStream.Stream, CavityMap, MaterialKeys.CavityMap, MaterialKeys.CavityValue, Color.White);
                context.SetStream("matCavityDiffuse", DiffuseCavity, null, MaterialKeys.CavityDiffuseValue);
                context.SetStream("matCavitySpecular", SpecularCavity, null, MaterialKeys.CavitySpecularValue);
            }
        }
Beispiel #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MaterialAttributes"/> class.
 /// </summary>
 public MaterialAttributes()
 {
     Overrides = new MaterialOverrides();
 }
        ///// <summary>
        ///// Gets or sets the scale v.
        ///// </summary>
        ///// <value>The scale v.</value>
        //[DefaultValue(1.0f)]
        //[DataMember(90)]
        //public float ScaleV { get; set; }

        /// <summary>
        /// Implements the multiply operator in order to support correct calculation of overrides for a particular layer.
        /// </summary>
        /// <param name="left">The left.</param>
        /// <param name="right">The right.</param>
        /// <returns>The result of the operator.</returns>
        public static MaterialOverrides operator *(MaterialOverrides left, MaterialOverrides right)
        {
            var overrides = new MaterialOverrides { UVScale = left.UVScale * right.UVScale };
            return overrides;
        }
Beispiel #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MaterialAttributes"/> class.
 /// </summary>
 public MaterialAttributes()
 {
     CullMode  = CullMode.Back;
     Overrides = new MaterialOverrides();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MaterialBlendLayer"/> class.
 /// </summary>
 public MaterialBlendLayer()
 {
     Enabled = true;
     BlendMap = new ComputeTextureScalar();
     Overrides = new MaterialOverrides();
 }
Beispiel #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MaterialBlendLayer"/> class.
 /// </summary>
 public MaterialBlendLayer()
 {
     Enabled   = true;
     BlendMap  = new ComputeTextureScalar();
     Overrides = new MaterialOverrides();
 }
Beispiel #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MaterialAttributes"/> class.
 /// </summary>
 public MaterialAttributes()
 {
     CullMode = CullMode.Back;
     Overrides = new MaterialOverrides();
 }
Beispiel #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MaterialAttributes"/> class.
 /// </summary>
 public MaterialAttributes()
 {
     Overrides = new MaterialOverrides();
 }