AcTools.Render.DeferredShading.DeferredShadingRenderer.DrawLights C# (CSharp) Метод

DrawLights() приватный Метод

private DrawLights ( TargetResourceTexture target, DepthStencilView limitedBy = null ) : void
target AcTools.Render.Base.TargetTextures.TargetResourceTexture
limitedBy DepthStencilView
Результат void
        private void DrawLights(TargetResourceTexture target, DepthStencilView limitedBy = null) {
            // set blending & prepare quad
            DeviceContext.OutputMerger.BlendState = DeviceContextHolder.AddBlendState;

            // proper render target
            if (limitedBy == null) {
                DeviceContext.OutputMerger.SetTargets(target.TargetView);
                DeviceContext.OutputMerger.DepthStencilState = null;
            } else {
                DeviceContext.OutputMerger.SetTargets(limitedBy, target.TargetView);
                DeviceContext.OutputMerger.DepthStencilState = DeviceContextHolder.GreaterReadOnlyDepthState;
            }

            DeviceContext.ClearRenderTargetView(target.TargetView, ColorTransparent);

            // camera position & matrix
            _deferredLighting.FxWorldViewProjInv.SetMatrix(Camera.ViewProjInvert);
            _deferredLighting.FxEyePosW.Set(Camera.Position);
            _deferredLighting.FxScreenSize.Set(new Vector4(Width, Height, 1f / Width, 1f / Height));

            // g-buffer
            _deferredLighting.FxBaseMap.SetResource(_gBufferBase.View);
            _deferredLighting.FxNormalMap.SetResource(_gBufferNormal.View);
            _deferredLighting.FxMapsMap.SetResource(_gBufferMaps.View);
            _deferredLighting.FxDepthMap.SetResource(_gDepthBuffer.View);

            // lights!
            if (UseShadows) {
                _deferredLighting.FxShadowMaps.SetResourceArray(_sunShadows.Splits.Take(EffectDeferredLight.NumSplits).Select(x => x.View).ToArray());
                _deferredLighting.FxShadowViewProj.SetMatrixArray(
                        _sunShadows.Splits.Take(EffectDeferredLight.NumSplits).Select(x => x.ShadowTransform).ToArray());
            } else {
                _deferredLighting.FxShadowMaps.SetResource(null);
            }

            Sun?.Draw(DeviceContextHolder, Camera,
                    UseDebugShadows ? SpecialLightMode.Debug : !UseShadows ? SpecialLightMode.Default :
                            UseShadowsFilter ? SpecialLightMode.Shadows : SpecialLightMode.ShadowsWithoutFilter);
            if (!LimitLightsThroughGlass || limitedBy == null) {
                foreach (var light in Lights) {
                    light.Draw(DeviceContextHolder, Camera, SpecialLightMode.Default);
                }
            }

            if (limitedBy != null) {
                DeviceContext.OutputMerger.DepthStencilState = null;
            }
        }