From 0cdab56dae680d0e8f79f207b65bdd077ba7273e Mon Sep 17 00:00:00 2001 From: Andrea Baldacci baldacci Date: Tue, 24 May 2011 10:48:07 +0000 Subject: [PATCH] try 16 bit buffer Fbo result for Mac problem --- src/fgt/filter_sdfgpu/filter_sdfgpu.cpp | 46 +++++++++++++------------ 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/src/fgt/filter_sdfgpu/filter_sdfgpu.cpp b/src/fgt/filter_sdfgpu/filter_sdfgpu.cpp index ef1e79745..0cd1f824c 100644 --- a/src/fgt/filter_sdfgpu/filter_sdfgpu.cpp +++ b/src/fgt/filter_sdfgpu/filter_sdfgpu.cpp @@ -281,7 +281,7 @@ bool SdfGpuPlugin::initGL(MeshModel& mm) mVertexCoordsTexture = new FloatTexture2D( TextureFormat( GL_TEXTURE_2D, mResTextureDim, mResTextureDim, GL_RGBA32F_ARB, GL_RGBA, GL_FLOAT ), TextureParams( GL_NEAREST, GL_NEAREST ) ); mVertexNormalsTexture = new FloatTexture2D( TextureFormat( GL_TEXTURE_2D, mResTextureDim, mResTextureDim, GL_RGBA32F_ARB, GL_RGBA, GL_FLOAT ), TextureParams( GL_NEAREST, GL_NEAREST ) ); - mResultTexture = new FloatTexture2D( TextureFormat( GL_TEXTURE_2D, mResTextureDim, mResTextureDim, GL_RGBA32F_ARB, GL_RGBA, GL_FLOAT ), TextureParams( GL_NEAREST, GL_NEAREST ) ); + mResultTexture = new FloatTexture2D( TextureFormat( GL_TEXTURE_2D, mResTextureDim, mResTextureDim, /*GL_RGBA32F_ARB*/GL_RGBA16F_ARB, GL_RGBA, GL_FLOAT ), TextureParams( GL_NEAREST, GL_NEAREST ) ); mFboResult = new FramebufferObject(); mFboResult->attachTexture( mResultTexture->format().target(), mResultTexture->id(), GL_COLOR_ATTACHMENT0_EXT ); assert(mFboResult->isValid()); @@ -540,10 +540,6 @@ void SdfGpuPlugin::useDepthPeelingShader(FramebufferObject* fbo) void SdfGpuPlugin::calculateSdfHW(FramebufferObject* fboFront, FramebufferObject* fboBack, FramebufferObject* fboPrevBack, const vcg::Point3f& cameraDir) { - mFboResult->bind(); - glViewport(0, 0, mResTextureDim, mResTextureDim); - glDrawBuffer(GL_COLOR_ATTACHMENT0); - GLfloat mv_pr_Matrix_f[16]; // modelview-projection matrix glGetFloatv(GL_MODELVIEW_MATRIX, mv_pr_Matrix_f); @@ -558,13 +554,6 @@ void SdfGpuPlugin::calculateSdfHW(FramebufferObject* fboFront, FramebufferObject glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - glDisable(GL_DEPTH_TEST); - glDepthMask(GL_FALSE); - - glEnable (GL_BLEND); - glBlendFunc (GL_ONE, GL_ONE); - glBlendEquation(GL_FUNC_ADD); - glUseProgram(mSDFProgram->id()); glActiveTexture(GL_TEXTURE0); @@ -630,6 +619,18 @@ void SdfGpuPlugin::calculateSdfHW(FramebufferObject* fboFront, FramebufferObject else mSDFProgram->setUniform1i("removeOutliers",0); + mFboResult->bind(); + glViewport(0, 0, mResTextureDim, mResTextureDim); + + glDrawBuffer(GL_COLOR_ATTACHMENT0); + + glDisable(GL_DEPTH_TEST); + glDepthMask(GL_FALSE); + + glEnable (GL_BLEND); + glBlendFunc (GL_ONE, GL_ONE); + glBlendEquation(GL_FUNC_ADD); + // Screen-aligned Quad glBegin(GL_QUADS); glVertex3f(-1.0f, -1.0f, 0.0f); //L-L @@ -672,9 +673,6 @@ void SdfGpuPlugin::applySdfHW(MeshModel &m, float numberOfRays) void SdfGpuPlugin::calculateObscurance(FramebufferObject* fboFront, FramebufferObject* fboBack, FramebufferObject* nextBack, const vcg::Point3f& cameraDir, float bbDiag) { - mFboResult->bind(); - glViewport(0, 0, mResTextureDim, mResTextureDim); - glDrawBuffer(GL_COLOR_ATTACHMENT0); GLfloat mv_pr_Matrix_f[16]; // modelview-projection matrix glGetFloatv(GL_MODELVIEW_MATRIX, mv_pr_Matrix_f); @@ -689,13 +687,6 @@ void SdfGpuPlugin::calculateObscurance(FramebufferObject* fboFront, FramebufferO glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - glDisable(GL_DEPTH_TEST); - glDepthMask(GL_FALSE); - - glEnable (GL_BLEND); - glBlendFunc (GL_ONE, GL_ONE); - glBlendEquation(GL_FUNC_ADD); - glUseProgram(mObscuranceProgram->id()); glActiveTexture(GL_TEXTURE0); @@ -744,6 +735,17 @@ void SdfGpuPlugin::calculateObscurance(FramebufferObject* fboFront, FramebufferO else mObscuranceProgram->setUniform1i("firstRendering",0); + mFboResult->bind(); + glViewport(0, 0, mResTextureDim, mResTextureDim); + glDrawBuffer(GL_COLOR_ATTACHMENT0); + + glDisable(GL_DEPTH_TEST); + glDepthMask(GL_FALSE); + + glEnable (GL_BLEND); + glBlendFunc (GL_ONE, GL_ONE); + glBlendEquation(GL_FUNC_ADD); + // Screen-aligned Quad glBegin(GL_QUADS); glVertex3f(-1.0f, -1.0f, 0.0f); //L-L