Esempio n. 1
0
        /// <summary>
        /// Creates a new instance of the <see cref="EffectBinding"/> class for a material instance.
        /// </summary>
        internal EffectBinding CreateMaterialInstance()
        {
            Debug.Assert(Hints == EffectParameterHint.Material, "EffectBinding for material expected.");

            // Note: The EffectBinding used in a Material can be a special binding, such as
            // BasicEffectBinding. The EffectBinding used in the MaterialInstance is not a
            // clone of the BasicEffectBinding, instead it is a normal EffectBinding.

            // A material instance may contain all parameters, except global and material settings.
            const EffectParameterHint hints = EffectParameterHint.Local
                                              | EffectParameterHint.PerInstance
                                              | EffectParameterHint.PerPass;

            var effectBinding = new EffectBinding
            {
                EffectEx          = EffectEx,
                MaterialBinding   = this,
                TechniqueBinding  = TechniqueBinding.Clone(),
                ParameterBindings = new EffectParameterBindingCollection(hints),
                OpaqueData        = OpaqueData,
            };

            // Copy all local, per-instance and per-pass bindings.
            foreach (var binding in EffectEx.ParameterBindings)
            {
                if ((binding.Description.Hint & hints) != 0)
                {
                    effectBinding.ParameterBindings.Add(binding.Clone());
                }
            }

            return(effectBinding);
        }
        /// <inheritdoc/>
        protected override void CloneCore(EffectBinding source)
        {
            // Clone EffectBinding properties.
            base.CloneCore(source);

            // Clone DualTextureEffectBinding properties.
            var sourceTyped = (DualTextureEffectBinding)source;

            VertexColorEnabled = sourceTyped.VertexColorEnabled;
        }
Esempio n. 3
0
        /// <inheritdoc/>
        protected override void CloneCore(EffectBinding source)
        {
            // Clone EffectBinding properties.
            base.CloneCore(source);

            // Clone SkinnedEffectBinding properties.
            var sourceTyped = (SkinnedEffectBinding)source;

            PreferPerPixelLighting = sourceTyped.PreferPerPixelLighting;
            WeightsPerVertex       = sourceTyped.WeightsPerVertex;
        }
Esempio n. 4
0
        /// <inheritdoc/>
        protected override void CloneCore(EffectBinding source)
        {
            // Clone EffectBinding properties.
            base.CloneCore(source);

            // Clone AlphaTestEffectBinding properties.
            var sourceTyped = (AlphaTestEffectBinding)source;

            AlphaFunction      = sourceTyped.AlphaFunction;
            ReferenceAlpha     = sourceTyped.ReferenceAlpha;
            VertexColorEnabled = sourceTyped.VertexColorEnabled;
        }
Esempio n. 5
0
        /// <inheritdoc/>
        protected override void CloneCore(EffectBinding source)
        {
            // Clone EffectBinding properties.
            base.CloneCore(source);

            // Clone BasicEffectBinding properties.
            var sourceTyped = (BasicEffectBinding)source;

            LightingEnabled        = sourceTyped.LightingEnabled;
            PreferPerPixelLighting = sourceTyped.PreferPerPixelLighting;
            TextureEnabled         = sourceTyped.TextureEnabled;
            VertexColorEnabled     = sourceTyped.VertexColorEnabled;
        }
        protected virtual void CloneCore(EffectBinding source)
        {
            EffectEx        = source.EffectEx;
            MaterialBinding = source.MaterialBinding;
            // Note: MorphWeights need to be set by MeshNode.
            TechniqueBinding = source.TechniqueBinding.Clone();
            OpaqueData       = source.OpaqueData;
            UserData         = source.UserData;

            // Clone parameter bindings (deep copy).
            ParameterBindings = new EffectParameterBindingCollection(source.Hints);
            foreach (var binding in source.ParameterBindings)
            {
                ParameterBindings.Add(binding.Clone());
            }
        }