Exemple #1
0
        protected override async Task LoadContent()
        {
            await base.LoadContent();


            dynamicEffectCompiler = new DynamicEffectCompiler(Services, "CustomEffect.CustomSubEffect");
            effectParameters      = new ParameterCollection();
            effectInstance        = new DefaultEffectInstance(effectParameters);
        }
        /// <inheritdoc/>
        protected override void InitializeCore()
        {
            base.InitializeCore();

            if (EffectName == null) throw new ArgumentNullException("No EffectName specified");

            parameterCollections = new List<ParameterCollection> { Context.Parameters };
            parameterCollections.AddRange(SharedParameterCollections);
            parameterCollections.Add(Parameters);
            appliedParameterCollections = new List<ParameterCollection>();

            // Setup the effect compiler
            EffectInstance = new DefaultEffectInstance(parameterCollections);
            effectCompiler = new DynamicEffectCompiler(Context.Services, EffectName, -1); // Image effects are compiled with higher priority

            SetDefaultParameters();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ImageEffectShader"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="effectName">Name of the shader.</param>
        public ImageEffectShader(ImageEffectContext context, string effectName)
            : base(context, effectName)
        {
            if (effectName == null)
            {
                throw new ArgumentNullException("effectName");
            }

            // Setup this instance parameters
            parameters = new ParameterCollection();
            // As this is used by PostEffectBase, we just setup it here by default
            parameters.Set(TexturingKeys.Sampler, GraphicsDevice.SamplerStates.LinearClamp);

            // Setup the effect compiler
            effectInstance = new InternalEffectInstance(parameters);
            effectCompiler = new DynamicEffectCompiler(context.Services, effectName);
        }
Exemple #4
0
        // TODO Part of the graphics improvement XK-3052
        //  Do not use the RenderContext

        /// <summary>
        /// Initializes the core of the material, such as the shader generator and the parameter collection
        /// </summary>
        /// <param name="context">The current <see cref="RenderContext"/></param>
        protected virtual void InitializeCore(RenderContext context)
        {
            if (EffectName == null)
            {
                throw new ArgumentNullException("No EffectName specified");
            }

            ParameterCollections = new List <ParameterCollection> {
                parameters
            };

            NewParameterCollections = new FastListStruct <ParameterCollection>(8);
            OldParameterCollections = new FastListStruct <ParameterCollection>(8);

            // Setup the effect compiler
            effectInstance = new DefaultEffectInstance(ParameterCollections);             // Remove this
            effectCompiler = new DynamicEffectCompiler(context.Services, EffectName, -1); // Image effects are compiled with higher priority
        }
        public ComputeEffectShader(RenderContext context, params ParameterCollection[] sharedParameterCollections)
            : base(context, null)
        {
            parameterCollections = new List<ParameterCollection> { context.Parameters };
            if (sharedParameterCollections != null)
            {
                parameterCollections.AddRange(sharedParameterCollections);
            }
            parameterCollections.Add(Parameters);

            appliedParameterCollections = new List<ParameterCollection>();

            // Setup the effect compiler
            EffectInstance = new DefaultEffectInstance(parameterCollections);
            effectCompiler = new DynamicEffectCompiler(context.Services, "ComputeEffectShader");

            ThreadNumbers = new Int3(1);
            ThreadGroupCounts = new Int3(1);

            SetDefaultParameters();
        }
Exemple #6
0
        /// <inheritdoc/>
        protected override void InitializeCore()
        {
            base.InitializeCore();

            if (EffectName == null)
            {
                throw new ArgumentNullException("No EffectName specified");
            }

            parameterCollections = new List <ParameterCollection> {
                Context.Parameters
            };
            parameterCollections.AddRange(SharedParameterCollections);
            parameterCollections.Add(Parameters);
            appliedParameterCollections = new List <ParameterCollection>();

            // Setup the effect compiler
            EffectInstance = new DefaultEffectInstance(parameterCollections);
            effectCompiler = new DynamicEffectCompiler(Context.Services, EffectName, -1); // Image effects are compiled with higher priority

            SetDefaultParameters();
        }
Exemple #7
0
        public ComputeEffectShader(RenderContext context, params ParameterCollection[] sharedParameterCollections)
            : base(context, null)
        {
            parameterCollections = new List <ParameterCollection> {
                context.Parameters
            };
            if (sharedParameterCollections != null)
            {
                parameterCollections.AddRange(sharedParameterCollections);
            }
            parameterCollections.Add(Parameters);

            appliedParameterCollections = new List <ParameterCollection>();

            // Setup the effect compiler
            EffectInstance = new DefaultEffectInstance(parameterCollections);
            effectCompiler = new DynamicEffectCompiler(context.Services, "ComputeEffectShader");

            ThreadNumbers     = new Int3(1);
            ThreadGroupCounts = new Int3(1);

            SetDefaultParameters();
        }
Exemple #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ImageEffectShader" /> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="effectName">Name of the shader.</param>
        /// <param name="sharedParameterCollections">The shared parameters.</param>
        /// <exception cref="System.ArgumentNullException">effectName</exception>
        public ImageEffectShader(ImageEffectContext context, string effectName, params ParameterCollection[] sharedParameterCollections)
            : base(context)
        {
            if (effectName == null)
            {
                throw new ArgumentNullException("effectName");
            }

            parameterCollections = new List <ParameterCollection> {
                context.Parameters
            };
            if (sharedParameterCollections != null)
            {
                parameterCollections.AddRange(sharedParameterCollections);
            }
            parameterCollections.Add(Parameters);

            // Setup the effect compiler
            effectInstance = new DefaultEffectInstance(parameterCollections);
            effectCompiler = new DynamicEffectCompiler(context.Services, effectName);

            SetDefaultParameters();
        }