protected override void InitializeCore() { base.InitializeCore(); // Create a slot manager var sceneInstance = SceneInstance.GetCurrent(Context); if (sceneInstance == null) { // If we don't have a scene instance (unlikely, but possible) slotManager = new RenderModelEffectSlotManager(); } else { // If we have a scene instance, we can store our state there, as we expect to share render models slotManager = sceneInstance.Tags.Get(RenderModelManagerKey); if (slotManager == null) { slotManager = new RenderModelEffectSlotManager(); sceneInstance.Tags.Set(RenderModelManagerKey, slotManager); } } if (dynamicEffectCompiler == null) { dynamicEffectCompiler = new DynamicEffectCompiler(Services, effectName); // Allocate (or reuse) a slot for the pass of this processor // Note: The slot is passed as out, so that when ModelRendererState.ModelSlotAdded callback is fired, // ModelRenderer.modelRenderSlot is valid (it might call PrepareRenderMeshes recursively). modelRenderSlot = slotManager.AllocateSlot(EffectName); } }
protected override async Task LoadContent() { await base.LoadContent(); dynamicEffectCompiler = new DynamicEffectCompiler(Services, "CustomEffect.CustomSubEffect"); effectParameters = new ParameterCollection(); effectInstance = new DefaultEffectInstance(effectParameters); }