コード例 #1
0
ファイル: BayBridgeApp.cpp プロジェクト: SethGibson/BayBridge
void BayBridgeApp::drawFbo()
{
	mFboRaw->bindFramebuffer();
	gl::clear(Color::black());
	gl::setMatrices(mCamera);
	drawBridge(vec3(0), 0.0f);
	mBridge.Draw();
	mFboRaw->unbindFramebuffer();

	////////////////////////////////////////////////////
	mFboHiPass->bindFramebuffer();
	mFboRaw->bindTexture(0);
	mShaderHiPass->bind();
	gl::enableAlphaBlending();
	gl::clear(ColorA::zero());
	gl::setMatricesWindow(getWindowSize());
	gl::drawSolidRect(Rectf({vec2(0), getWindowSize()}));
	gl::disableAlphaBlending();
	mFboRaw->unbindTexture(0);
	mFboHiPass->unbindFramebuffer();

	////////////////////////////////////////////////////
	mFboBlurU->bindFramebuffer();
	mFboHiPass->bindTexture(0);
	mShaderBlur->bind();
	mShaderBlur->uniform("uBlurAxis", vec2(1.0, 0.0));
	mShaderBlur->uniform("uBlurStrength", 2.0f);
	mShaderBlur->uniform("uBlurSize", 1.0f);
	gl::clear(ColorA::zero());
	gl::setMatricesWindow(getWindowSize());
	gl::drawSolidRect(Rectf({ vec2(0), getWindowSize() }));
	mFboHiPass->unbindTexture(0);
	mFboBlurU->unbindFramebuffer();

	////////////////////////////////////////////////////
	mFboBlurV->bindFramebuffer();
	mFboBlurU->bindTexture(0);
	mShaderBlur->bind();
	mShaderBlur->uniform("uBlurAxis", vec2(0.0, 1.0));
	mShaderBlur->uniform("uBlurStrength", 2.0f);
	mShaderBlur->uniform("uBlurSize", 2.0f);
	gl::clear(ColorA::zero());
	gl::setMatricesWindow(getWindowSize());
	gl::drawSolidRect(Rectf({ vec2(0), getWindowSize() }));
	mFboBlurU->unbindTexture(0);
	mFboBlurV->unbindFramebuffer();
}
コード例 #2
0
void MotionBlurFboApp::draw()
{
	gl::viewport( vec2(), mAccumFbo->getSize() );

	if( ! mPaused ) {
		// make 'mAccumFbo' the active framebuffer
		gl::ScopedFramebuffer fbScp( mAccumFbo );
		// clear out both of our FBOs
		gl::clear( Color::black() );
		gl::color( 1, 1, 1, 1 );

		// iterate all the sub-frames
		double startTime = getElapsedSeconds();
		for( int i = 0; i < SUBFRAMES; ++i ) {
			// draw the Cube's sub-frame into mFbo
			gl::enableDepth();
			gl::enableAlphaBlending();
			mFbo->bindFramebuffer();
			gl::clear();
			gl::enableDepth();
			gl::setMatrices( mCam );
			updateCubeRotation( startTime + i / (float)SUBFRAMES );
			gl::multModelMatrix( mCubeRotation );
			mBatch->draw();
			
			// now add this frame to the accumulation FBO
			mAccumFbo->bindFramebuffer();
			gl::setMatricesWindow( mAccumFbo->getSize() );
			gl::enableAdditiveBlending();
			gl::enableDepth( false );
			gl::draw( mFbo->getColorTexture() );
		}
	}
	
	gl::disableDepthRead();
	gl::disableAlphaBlending();
	// set the color to be 1/SUBFRAMES, which divides the HDR image by the number of sub-frames we rendered
	gl::color( 1.0f / SUBFRAMES, 1.0f / SUBFRAMES, 1.0f / SUBFRAMES, 1 );
	gl::setMatricesWindow( getWindowSize() );
	gl::draw( mAccumFbo->getColorTexture() );
}