void Camera::createPostFilter(Material *shaderMaterial) { if(!shaderMaterial) return; if(shaderMaterial->getNumShaders() == 0) return; this->filterShaderMaterial = shaderMaterial; // TODO: make it save the textures to resource manager and check if they there // originalSceneTexture = CoreServices::getInstance()->getMaterialManager()->createNewTexture(CoreServices::getInstance()->getCore()->getXRes(), CoreServices::getInstance()->getCore()->getYRes()); // zBufferSceneTexture = CoreServices::getInstance()->getMaterialManager()->createFramebufferTexture(CoreServices::getInstance()->getCore()->getXRes(), CoreServices::getInstance()->getCore()->getYRes(), 0); if(!originalSceneTexture) { CoreServices::getInstance()->getRenderer()->createRenderTextures(&originalSceneTexture, &zBufferSceneTexture, CoreServices::getInstance()->getCore()->getXRes(), CoreServices::getInstance()->getCore()->getYRes(), shaderMaterial->fp16RenderTargets); } for(int i=0; i < shaderMaterial->getNumShaders(); i++) { ShaderBinding* binding = shaderMaterial->getShader(i)->createBinding(); if(i == 0) { binding->addTexture("screenColorBuffer", originalSceneTexture); binding->addTexture("screenDepthBuffer", zBufferSceneTexture); } localShaderOptions.push_back(binding); binding->addLocalParam("exposure", (void*)&exposureLevel); } _hasFilterShader = true; }
void Camera::setPostFilter(Material *shaderMaterial) { if(!shaderMaterial) return; if(shaderMaterial->getNumShaders() == 0) return; this->filterShaderMaterial = shaderMaterial; if(!originalSceneTexture) { CoreServices::getInstance()->getRenderer()->createRenderTextures(&originalSceneTexture, &zBufferSceneTexture, CoreServices::getInstance()->getCore()->getXRes(), CoreServices::getInstance()->getCore()->getYRes(), shaderMaterial->fp16RenderTargets); } for(int i=0; i < shaderMaterial->getNumShaders(); i++) { ShaderBinding* binding = shaderMaterial->getShader(i)->createBinding(); localShaderOptions.push_back(binding); binding->addLocalParam("exposure", (void*)&exposureLevel); } _hasFilterShader = true; }