public void RenderVolumetricFog(DeviceContext context, TextureObject shadowMap, GlobalIlluminationRenderer giRenderer) { // Not using temporal manager as it was designed for render target sets; TODO TextureObject previousFrameAccumulationTexture = m_Phase ? m_LightingTexturePing : m_LightingTexturePong; TextureObject currentFrameAccumulationTexture = m_Phase ? m_LightingTexturePong : m_LightingTexturePing; m_Phase = !m_Phase; using (new GpuProfilePoint(context, "VolumetricFog")) { #if false using (new GpuProfilePoint(context, "DensityEstimation")) { context.ComputeShader.SetUnorderedAccessView(m_DensityTexture.m_UnorderedAccessView, 0); ShaderManager.ExecuteComputeForResource(context, m_DensityTexture, "CalculateDensity"); ContextHelper.ClearCSContext(context); } #endif using (new GpuProfilePoint(context, "LitFogVolume")) { context.ComputeShader.SetShaderResource(giRenderer.m_GIVolumeR.m_ShaderResourceView, 5); context.ComputeShader.SetShaderResource(giRenderer.m_GIVolumeG.m_ShaderResourceView, 6); context.ComputeShader.SetShaderResource(giRenderer.m_GIVolumeB.m_ShaderResourceView, 7); context.ComputeShader.SetShaderResource(previousFrameAccumulationTexture.m_ShaderResourceView, 8); context.ComputeShader.SetShaderResource(m_DensityTexture.m_ShaderResourceView, 0); context.ComputeShader.SetShaderResource(shadowMap.m_ShaderResourceView, 1); context.ComputeShader.SetUnorderedAccessView(currentFrameAccumulationTexture.m_UnorderedAccessView, 1); ShaderManager.ExecuteComputeForResource(context, currentFrameAccumulationTexture, "LitFogVolume"); ContextHelper.ClearCSContext(context); } using (new GpuProfilePoint(context, "ComputeScattering")) { context.ComputeShader.SetShaderResource(currentFrameAccumulationTexture.m_ShaderResourceView, 0); context.ComputeShader.SetUnorderedAccessView(m_ScatteringTexture.m_UnorderedAccessView, 2); ShaderManager.ExecuteComputeForSize(context, m_VolumeX, m_VolumeY, 1, "ComputeScattering"); ContextHelper.ClearCSContext(context); } } }