void GPUChromaKeyFilter::applyOnGPU(GLTexturePtr pSrcTex) { // Set up double-buffering int curBufferIndex = m_Erosion%2; getFBO(curBufferIndex)->activate(); getShader()->activate(); m_pTextureParam->set(0); float h, s, l; m_Color.toHSL(h, s, l); m_pHKeyParam->set(h); m_pHToleranceParam->set(m_HTolerance*360); m_pHSoftToleranceParam->set((m_HTolerance+m_Softness)*360.0f); m_pSKeyParam->set(s); m_pSToleranceParam->set(m_STolerance); m_pSSoftToleranceParam->set(m_STolerance+m_Softness); m_pLKeyParam->set(l); m_pLToleranceParam->set(m_LTolerance); m_pLSoftToleranceParam->set(m_LTolerance+m_Softness); m_pSpillThresholdParam->set(m_SpillThreshold*360); m_pIsLastParam->set(int(m_Erosion==0)); draw(pSrcTex); for (int i = 0; i < m_Erosion; ++i) { curBufferIndex = (curBufferIndex+1)%2; getFBO(curBufferIndex)->activate(); OGLShaderPtr pShader = avg::getShader(SHADERID_EROSION); pShader->activate(); m_pErosionTextureParam->set(0); m_pErosionIsLastParam->set(int(i==m_Erosion-1)); getDestTex((curBufferIndex+1)%2)->activate(GL_TEXTURE0); m_pProjection2->draw(avg::getShader(SHADERID_EROSION)); } }
void GPUBlurFilter::applyOnGPU(GLContext* pContext, GLTexturePtr pSrcTex) { int kernelWidth = m_pGaussCurveTex->getSize().x; getFBO(pContext, 1)->activate(); getShader()->activate(); m_pHorizWidthParam->set(pContext, float(kernelWidth)); m_pHorizRadiusParam->set(pContext, (kernelWidth-1)/2); m_pHorizTextureParam->set(pContext, 0); m_pHorizKernelTexParam->set(pContext, 1); m_pGaussCurveTex->getTex(pContext)->activate(WrapMode(), GL_TEXTURE1); draw(pContext, pSrcTex, m_WrapMode); getFBO(pContext, 0)->activate(); OGLShaderPtr pVShader = avg::getShader(SHADERID_VERT); pVShader->activate(); m_pVertWidthParam->set(pContext, float(kernelWidth)); m_pVertRadiusParam->set(pContext, (kernelWidth-1)/2); m_pVertTextureParam->set(pContext, 0); m_pVertKernelTexParam->set(pContext, 1); getDestTex(pContext, 1)->activate(m_WrapMode, GL_TEXTURE0); m_pProjection2->draw(pContext, pVShader); }
void GPUBlurFilter::applyOnGPU(GLTexturePtr pSrcTex) { int kernelWidth = m_pGaussCurveTex->getSize().x; getFBO(1)->activate(); getShader()->activate(); m_pHorizWidthParam->set(float(kernelWidth)); m_pHorizRadiusParam->set((kernelWidth-1)/2); m_pHorizTextureParam->set(0); m_pHorizKernelTexParam->set(1); m_pGaussCurveTex->activate(GL_TEXTURE1); draw(pSrcTex); getFBO(0)->activate(); OGLShaderPtr pVShader = avg::getShader(SHADERID_VERT); pVShader->activate(); m_pVertWidthParam->set(float(kernelWidth)); m_pVertRadiusParam->set((kernelWidth-1)/2); m_pVertTextureParam->set(0); m_pVertKernelTexParam->set(1); getDestTex(1)->activate(GL_TEXTURE0); m_pProjection2->draw(pVShader); }