void PostProcessWater::Process(RenderTarget &destinationTarget, LPDIRECT3DBASETEXTURE9 sourceTexture) { // Implement your own solution for the Post-process lab //return ProcessSolution(destinationTarget, sourceTexture); elapsedTime += timer.GetElapsedTime(); destinationTarget.ActivateTarget(0); IDirect3DDevice9 *pDevice = Renderer::theDevicePtr; Renderer::theDevicePtr->Clear(0,0, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1, 0); // Set the vertex and index source and declarion pDevice->SetVertexDeclaration(VertexBufferManager::GetReference().GetPositionTexBuffer().GetVertexDeclaration()); pDevice->SetStreamSource(0, VertexBufferManager::GetReference().GetPositionTexBuffer().GetVertexBuffer(), 0, sizeof(VERTEX_POSTEX)); pDevice->SetIndices(IndexBuffer::GetReference().GetIndices()); effectPtr->SetTexture(textureHandle, sourceTexture); effectPtr->SetFloat(elapsedTimeHandle, elapsedTime); // RTT_Ambient, RTT_Diffuse, RTT_Specular, RTT_Emmisive, RTT_Normal effectPtr->SetTexture(reflectionMapTextureHandle, renderMaterialHandle.GetContent()->GetRTCubeMapHandle().GetContent()->GetHandle()); effectPtr->SetTexture(heightMapTextueHandle, renderMaterialHandle.GetContent()->GetRTHandles()[RTT_Diffuse].GetContent()->GetHandle()); effectPtr->SetTexture(noiseTextureHandle, renderMaterialHandle.GetContent()->GetRTHandles()[RTT_Normal].GetContent()->GetHandle()); effectPtr->SetTexture(foamTextureHandle, renderMaterialHandle.GetContent()->GetRTHandles()[RTT_Ambient].GetContent()->GetHandle()); effectPtr->SetTexture(causticTextureHandle, renderMaterialHandle.GetContent()->GetRTHandles()[RTT_Specular].GetContent()->GetHandle()); effectPtr->SetValue(surfaceColorHandle, &renderMaterialHandle.GetContent()->GetRenderColors()[RTT_Diffuse], sizeof(RenderColor)); effectPtr->SetValue(ambientColorHandle, &renderMaterialHandle.GetContent()->GetRenderColors()[RTT_Ambient], sizeof(RenderColor)); pDevice->SetVertexDeclaration(VertexBufferManager::GetReference().GetPositionTexBuffer().GetVertexDeclaration()); pDevice->SetStreamSource(0, VertexBufferManager::GetReference().GetPositionTexBuffer().GetVertexBuffer(), 0, sizeof(VERTEX_POSTEX)); pDevice->SetIndices(IndexBuffer::GetReference().GetIndices()); // Begin the post-process effect UINT passes = 0; effectPtr->Begin(&passes, 0); // Iterate through the post-process passes for(UINT pass = 0; pass < passes; ++pass) { effectPtr->BeginPass(pass); Renderer::theDevicePtr->DrawIndexedPrimitive(meshPtr->GetPrimitiveType(), meshPtr->GetStartVertex(), 0, meshPtr->GetVertCount(), meshPtr->GetStartIndex(), meshPtr->GetPrimitiveCount()); effectPtr->EndPass(); } effectPtr->End(); destinationTarget.RevertTarget(); timer.Reset(); }
void PostProcessChain::Run(RenderTarget &mainTarget) { // Implement your own solution for the Post-process lab RunSolution(mainTarget); // We need the destination of the effect chain to be written to the mainTarget before we return RenderContext *sceneContext = RenderController::GetInstance()->GetScreenContextPtr(); RenderShapeTarget *screenShape = RenderController::GetInstance()->GetScreenShapePtr(); mainTarget.ActivateTarget(0); screenShape->SetRenderTarget(sourceTargetPtr); screenShape->AddToContextSet(); sceneContext->RenderProcess(); sceneContext->ClearRenderSet(); mainTarget.RevertTarget(); }