I used to render only when changing the positions of the lights and FPS was acceptable, but it turned out that I needed dynamic shadows for animated characters. FPS now does not rise above 58 frames per second, and judging by the indicators, the video card is idle.
// rendering depth to render texture for point light bool lightPosChanged = false; for (int i = 0; i < NUM_POINT_LIGHTS; i++) { lightPosChanged = lightPositionsPrev[i] != m_Cameras[1 + i].GetPosition(); if (lightPosChanged) break; } if (lightPosChanged || true) { for (int i = 0; i < NUM_POINT_LIGHTS; i++) { PreparePointLightViewMatrixes(m_Cameras[i + 1].GetPosition()); //static_cast<DX11RendererAPI*>(RendererAPI::GetInstance().get())->SetCullFront(); m_PointLightDepthVertexShader->Bind(); m_PointLightDepthGeometryShader->Bind(); m_PointLightDepthPixelShader->Bind(); PointLightDepthToTextureBegin(i); RenderScene(m_Cameras[0].GetViewMatrix(), lightProjMat, m_PointLightDepthVertexShader, m_PointLightDepthPixelShader, m_PointLightDepthGeometryShader, false, nullptr, 0, false); PointLightDepthToTextureEnd(i); m_PointLightDepthVertexShader->Unbind(); m_PointLightDepthGeometryShader->Unbind(); m_PointLightDepthPixelShader->Unbind(); //static_cast<DX11RendererAPI*>(RendererAPI::GetInstance().get())->SetCullBack(); } lightPositionsPrev[0] = m_Cameras[1].GetPosition(); lightPositionsPrev[1] = m_Cameras[2].GetPosition(); lightPositionsPrev[2] = m_Cameras[3].GetPosition(); } I am using the geometry shader to render shadows to a cubemap:
struct Output { float4 Pos : SV_POSITION; float2 uv : TEXCOORD0; uint RTIndex : SV_RenderTargetArrayIndex; }; [maxvertexcount(18)] void GSMain(triangle Input input[3], inout TriangleStream<Output> OutStream) { for (int iFace = 0; iFace < 6; iFace++) { Output output; output.RTIndex = iFace; for (int v = 0; v < 3; v++) { output.Pos = mul(input[v].position, CubeView[iFace]); output.Pos = mul(output.Pos, CubeProj); output.uv = input[v].uv; OutStream.Append(output); } OutStream.RestartStrip(); } } ```