public void Init(int passId, Matrix viewProjMatrix, MyViewport viewport, MyGBuffer gbuffer) { m_viewProjMatrix = viewProjMatrix; m_viewport = viewport; m_gbuffer = gbuffer; Init(passId, "GBuffer", MyFrustumEnum.MainFrustum, MyPassIdResolver.GetGBufferPassIdx(PassId)); }
internal static void Run(IRtvBindable dst, MyGBuffer gbuffer) { RC.ClearRtv(dst, new SharpDX.Color4(1, 1, 1, 1)); var paramsCB = MyCommon.GetObjectCB(16 * (2 + NUM_SAMPLES * 2)); var mapping = MyMapping.MapDiscard(paramsCB); mapping.WriteAndPosition(ref Params.Data); FillRandomVectors(mapping); mapping.Unmap(); if (!MyStereoRender.Enable) RC.AllShaderStages.SetConstantBuffer(MyCommon.FRAME_SLOT, MyCommon.FrameConstants); else MyStereoRender.BindRawCB_FrameConstants(RC); RC.AllShaderStages.SetConstantBuffer(1, paramsCB); RC.PixelShader.Set(m_ps); RC.SetRtv(dst); RC.PixelShader.SetSrvs(0, gbuffer); RC.PixelShader.SetSamplers(0, MySamplerStateManager.StandardSamplers); RC.PixelShader.SetSrv(5, gbuffer.ResolvedDepthStencil.SrvDepth); RC.SetDepthStencilState(MyDepthStencilStateManager.IgnoreDepthStencil); DrawFullscreenQuad(); RC.ResetTargets(); }
internal void SetSrvs(int startSlot, MyGBuffer gbuffer, MyGBufferSrvFilter mode = MyGBufferSrvFilter.ALL) { ISrvBindable srvStencil = null; if (mode == MyGBufferSrvFilter.ALL) { srvStencil = gbuffer.DepthStencil.SrvStencil; } SetSrvs(0, gbuffer.DepthStencil.SrvDepth, gbuffer.GBuffer0, gbuffer.GBuffer1, gbuffer.GBuffer2, srvStencil); }
void InitRenderPasses(MyCullQuery cullQuery, List <MyRenderPass> renderPasses) { renderPasses.Clear(); foreach (var query in cullQuery.RenderingPasses) { if (query == null) { continue; } Matrix matrix = query.ViewProjection; MyViewport viewport = query.Viewport; if (query is VRageRender.MyGBufferPass) { VRageRender.MyGBufferPass oldGBufferPass = (VRageRender.MyGBufferPass)query; MyGBuffer gbuffer = oldGBufferPass.GBuffer; MyGBufferPass gbufferPass; int passId = GetPassId(oldGBufferPass); m_gbufferPassesPool.AllocateOrCreate(out gbufferPass); gbufferPass.Init(passId, matrix, viewport, gbuffer); renderPasses.Add(gbufferPass); } if (query is VRageRender.MyDepthPass) { VRageRender.MyDepthPass oldDepthPass = (VRageRender.MyDepthPass)query; IDsvBindable dsv = oldDepthPass.Dsv; MyDepthPass depthPass; bool isCascade = oldDepthPass.IsCascade; int passId = GetPassId(oldDepthPass); m_depthPassesPool.AllocateOrCreate(out depthPass); depthPass.Init(passId, matrix, viewport, dsv, isCascade, oldDepthPass.DebugName); renderPasses.Add(depthPass); } } }
internal static void Run(IRtvTexture dst, MyGBuffer gbuffer, MyViewport? viewport = null) { CompilePS(); if (!viewport.HasValue) { viewport = new MyViewport(0, 0, MyRender11.m_resolution.X, MyRender11.m_resolution.Y); } var data = InitConstantBuffer(viewport.Value); var mapping = MyMapping.MapDiscard(m_dataCB); mapping.WriteAndPosition(ref data); mapping.Unmap(); RC.PixelShader.SetConstantBuffer(0, m_dataCB); RC.PixelShader.SetSamplers(0, MySamplerStateManager.PointHBAOClamp); RC.SetBlendState(null); RC.SetDepthStencilState(MyDepthStencilStateManager.IgnoreDepthStencil); DrawLinearDepthPS(gbuffer.ResolvedDepthStencil.SrvDepth, m_fullResViewDepthTarget, viewport.Value); DrawDeinterleavedDepth(viewport.Value); DrawCoarseAO(gbuffer, viewport.Value); if (Params.BlurEnable) { Resolve(true, m_fullResAOZTexture2, viewport.Value); DrawBlurXPS(viewport.Value); DrawBlurYPS(dst, viewport.Value); } else Resolve(false, dst, viewport.Value); RC.SetRtv(null); }
static void DrawCoarseAO(MyGBuffer gbuffer, MyViewport viewport) { var qViewport = GetQuarterViewport(viewport); RC.PixelShader.Set(m_coarseAOPS); RC.PixelShader.SetSamplers(0, Params.DepthClampToEdge ? MySamplerStateManager.PointHBAOClamp : MySamplerStateManager.PointHBAOBorder); RC.PixelShader.SetSamplers(1, MySamplerStateManager.PointHBAOClamp); RC.PixelShader.SetSrv(1, gbuffer.GBuffer1); for (int sliceIndex = 0; sliceIndex < NUM_SLICES; ++sliceIndex) { RC.PixelShader.SetSrv(0, m_quarterResViewDepthTextureArray.SubresourceSrv(sliceIndex)); RC.PixelShader.SetConstantBuffer(1, m_perPassCBs[sliceIndex]); RC.GeometryShader.SetConstantBuffer(1, m_perPassCBs[sliceIndex]); RC.SetRtv(m_quarterResAOTextureArray.SubresourceRtv(sliceIndex)); MyScreenPass.DrawFullscreenQuad(qViewport); } RC.GeometryShader.Set(null); }
internal override void Cleanup() { base.Cleanup(); GBuffer = null; }
internal void SetRtvs(MyGBuffer gbuffer, MyDepthStencilAccess access) { InternalSetRtvs(gbuffer.DepthStencil, access, gbuffer.GBuffer0, gbuffer.GBuffer1, gbuffer.GBuffer2); CheckErrors(); }
internal void AddMainViewPass(MyViewport viewport, MyGBuffer gbuffer) { int frustumMask = AddFrustum(ref MyRender11.Environment.Matrices.ViewProjectionD); FrustumCullQueries[Size - 1].Type = MyFrustumEnum.MainFrustum; var pass = MyObjectPoolManager.Allocate<MyGBufferPass>(); pass.DebugName = "GBuffer"; pass.ProcessingMask = frustumMask; pass.ViewProjection = MyRender11.Environment.Matrices.ViewProjectionAt0; pass.Viewport = viewport; pass.GBuffer = gbuffer; pass.PerFrame(); RenderingPasses[Size - 1] = pass; }