| 49 | } |
| 50 | |
| 51 | bool RenderManager::preProcess(){ |
| 52 | //Initializing the surface that we use to draw screen-space effects |
| 53 | canvas.setup(); |
| 54 | |
| 55 | //Building the grid of AABB enclosing the view frustum clusters |
| 56 | buildAABBGridCompShader.use(); |
| 57 | buildAABBGridCompShader.setFloat("zNear", sceneCamera->cameraFrustum.nearPlane); |
| 58 | buildAABBGridCompShader.setFloat("zFar", sceneCamera->cameraFrustum.farPlane); |
| 59 | buildAABBGridCompShader.dispatch(gridSizeX, gridSizeY, gridSizeZ); |
| 60 | |
| 61 | //Environment Mapping |
| 62 | //Passing equirectangular map to cubemap |
| 63 | captureFBO.bind(); |
| 64 | currentScene->mainSkyBox.fillCubeMapWithTexture(fillCubeMapShader); |
| 65 | |
| 66 | //Cubemap convolution TODO:: This could probably be moved to a function of the scene or environment maps |
| 67 | //themselves as a class / static function |
| 68 | int res = currentScene->irradianceMap.width; |
| 69 | captureFBO.resizeFrameBuffer(res); |
| 70 | unsigned int environmentID = currentScene->mainSkyBox.skyBoxCubeMap.textureID; |
| 71 | currentScene->irradianceMap.convolveCubeMap(environmentID, convolveCubeMap); |
| 72 | |
| 73 | //Cubemap prefiltering TODO:: Same as above |
| 74 | unsigned int captureRBO = captureFBO.depthBuffer; |
| 75 | currentScene->specFilteredMap.preFilterCubeMap(environmentID, captureRBO, preFilterSpecShader); |
| 76 | |
| 77 | //BRDF lookup texture |
| 78 | integrateBRDFShader.use(); |
| 79 | res = currentScene->brdfLUTTexture.height; |
| 80 | captureFBO.resizeFrameBuffer(res); |
| 81 | unsigned int id = currentScene->brdfLUTTexture.textureID; |
| 82 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, id, 0); |
| 83 | glViewport(0, 0, res, res); |
| 84 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
| 85 | canvas.draw(); |
| 86 | |
| 87 | //Making sure that the viewport is the correct size after rendering |
| 88 | glViewport(0, 0, DisplayManager::SCREEN_WIDTH, DisplayManager::SCREEN_HEIGHT); |
| 89 | |
| 90 | glEnable(GL_DEPTH_TEST); |
| 91 | glDepthMask(true); |
| 92 | |
| 93 | //Populating depth cube maps for the point light shadows |
| 94 | for (unsigned int i = 0; i < currentScene->pointLightCount; ++i){ |
| 95 | pointLightShadowFBOs[i].bind(); |
| 96 | pointLightShadowFBOs[i].clear(GL_DEPTH_BUFFER_BIT, glm::vec3(1.0f)); |
| 97 | currentScene->drawPointLightShadow(pointShadowShader, i, pointLightShadowFBOs[i].depthBuffer); |
| 98 | } |
| 99 | |
| 100 | // Directional shadows |
| 101 | dirShadowFBO.bind(); |
| 102 | dirShadowFBO.clear(GL_DEPTH_BUFFER_BIT, glm::vec3(1.0f)); |
| 103 | currentScene->drawDirLightShadows(dirShadowShader, dirShadowFBO.depthBuffer); |
| 104 | |
| 105 | //As we add more error checking this will change from a dummy variable to an actual thing |
| 106 | return true; |
| 107 | } |
| 108 |
nothing calls this directly
no test coverage detected