/// <inheritdoc/> public override void PrepareEffectPermutationsImpl(RenderDrawContext context) { base.PrepareEffectPermutationsImpl(context); var renderEffects = RenderData.GetData(renderEffectKey); int effectSlotCount = EffectPermutationSlotCount; // Update existing materials foreach (var material in allMaterialInfos) { material.Key.Setup(context.RenderContext); } for (int k = 0; k < RenderObjects.Count; k++) { var renderObject = RenderObjects[k]; var staticObjectNode = renderObject.StaticObjectNode; var renderParticleEmitter = (RenderParticleEmitter)renderObject; var material = renderParticleEmitter.ParticleEmitter.Material; var materialInfo = renderParticleEmitter.ParticleMaterialInfo; for (int i = 0; i < effectSlotCount; ++i) { var staticEffectObjectNode = staticObjectNode * effectSlotCount + i; var renderEffect = renderEffects[staticEffectObjectNode]; // Skip effects not used during this frame if (renderEffect == null || !renderEffect.IsUsedDuringThisFrame(RenderSystem)) { continue; } if (materialInfo == null || materialInfo.Material != material) { // First time this material is initialized, let's create associated info if (!allMaterialInfos.TryGetValue(material, out materialInfo)) { materialInfo = new ParticleMaterialInfo(material); allMaterialInfos.Add(material, materialInfo); } renderParticleEmitter.ParticleMaterialInfo = materialInfo; // Update new materials material.Setup(context.RenderContext); } // TODO: Iterate PermuatationParameters automatically? material.ValidateEffect(context.RenderContext, ref renderEffect.EffectValidator); } } }
/// <inheritdoc/> public override void PrepareEffectPermutationsImpl(RenderDrawContext context) { base.PrepareEffectPermutationsImpl(context); var renderEffects = RenderData.GetData(renderEffectKey); int effectSlotCount = EffectPermutationSlotCount; // Update existing materials foreach (var material in allMaterialInfos) { material.Key.Setup(RenderSystem.RenderContextOld); } foreach (var renderObject in RenderObjects) { var staticObjectNode = renderObject.StaticObjectNode; var renderParticleEmitter = (RenderParticleEmitter)renderObject; var material = renderParticleEmitter.ParticleEmitter.Material; var materialInfo = renderParticleEmitter.ParticleMaterialInfo; for (int i = 0; i < effectSlotCount; ++i) { var staticEffectObjectNode = staticObjectNode * effectSlotCount + i; var renderEffect = renderEffects[staticEffectObjectNode]; // Skip effects not used during this frame if (renderEffect == null || !renderEffect.IsUsedDuringThisFrame(RenderSystem)) continue; if (materialInfo == null || materialInfo.Material != material) { // First time this material is initialized, let's create associated info if (!allMaterialInfos.TryGetValue(material, out materialInfo)) { materialInfo = new ParticleMaterialInfo(material); allMaterialInfos.Add(material, materialInfo); } renderParticleEmitter.ParticleMaterialInfo = materialInfo; // Update new materials material.Setup(RenderSystem.RenderContextOld); } // TODO: Iterate PermuatationParameters automatically? material.ValidateEffect(RenderSystem.RenderContextOld, ref renderEffect.EffectValidator); } } }