private void DrawReflections(TargetResourceTexture target, TargetResourceTexture temporary = null, TargetResourceTexture light = null, DepthStencilView limitedBy = null) {
var sslr = DeviceContextHolder.GetHelper<SslrHelper>();
DeviceContextHolder.QuadBuffers.Prepare(DeviceContext, sslr.Effect.LayoutPT);
DeviceContext.OutputMerger.BlendState = null;
if (limitedBy == null) DeviceContext.OutputMerger.SetTargets(target.TargetView);
else {
DeviceContext.OutputMerger.SetTargets(limitedBy, target.TargetView);
DeviceContext.OutputMerger.DepthStencilState = DeviceContextHolder.GreaterReadOnlyDepthState;
}
// camera position & matrix
sslr.Effect.FxWorldViewProj.SetMatrix(Camera.ViewProj);
sslr.Effect.FxWorldViewProjInv.SetMatrix(Camera.ViewProjInvert);
sslr.Effect.FxEyePosW.Set(Camera.Position);
// g-buffer
sslr.Effect.FxBaseMap.SetResource(_gBufferBase.View);
sslr.Effect.FxNormalMap.SetResource(_gBufferNormal.View);
sslr.Effect.FxDepthMap.SetResource(_gDepthBuffer.View);
sslr.Effect.FxLightMap.SetResource(light?.View);
sslr.Effect.TechHabrahabrVersion.DrawAllPasses(DeviceContext, 6);
if (temporary != null) {
DeviceContext.OutputMerger.SetTargets(temporary.TargetView);
DeviceContextHolder.GetHelper<BlurHelper>().BlurReflectionVertically(DeviceContextHolder, target.View, _gBufferMaps.View);
DeviceContext.OutputMerger.SetTargets(target.TargetView);
DeviceContextHolder.GetHelper<BlurHelper>().BlurReflectionHorizontally(DeviceContextHolder, temporary.View, _gBufferMaps.View);
}
if (limitedBy != null) {
DeviceContext.OutputMerger.DepthStencilState = null;
}
}