internal static void DrawIndexedBillboards(MyRenderContext RC, int indexCount, int startIndexLocation, int baseVertexLocation) { MyStereoRender.SetViewport(RC, MyStereoRegion.LEFT); RC.SetCB(MyCommon.FRAME_SLOT, MyCommon.FrameConstantsStereoLeftEye); RC.DeviceContext.DrawIndexed(indexCount, startIndexLocation, baseVertexLocation); MyStereoRender.SetViewport(RC, MyStereoRegion.RIGHT); RC.SetCB(MyCommon.FRAME_SLOT, MyCommon.FrameConstantsStereoRightEye); RC.DeviceContext.DrawIndexed(indexCount, startIndexLocation, baseVertexLocation); MyStereoRender.SetViewport(RC, MyStereoRegion.FULLSCREEN); RC.SetCB(MyCommon.FRAME_SLOT, MyCommon.FrameConstants); }
internal static void DrawIndexedInstancedIndirectGPUParticles(MyRenderContext RC, Buffer bufferForArgsRef, int alignedByteOffsetForArgs) { RC.SetCB(MyCommon.FRAME_SLOT, MyCommon.FrameConstantsStereoLeftEye); SetViewport(RC, MyStereoRegion.LEFT); RC.DeviceContext.DrawIndexedInstancedIndirect(bufferForArgsRef, alignedByteOffsetForArgs); RC.SetCB(MyCommon.FRAME_SLOT, MyCommon.FrameConstantsStereoRightEye); SetViewport(RC, MyStereoRegion.RIGHT); RC.DeviceContext.DrawIndexedInstancedIndirect(bufferForArgsRef, alignedByteOffsetForArgs); RC.SetCB(MyCommon.FRAME_SLOT, MyCommon.FrameConstants); SetViewport(RC, MyStereoRegion.FULLSCREEN); }
private static void SwitchDrawGBufferPass(MyRenderContext RC) { SetViewport(RC, MyStereoRegion.RIGHT); var viewProjTranspose = Matrix.Transpose(EnvMatricesRightEye.ViewProjectionAt0); var mapping = MyMapping.MapDiscard(RC.DeviceContext, MyCommon.ProjectionConstants); mapping.WriteAndPosition(ref viewProjTranspose); mapping.Unmap(); RC.SetCB(MyCommon.PROJECTION_SLOT, MyCommon.ProjectionConstants); //RC.SetCB(MyCommon.FRAME_SLOT, MyCommon.VRFrameConstantsRightEye); }
private static void EndDrawGBufferPass(MyRenderContext RC) { SetViewport(RC, MyStereoRegion.FULLSCREEN); var viewProjTranspose = Matrix.Transpose(MyRender11.Environment.ViewProjectionAt0); var mapping = MyMapping.MapDiscard(RC.DeviceContext, MyCommon.ProjectionConstants); mapping.WriteAndPosition(ref viewProjTranspose); mapping.Unmap(); RC.SetCB(MyCommon.PROJECTION_SLOT, MyCommon.ProjectionConstants); //RC.SetCB(MyCommon.FRAME_SLOT, MyCommon.FrameConstants); }
internal static void DrawIndexedInstancedIndirectGPUParticles(MyRenderContext RC, Buffer bufferForArgsRef, int alignedByteOffsetForArgs) { RC.SetCB(MyCommon.FRAME_SLOT, MyCommon.FrameConstantsStereoLeftEye); SetViewport(RC, MyStereoRegion.LEFT); RC.DeviceContext.DrawIndexedInstancedIndirect(bufferForArgsRef, alignedByteOffsetForArgs); RC.SetCB(MyCommon.FRAME_SLOT, MyCommon.FrameConstantsStereoRightEye); SetViewport(RC, MyStereoRegion.RIGHT); RC.DeviceContext.DrawIndexedInstancedIndirect(bufferForArgsRef, alignedByteOffsetForArgs); RC.SetCB(MyCommon.FRAME_SLOT, MyCommon.FrameConstants); SetViewport(RC, MyStereoRegion.FULLSCREEN); }
internal static void DrawIndexedBillboards(MyRenderContext RC, int indexCount, int startIndexLocation, int baseVertexLocation) { MyStereoRender.SetViewport(RC, MyStereoRegion.LEFT); RC.SetCB(MyCommon.FRAME_SLOT, MyCommon.FrameConstantsStereoLeftEye); RC.DeviceContext.DrawIndexed(indexCount, startIndexLocation, baseVertexLocation); MyStereoRender.SetViewport(RC, MyStereoRegion.RIGHT); RC.SetCB(MyCommon.FRAME_SLOT, MyCommon.FrameConstantsStereoRightEye); RC.DeviceContext.DrawIndexed(indexCount, startIndexLocation, baseVertexLocation); MyStereoRender.SetViewport(RC, MyStereoRegion.FULLSCREEN); RC.SetCB(MyCommon.FRAME_SLOT, MyCommon.FrameConstants); }
private static void EndDrawGBufferPass(MyRenderContext RC) { SetViewport(RC, MyStereoRegion.FULLSCREEN); var viewProjTranspose = Matrix.Transpose(MyRender11.Environment.ViewProjectionAt0); var mapping = MyMapping.MapDiscard(RC.DeviceContext, MyCommon.ProjectionConstants); mapping.WriteAndPosition(ref viewProjTranspose); mapping.Unmap(); RC.SetCB(MyCommon.PROJECTION_SLOT, MyCommon.ProjectionConstants); //RC.SetCB(MyCommon.FRAME_SLOT, MyCommon.FrameConstants); }
private static void SwitchDrawGBufferPass(MyRenderContext RC) { SetViewport(RC, MyStereoRegion.RIGHT); var viewProjTranspose = Matrix.Transpose(EnvMatricesRightEye.ViewProjectionAt0); var mapping = MyMapping.MapDiscard(RC.DeviceContext, MyCommon.ProjectionConstants); mapping.WriteAndPosition(ref viewProjTranspose); mapping.Unmap(); RC.SetCB(MyCommon.PROJECTION_SLOT, MyCommon.ProjectionConstants); //RC.SetCB(MyCommon.FRAME_SLOT, MyCommon.VRFrameConstantsRightEye); }
private unsafe void MarkCascadesInStencil(MyProjectionInfo[] cascadeInfo) { MyGpuProfiler.IC_BeginBlock("MarkCascadesInStencil"); //RC.SetRS(MyRasterizerState.CullCW); MyRenderContext renderContext = MyRenderContext.Immediate; renderContext.DeviceContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList; renderContext.SetVB(0, m_cascadesBoundingsVertices.Buffer, m_cascadesBoundingsVertices.Stride); renderContext.SetIB(m_cubeIB.Buffer, m_cubeIB.Format); renderContext.SetIL(m_inputLayout); renderContext.DeviceContext.Rasterizer.SetViewport(0, 0, MyRender11.ViewportResolution.X, MyRender11.ViewportResolution.Y); renderContext.SetCB(MyCommon.FRAME_SLOT, MyCommon.FrameConstants); renderContext.BindDepthRT(MyGBuffer.Main.DepthStencil, DepthStencilAccess.DepthReadOnly, null); renderContext.SetVS(m_markVS); renderContext.SetPS(m_markPS); const int vertexCount = 8; Vector3D *frustumVerticesSS = stackalloc Vector3D[vertexCount]; frustumVerticesSS[0] = new Vector3D(-1, -1, 0); frustumVerticesSS[1] = new Vector3D(-1, 1, 0); frustumVerticesSS[2] = new Vector3D(1, 1, 0); frustumVerticesSS[3] = new Vector3D(1, -1, 0); frustumVerticesSS[4] = new Vector3D(-1, -1, 1); frustumVerticesSS[5] = new Vector3D(-1, 1, 1); frustumVerticesSS[6] = new Vector3D(1, 1, 1); frustumVerticesSS[7] = new Vector3D(1, -1, 1); Vector3D *lightVertices = stackalloc Vector3D[vertexCount]; Vector3 * tmpFloatVertices = stackalloc Vector3[vertexCount]; var mapping = MyMapping.MapDiscard(m_cascadesBoundingsVertices.Buffer); for (int cascadeIndex = 0; cascadeIndex < MyRender11.Settings.ShadowCascadeCount; ++cascadeIndex) { var inverseViewProj = MatrixD.Invert(cascadeInfo[cascadeIndex].CurrentLocalToProjection); for (int arrayIndex = 0; arrayIndex < vertexCount; ++arrayIndex) { Vector3D.Transform(ref frustumVerticesSS[arrayIndex], ref inverseViewProj, out lightVertices[arrayIndex]); tmpFloatVertices[arrayIndex] = lightVertices[arrayIndex]; } for (int arrayIndex = 0; arrayIndex < vertexCount; ++arrayIndex) { mapping.WriteAndPosition(ref tmpFloatVertices[arrayIndex]); } } mapping.Unmap(); for (int cascadeIndex = 0; cascadeIndex < MyRender11.Settings.ShadowCascadeCount; ++cascadeIndex) { renderContext.SetDS(MyDepthStencilState.MarkIfInsideCascade[cascadeIndex], 1 << cascadeIndex); // mark ith bit on depth near renderContext.DeviceContext.DrawIndexed(36, 0, 8 * cascadeIndex); } renderContext.BindDepthRT(null, DepthStencilAccess.DepthReadOnly, null); renderContext.SetDS(null); renderContext.SetRS(null); MyGpuProfiler.IC_EndBlock(); }