void IndirectLightingRenderer::Render(pTexture inSource, pTexture inNormal, pTexture inLinearDepth, pTexture inMaxDepth, pTexture inDiffuse, pRenderTarget inTarget, pRenderTarget inTempTarget) { assert(mInitialized == true); assert(inSource != nullptr); assert(inTarget != nullptr); ApplyIndirect(inSource, inNormal, inLinearDepth, inMaxDepth, inDiffuse, inTarget); for (int i = 0; i < 2; i++) { ApplyBlur(inTarget->GetTexture(), inNormal, inLinearDepth, inTempTarget, true); ApplyBlur(inTempTarget->GetTexture(), inNormal, inLinearDepth, inTarget, false); } }
void CPostprocManager::ApplyPostproc() { if (!m_IsInitialised) return; // Don't do anything if we are using the default effect. if (m_PostProcEffect == L"default") { return; } pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PongFbo); pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D, 0, 0); GLenum buffers[] = { GL_COLOR_ATTACHMENT0_EXT }; pglDrawBuffers(1, buffers); pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PingFbo); pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D, 0, 0); pglDrawBuffers(1, buffers); pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PongFbo); pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0); pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PingFbo); pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0); // First render blur textures. Note that this only happens ONLY ONCE, before any effects are applied! // (This may need to change depending on future usage, however that will have a fps hit) ApplyBlur(); for (int pass = 0; pass < m_PostProcTech->GetNumPasses(); ++pass) { ApplyEffect(m_PostProcTech, pass); } pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PongFbo); pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_DepthTex, 0); pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PingFbo); pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_DepthTex, 0); }
void SDSMShadowManager::RenderShadowMapPartitions(const D3DXMATRIX &lightViewProjMatrix, DynamicArray<SceneEntity*> &shadowEntities, DepthStencilTarget *gbufferDepth, RenderTarget *gbufferNormals) { Direct3DManager *direct3DManager = mGraphicsManager->GetDirect3DManager(); GraphicsContext *graphicsContext = direct3DManager->GetContextManager()->GetGraphicsContext(); Direct3DHeapManager *heapManager = direct3DManager->GetContextManager()->GetHeapManager(); Direct3DQueueManager *queueManager = direct3DManager->GetContextManager()->GetQueueManager(); //TDA: * mShadowPreferences.PartitionCount <--- is only for testing. Can just fill those cbv descs on the first partition and then reuse them uint32 numCBVSRVDescsShadowMap = shadowEntities.CurrentSize() * mShadowPreferences.PartitionCount + mShadowPreferences.PartitionCount + 1; //1 cbv per entity + X partition cbvs + 1 partition srv uint32 numCBVSRVDescsEVSM = 1; uint32 numCBVSRVDescsMips = 1 + mShadowPreferences.ShadowTextureMipLevels; RenderPassDescriptorHeap *shadowSRVDescHeap = heapManager->GetRenderPassDescriptorHeapFor(RenderPassDescriptorHeapType_ShadowRender, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, direct3DManager->GetFrameIndex(), numCBVSRVDescsShadowMap + numCBVSRVDescsEVSM + numCBVSRVDescsMips); RenderPassDescriptorHeap *shadowSamplerDescHeap = heapManager->GetRenderPassDescriptorHeapFor(RenderPassDescriptorHeapType_ShadowRender, D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER, direct3DManager->GetFrameIndex(), 1); graphicsContext->InsertPixBeginEvent(0xFF00FF00, "Shadow Render"); graphicsContext->TransitionResource(mShadowPartitionBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, true); graphicsContext->SetDescriptorHeap(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, shadowSRVDescHeap->GetHeap()); graphicsContext->SetDescriptorHeap(D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER, shadowSamplerDescHeap->GetHeap()); graphicsContext->SetViewport(mShadowMapViewport); graphicsContext->SetScissorRect(0, 0, mShadowPreferences.ShadowTextureSize, mShadowPreferences.ShadowTextureSize); DescriptorHeapHandle shadowParitionReadBuffer = shadowSRVDescHeap->GetHeapHandleBlock(1); direct3DManager->GetDevice()->CopyDescriptorsSimple(1, shadowParitionReadBuffer.GetCPUHandle(), mShadowPartitionBuffer->GetShaderResourceViewHandle().GetCPUHandle(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); DescriptorHeapHandle shadowMapDepthHandle = shadowSRVDescHeap->GetHeapHandleBlock(1); direct3DManager->GetDevice()->CopyDescriptorsSimple(1, shadowMapDepthHandle.GetCPUHandle(), mShadowDepthTarget->GetShaderResourceViewHandle().GetCPUHandle(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); DynamicArray<MaterialTextureType> noTexturesForThisPass; RenderPassContext shadowPassContext(graphicsContext, shadowSRVDescHeap, shadowSamplerDescHeap, noTexturesForThisPass, direct3DManager->GetFrameIndex()); for (uint32 i = 0; i < SDSM_SHADOW_PARTITION_COUNT; i++) { DescriptorHeapHandle perPassParitionBuffer = shadowSRVDescHeap->GetHeapHandleBlock(1); direct3DManager->GetDevice()->CopyDescriptorsSimple(1, perPassParitionBuffer.GetCPUHandle(), mPartitionIndexBuffers[i]->GetConstantBufferViewHandle().GetCPUHandle(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); graphicsContext->SetPipelineState(mShadowMapShader); graphicsContext->SetRootSignature(mShadowMapShader->GetRootSignature(), NULL); graphicsContext->SetGraphicsDescriptorTable(1, perPassParitionBuffer.GetGPUHandle()); graphicsContext->SetGraphicsDescriptorTable(2, shadowParitionReadBuffer.GetGPUHandle()); RenderShadowDepth(i, &shadowPassContext, lightViewProjMatrix, shadowEntities); graphicsContext->SetPipelineState(mShadowMapEVSMShader); graphicsContext->SetRootSignature(mShadowMapEVSMShader->GetRootSignature(), NULL); graphicsContext->SetGraphicsDescriptorTable(0, perPassParitionBuffer.GetGPUHandle()); graphicsContext->SetGraphicsDescriptorTable(1, shadowMapDepthHandle.GetGPUHandle()); graphicsContext->SetGraphicsDescriptorTable(2, shadowParitionReadBuffer.GetGPUHandle()); ConvertToEVSM(i); if (mShadowPreferences.UseSoftShadows) { ApplyBlur(); } GenerateMipsForShadowMap(i, &shadowPassContext); graphicsContext->TransitionResource(mShadowEVSMTextures[i], D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, true); } RenderAccumulatedShadowMap(&shadowPassContext, gbufferDepth, gbufferNormals); graphicsContext->InsertPixEndEvent(); }