public IAsset Handle(IAssetManager assetManager, string name, IRawAsset data) { if (data is CompiledAsset) { return new UberEffectAsset(_kernel, _assetContentManager, _rawLaunchArguments, name, null, data.GetProperty<PlatformData>("PlatformData"), false); } PlatformData platformData = null; if (data.GetProperty<PlatformData>("PlatformData") != null) { platformData = new PlatformData { Platform = data.GetProperty<PlatformData>("PlatformData").Platform, Data = data.GetProperty<PlatformData>("PlatformData").Data }; } var effect = new UberEffectAsset( _kernel, _assetContentManager, _rawLaunchArguments, name, data.GetProperty<string>("Code"), platformData, data.GetProperty<bool>("SourcedFromRaw")); return effect; }
public void Render(ComponentizedEntity entity, IGameContext gameContext, IRenderContext renderContext) { if (!Enabled) { return; } if (renderContext.IsCurrentRenderPass<I3DRenderPass>()) { if (Effect == null) { _useDefaultEffects = true; } else { _useDefaultEffects = false; } if (_useDefaultEffects && _uberEffectAsset == null) { _uberEffectAsset = _assetManager.Get<UberEffectAsset>("effect.BuiltinSurface"); } if (Model != null) { var matrix = FinalTransform.AbsoluteMatrix; bool changedRenderRequest = _lastWorldMatrix != matrix; string changedRenderRequestBy = changedRenderRequest ? "matrix" : ""; var material = OverrideMaterial ?? _model.Material; UpdateCachedModel(material, ref changedRenderRequest, ref changedRenderRequestBy); var effect = GetEffect(ref changedRenderRequest, ref changedRenderRequestBy); var parameterSet = GetEffectParameterSet(material, ref changedRenderRequest, ref changedRenderRequestBy); var animation = GetModelAnimation(ref changedRenderRequest, ref changedRenderRequestBy); if (animation != null) { animation.Apply(_model, _animationTracker.ElapsedMilliseconds / 1000f, 0.5f); _renderRequest = _model.CreateRenderRequest(renderContext, effect, parameterSet, matrix); } else if (changedRenderRequest || _renderRequest == null) { _renderRequest = _model.CreateRenderRequest(renderContext, effect, parameterSet, matrix); } _lastWorldMatrix = matrix; _renderBatcher.QueueRequest( renderContext, _renderRequest); } else { _lastCachedModel = null; _lastCachedDiffuseTexture = null; } } }