/// <inheritdoc/> protected override void OnUpdate(RenderContext context) { if (context == null) { return; } var lightNode = SceneEffectBinder.GetLightNode <DirectionalLight>(this, context); if (_standardShadowParameters != null) { _standardShadowParameters.StandardShadow = lightNode.Shadow as StandardShadow; } else if (_cascadedShadowParameters != null) { _cascadedShadowParameters.CascadedShadow = lightNode.Shadow as CascadedShadow; } }
protected override void OnUpdate(RenderContext context) { var stockEffectBinding = context.MaterialBinding as IStockEffectBinding; if (stockEffectBinding == null) { throw new EffectBindingException("XNA stock effect binding not found in render context."); } // Fallback values. Value = new Vector4(0, 0, 0, 0); stockEffectBinding.FogEnabled = false; if (context.CameraNode == null) { return; } var nodes = SceneEffectBinder.QueryFogNodes(context); if (nodes == null) { return; } var node = nodes[0]; var fog = node.Fog; if (Numeric.IsZero(fog.Density) || Numeric.IsZero(fog.Color0.W)) { return; } Matrix worldView = SceneEffectBinder.GetWorldView(null, context); float fogStart = fog.Start; float fogEnd = fog.End; // This how XNA uses its fog vector. float x = 1f / (fogStart - fogEnd); Value = new Vector4(worldView.M13 * x, worldView.M23 * x, worldView.M33 * x, (worldView.M43 + fogStart) * x); stockEffectBinding.FogEnabled = true; }