protected override void DrawPrepare() { base.DrawPrepare(); if (Sun != null && UseShadows) { _sunShadows.Update(Sun.Direction, Camera); _sunShadows.DrawScene(DeviceContextHolder, this); } if (UseCubemapReflections) { _reflectionCubemap.Update(ReflectionCubemapPosition); _reflectionCubemap.DrawScene(DeviceContextHolder, this); } DeviceContext.OutputMerger.SetTargets(_gDepthBuffer.DepthView, _gBufferBase.TargetView, _gBufferNormal.TargetView, _gBufferMaps.TargetView); DeviceContext.ClearDepthStencilView(_gDepthBuffer.DepthView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, 1f, 0); DeviceContext.ClearRenderTargetView(_gBufferBase.TargetView, ColorTransparent); DeviceContext.ClearRenderTargetView(_gBufferNormal.TargetView, ColorTransparent); DeviceContext.ClearRenderTargetView(_gBufferMaps.TargetView, ColorTransparent); DeviceContext.OutputMerger.BlendState = null; }
protected override void DrawPrepare() { base.DrawPrepare(); var effect = DeviceContextHolder.GetEffect <EffectDarkMaterial>(); var center = ReflectionCubemapPosition; if (EffectDarkMaterial.EnableShadows && _previousShadowsTarget != center) { _previousShadowsTarget = center; _shadows.Update(-_light, center); _shadows.DrawScene(DeviceContextHolder, this); effect.FxShadowMaps.SetResourceArray(_shadows.Splits.Take(EffectDarkMaterial.NumSplits).Select(x => x.View).ToArray()); effect.FxShadowViewProj.SetMatrixArray( _shadows.Splits.Take(EffectDarkMaterial.NumSplits).Select(x => x.ShadowTransform).ToArray()); } if (CubemapReflection && _reflectionCubemap.Update(center)) { _reflectionCubemap.DrawScene(DeviceContextHolder, this); effect.FxReflectionCubemap.SetResource(_reflectionCubemap.View); } effect.FxEyePosW.Set(ActualCamera.Position); effect.FxLightDir.Set(_light); }
protected void DrawPrepare(Vector3 eyesPosition, Vector3 light) { var sceneDirty = _sceneDirty; _sceneDirty = false; if (sceneDirty) { if (!DelayedBoundingBoxUpdate) { Scene.UpdateBoundingBox(); } _sceneWasDirty = true; } else { if (_sceneWasDirty && DelayedBoundingBoxUpdate) { Scene.UpdateBoundingBox(); } _sceneWasDirty = false; } var shadowsPosition = ShadowsPosition; if (_shadows != null && (_previousShadowsTarget != shadowsPosition || sceneDirty || _shadowsEnabled != EnableShadows)) { UpdateShadows(_shadows, shadowsPosition); _shadowsEnabled = EnableShadows; } var reflectionPosition = ReflectionCubemapPosition; if (_reflectionCubemap != null && (_reflectionCubemap.Update(reflectionPosition) || _reflectionCubemapDirty)) { _reflectionCubemap.BackgroundColor = (Color4)BackgroundColor * BackgroundBrightness; _reflectionCubemap.DrawScene(DeviceContextHolder, this); _reflectionCubemapDirty = false; } DrawPrepareEffect(eyesPosition, light, _shadows, _reflectionCubemap); }