Beispiel #1
0
 public ShaderGeneratorContext(GraphicsDevice graphicsDevice = null)
 {
     this.graphicsDevice   = graphicsDevice;
     Parameters            = new ParameterCollection();
     parameterKeyIndices   = new Dictionary <ParameterKey, int>();
     declaredSamplerStates = new Dictionary <SamplerStateDescription, ObjectParameterKey <SamplerState> >();
     currentOverrides      = new MaterialOverrides();
 }
Beispiel #2
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 #3
0
 private void UpdateOverrides()
 {
     // Update overrides by squashing them using multiplication
     currentOverrides = new MaterialOverrides();
     foreach (var current in overridesStack)
     {
         currentOverrides *= current;
     }
 }
Beispiel #4
0
 public void PushOverrides(MaterialOverrides overrides)
 {
     if (overrides == null)
     {
         throw new ArgumentNullException("overrides");
     }
     overridesStack.Push(overrides);
     UpdateOverrides();
 }
        public override void GenerateShader(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 #6
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();
 }