internal override void Cleanup() { base.Cleanup(); Dsv = null; Rtv = null; }
internal override void Cleanup() { base.Cleanup(); Dsv = null; DefaultRasterizer = null; }
internal override void Cleanup() { base.Cleanup(); Dsv = null; DefaultRasterizer = null; IsCascade = false; }
internal void SetRtv(IDsvBindable dsvBind, IRtvBindable rtv) { DepthStencilView dsv = null; if (dsvBind != null) { dsv = dsvBind.Dsv; } InternalSetRtvs(dsv, rtv); CheckErrors(); }
public void Init(int passId, Matrix viewProjMatrix, MyViewport viewport, IDsvBindable dsv, bool isCascade, string debugName) { m_viewProjMatrix = viewProjMatrix; m_viewport = viewport; m_dsv = dsv; m_isCascade = isCascade; if (isCascade) { Init(passId, debugName, MyFrustumEnum.ShadowCascade, MyPassIdResolver.GetCascadeDepthPassIdx(passId)); } else { Init(passId, debugName, MyFrustumEnum.ShadowProjection, MyPassIdResolver.GetSingleDepthPassIdx(passId)); } }
public MyShadowmapQuery GetShadowmapQueryForSingleShadow(int index, IDsvBindable dsvBindable) { MyProjectionInfo projInfo = new MyProjectionInfo(); projInfo.WorldCameraOffsetPosition = MyRender11.Environment.Matrices.CameraPosition; projInfo.WorldToProjection = MatrixWorldAt0ToShadowSpace; projInfo.LocalToProjection = Matrix.CreateTranslation(MyRender11.Environment.Matrices.CameraPosition) * MatrixWorldAt0ToShadowSpace; MyShadowmapQuery query = new MyShadowmapQuery(); query.DepthBuffer = dsvBindable; query.Viewport = new MyViewport(dsvBindable.Size.X, dsvBindable.Size.Y); query.ProjectionInfo = projInfo; query.ProjectionFactor = (float)Math.Sqrt(dsvBindable.Size.X * dsvBindable.Size.Y / (m_matrixShadowToWorldAt0Space.Left.Length() * m_matrixShadowToWorldAt0Space.Up.Length())); query.QueryType = MyFrustumEnum.ShadowProjection; query.Index = index; return query; }
public MyShadowmapQuery GetShadowmapQueryForSingleShadow(int index, IDsvBindable dsvBindable) { MyProjectionInfo projInfo = new MyProjectionInfo(); projInfo.WorldCameraOffsetPosition = MyRender11.Environment.Matrices.CameraPosition; projInfo.WorldToProjection = MatrixWorldAt0ToShadowSpace; projInfo.LocalToProjection = Matrix.CreateTranslation(MyRender11.Environment.Matrices.CameraPosition) * MatrixWorldAt0ToShadowSpace; MyShadowmapQuery query = new MyShadowmapQuery(); query.DepthBuffer = dsvBindable; query.Viewport = new MyViewport(dsvBindable.Size.X, dsvBindable.Size.Y); query.ProjectionInfo = projInfo; query.ProjectionFactor = (float)Math.Sqrt(dsvBindable.Size.X * dsvBindable.Size.Y / (m_matrixShadowToWorldAt0Space.Left.Length() * m_matrixShadowToWorldAt0Space.Up.Length())); query.QueryType = MyFrustumEnum.ShadowProjection; query.Index = index; return(query); }
internal static unsafe void RunForwardPostprocess(IRtvBindable rt, IDsvBindable depthDsv, ISrvBindable depthSrv, ref Matrix viewMatrix, ref Matrix projMatrix) { MyGpuProfiler.IC_BeginBlock("Postprocess"); var viewMatrixT = Matrix.Transpose(viewMatrix); var projMatrixT = Matrix.Transpose(projMatrix); var mapping = MyMapping.MapDiscard(RC, TransformConstants); mapping.WriteAndPosition(ref viewMatrixT); mapping.WriteAndPosition(ref projMatrixT); mapping.WriteAndPosition(ref MyRender11.Environment.Data.EnvironmentLight.SunLightDirection); mapping.Unmap(); RC.AllShaderStages.SetConstantBuffer(MyCommon.FRAME_SLOT, MyCommon.FrameConstants); RC.AllShaderStages.SetConstantBuffer(MyCommon.OBJECT_SLOT, TransformConstants); RC.SetDepthStencilState(MyDepthStencilStateManager.IgnoreDepthStencil); RC.SetRtv(rt); RC.PixelShader.SetSrv(0, depthSrv); MyFileTextureManager texManager = MyManagers.FileTextures; RC.PixelShader.SetSrv(MyCommon.SKYBOX_SLOT, texManager.GetTexture(MyRender11.Environment.Data.Skybox, MyFileTextureEnum.CUBEMAP, true)); RC.PixelShader.SetSamplers(0, MySamplerStateManager.StandardSamplers); RC.PixelShader.Set(m_ps); MyScreenPass.DrawFullscreenQuad(new MyViewport(m_viewportSize, m_viewportSize)); MyGpuProfiler.IC_EndBlock(); var nearestAtmosphereId = MyAtmosphereRenderer.GetNearestAtmosphereId(); if (nearestAtmosphereId != null) { MyGpuProfiler.IC_BeginBlock("Atmosphere"); RC.PixelShader.SetSrv(0, depthSrv); var viewProj = viewMatrix * projMatrix; MyAtmosphereRenderer.RenderEnvProbe(MyRender11.Environment.Matrices.CameraPosition, ref viewProj, nearestAtmosphereId.Value); MyGpuProfiler.IC_EndBlock(); } RC.SetRtv(null); }
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 void ClearDsv(IDsvBindable dsv, DepthStencilClearFlags clearFlags, float depth, byte stencil) { m_deviceContext.ClearDepthStencilView(dsv.Dsv, clearFlags, depth, stencil); CheckErrors(); }
internal void AddForwardPass(int index, ref Matrix offsetedViewProjection, ref MatrixD viewProjection, MyViewport viewport, IDsvBindable dsv, IRtvBindable rtv) { int frustumMask = AddFrustum(ref viewProjection); MyForwardPass pass = MyObjectPoolManager.Allocate <MyForwardPass>(); pass.DebugName = "EnvironmentProbe"; pass.ProcessingMask = frustumMask; pass.ViewProjection = offsetedViewProjection; pass.Viewport = viewport; pass.FrustumIndex = index; pass.Dsv = dsv; pass.Rtv = rtv; pass.PerFrame(); RenderingPasses[Size - 1] = pass; }
public MyShadowmapQuery GetShadowmapQuery(IDsvBindable dsv, int slice) { return(m_shadowVolume.GetShadowmapQueryForCsm(dsv, slice)); }
internal void AddForwardPass(int index, ref Matrix offsetedViewProjection, ref MatrixD viewProjection, MyViewport viewport, IDsvBindable dsv, IRtvBindable rtv) { int frustumMask = AddFrustum(ref viewProjection); MyForwardPass pass = MyObjectPoolManager.Allocate<MyForwardPass>(); pass.DebugName = "EnvironmentProbe"; pass.ProcessingMask = frustumMask; pass.ViewProjection = offsetedViewProjection; pass.Viewport = viewport; pass.FrustumIndex = index; pass.Dsv = dsv; pass.Rtv = rtv; pass.PerFrame(); RenderingPasses[Size - 1] = pass; }
public MyShadowmapQuery GetShadowmapQuery(IDsvBindable dsv, int slice) { return m_shadowVolume.GetShadowmapQueryForCsm(dsv, slice); }
internal void AddDepthPass(ref MatrixD worldToProjection, Matrix viewProjectionLocal, MyViewport viewport, IDsvBindable depthTarget, bool isCascade, string debugName) { int frustumMask = AddFrustum(ref worldToProjection); MyDepthPass pass = MyObjectPoolManager.Allocate <MyDepthPass>(); pass.DebugName = debugName; pass.ProcessingMask = frustumMask; pass.ViewProjection = viewProjectionLocal; pass.Viewport = viewport; pass.Dsv = depthTarget; pass.DefaultRasterizer = isCascade ? MyRasterizerStateManager.CascadesRasterizerStateOld : MyRasterizerStateManager.ShadowRasterizerState; pass.PerFrame(); RenderingPasses[Size - 1] = pass; }