/// <summary> /// Prepare the EffectParameterUpdater for the effect instance. /// </summary> /// <param name="effectInstance">The effect instance.</param> private void PrepareUpdater(DynamicEffectInstance effectInstance) { parameterCollections.Clear(true); parameterCollections.Add(effectInstance.Effect.CompilationParameters); effectInstance.FillParameterCollections(parameterCollections); parameterCollections.Add(GraphicsDevice.Parameters); updater.Update(effectInstance.UpdaterDefinition, parameterCollections.Items, parameterCollections.Count); }
private void CreateEffect(DynamicEffectInstance effectInstance) { var compilerParameters = new CompilerParameters(); parameterCollections.Clear(true); effectInstance.FillParameterCollections(parameterCollections); foreach (var parameterCollection in parameterCollections) { if (parameterCollection != null) { foreach (var parameter in parameterCollection.InternalValues) { compilerParameters.SetObject(parameter.Key, parameter.Value.Object); } } } foreach (var parameter in GraphicsDevice.Parameters.InternalValues) { compilerParameters.SetObject(parameter.Key, parameter.Value.Object); } // Compile shader // possible exception in LoadEffect var effect = EffectSystem.LoadEffect(EffectName, compilerParameters); if (!ReferenceEquals(effect, effectInstance.Effect)) { // Copy back parameters set on previous effect to new effect if (effectInstance.Effect != null) { foreach (var parameter in effectInstance.Effect.Parameters.InternalValues) { effect.Parameters.SetObject(parameter.Key, parameter.Value.Object); } } effectInstance.Effect = effect; effectInstance.UpdaterDefinition = new EffectParameterUpdaterDefinition(effect); } else { // Same effect than previous one effectInstance.UpdaterDefinition.UpdateCounter(effect.CompilationParameters); } UpdateLevels(effectInstance); updater.UpdateCounters(effectInstance.UpdaterDefinition); }