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;
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        protected virtual void UpdateShadows(ShadowsDirectional shadows, Vector3 center)
        {
            _previousShadowsTarget = center;

            if (!EnableShadows)
            {
                shadows.Clear(DeviceContextHolder);
            }
            else
            {
                shadows.Update(-Light, center);
                shadows.DrawScene(DeviceContextHolder, this);
            }
        }