void BubbleChamberApp::drawIntoRoomFbo()
{
	mRoomFbo.bindFramebuffer();
	gl::clear( ColorA( 0.0f, 0.0f, 0.0f, 0.0f ), true );
	
	gl::setMatricesWindow( mRoomFbo.getSize(), false );
	gl::setViewport( mRoomFbo.getBounds() );
	gl::disableAlphaBlending();
	gl::enable( GL_TEXTURE_2D );
	glEnable( GL_CULL_FACE );
	glCullFace( GL_BACK );
	Matrix44f m;
	m.setToIdentity();
	m.scale( mRoom.getDims() );

	mRoomShader.bind();
	mRoomShader.uniform( "mvpMatrix", mActiveCam.mMvpMatrix );
	mRoomShader.uniform( "mMatrix", m );
	mRoomShader.uniform( "eyePos", mActiveCam.mCam.getEyePoint() );
	mRoomShader.uniform( "roomDims", mRoom.getDims() );
	mRoomShader.uniform( "power", mRoom.getPower() );
	mRoomShader.uniform( "lightPower", mRoom.getLightPower() );
	mRoomShader.uniform( "timePer", mRoom.getTimePer() * 1.5f + 0.5f );
	mRoom.draw();
	mRoomShader.unbind();
	
	mRoomFbo.unbindFramebuffer();
	glDisable( GL_CULL_FACE );
}
Beispiel #2
0
void MemExploreApp::draw()
{
  mTexture = gl::Texture(mDataPointer, GL_RGBA, mVolumeDim * mTilesDim, mVolumeDim * mTilesDim);
  mTexture.setWrap(GL_REPEAT, GL_REPEAT);
  mTexture.setMinFilter(GL_NEAREST);
  mTexture.setMagFilter(GL_NEAREST);
  
  float frustum[6];
  mCamera.getFrustum(&frustum[0], &frustum[1], &frustum[2], &frustum[3], &frustum[4], &frustum[5]);

  mFbo.bindFramebuffer();
  gl::setMatricesWindow(mFbo.getSize(), false);

  mProgram.bind();
  mProgram.uniform("uTexture", 0);
  mProgram.uniform("uVolumeDim", mVolumeDim);
  mProgram.uniform("uTilesDim", mTilesDim);
  mProgram.uniform("uTime", (float)getElapsedSeconds());
  mProgram.uniform("uEyePoint", mCamera.getEyePoint());
  mProgram.uniform("uXAxis", mCamera.getOrientation() * Vec3f::xAxis());
  mProgram.uniform("uYAxis", mCamera.getOrientation() * Vec3f::yAxis());
  mProgram.uniform("uViewDistance", mCamera.getAspectRatio() / abs(frustum[2] - frustum[0]) * mCamera.getNearClip());
  mProgram.uniform("uNegViewDir", -mCamera.getViewDirection().normalized());
  mProgram.uniform("uAspectRatio", mCamera.getAspectRatio());
  mTexture.enableAndBind();
  gl::drawSolidRect(mFbo.getBounds());
  mTexture.unbind();
  mProgram.unbind();
  
  mFbo.unbindFramebuffer();
  
  gl::setMatricesWindow(getWindowSize());
  gl::draw(mFbo.getTexture(), getWindowBounds());
}
void ShadedSphereApp::drawIntoRoomFbo()
{
	mRoomFbo.bindFramebuffer();
	gl::clear( ColorA( 0.0f, 0.0f, 0.0f, 0.0f ), true );
	
	gl::setMatricesWindow( mRoomFbo.getSize(), false );
	gl::setViewport( mRoomFbo.getBounds() );
	gl::disableAlphaBlending();
	gl::enable( GL_TEXTURE_2D );
	glEnable( GL_CULL_FACE );
	glCullFace( GL_BACK );
	Matrix44f m;
	m.setToIdentity();
	m.scale( mRoom.getDims() );
	
	//	mLightsTex.bind( 0 );
	mRoomShader.bind();
	mRoomShader.uniform( "mvpMatrix", mSpringCam.mMvpMatrix );
	mRoomShader.uniform( "mMatrix", m );
	mRoomShader.uniform( "eyePos", mSpringCam.getEye() );
	mRoomShader.uniform( "roomDims", mRoom.getDims() );
	mRoomShader.uniform( "mainPower", mRoom.getPower() );
	mRoomShader.uniform( "lightPower", mRoom.getLightPower() );
	mRoom.draw();
	mRoomShader.unbind();
	
	mRoomFbo.unbindFramebuffer();
	glDisable( GL_CULL_FACE );
}
void StereoscopicRenderingApp::renderAnaglyph(  const Vec2i &size, const ColorA &left, const ColorA &right )
{	
	// bind the FBO and clear its buffer
	mFbo.bindFramebuffer();
	gl::clear( mColorBackground );

	// render the scene using the side-by-side technique
	renderSideBySide( mFbo.getSize() );

	// unbind the FBO
	mFbo.unbindFramebuffer();

	// enable the anaglyph shader
	mShaderAnaglyph.bind();
	mShaderAnaglyph.uniform( "tex0", 0 );
	mShaderAnaglyph.uniform( "clr_left", left );
	mShaderAnaglyph.uniform( "clr_right", right );	

	// bind the FBO texture and draw a full screen rectangle,
	// which conveniently is exactly what the following line does
	gl::draw( mFbo.getTexture(), Rectf(0, float(size.y), float(size.x), 0) );

	// disable the anaglyph shader
	mShaderAnaglyph.unbind();
}
Beispiel #5
0
void CatalogApp::setFboPositions( gl::Fbo &fbo )
{
	int numBrightStars = mBrightStars.size();

	int index = 0;
	
	Surface32f posSurface( fbo.getTexture() );
	Surface32f::Iter it = posSurface.getIter();
	while( it.line() ){
		while( it.pixel() ){
			Vec3f pos = Vec3f( 1000000.0f, 0.0f, 0.0f );
			float col = 0.4f;
			float rad = 0.0f;
			if( index < numBrightStars ){
				pos = mBrightStars[index]->mPos;
				col = mBrightStars[index]->mColor;
				rad = floor( constrain( ( ( 6.0f - ( mBrightStars[index]->mAbsoluteMag ) )/6.0f ), 0.3f, 1.0f ) * 3.0f * 1000 );
			}
			it.r() = pos.x;
			it.g() = pos.y;
			it.b() = pos.z;
			it.a() = rad + col;

			index ++;
		}
	}

	gl::Texture posTexture( posSurface );
	fbo.bindFramebuffer();
	gl::setMatricesWindow( fbo.getSize(), false );
	gl::setViewport( fbo.getBounds() );
	gl::clear( ColorA( 0, 0, 0, 0 ), true );
	gl::draw( posTexture );
	fbo.unbindFramebuffer();
}
void StereoscopicRenderingApp::renderInterlacedHorizontal( const Vec2i &size )
{
	// bind the FBO and clear its buffer
	mFbo.bindFramebuffer();
	gl::clear( mColorBackground );

	// render the scene using the over-under technique
	renderOverUnder( mFbo.getSize() );

	// unbind the FBO
	mFbo.unbindFramebuffer();

	// enable the interlace shader
	mShaderInterlaced.bind();
	mShaderInterlaced.uniform( "tex0", 0 );
	mShaderInterlaced.uniform( "window_origin", Vec2f( getWindowPos() ) );
	mShaderInterlaced.uniform( "window_size", Vec2f( getWindowSize() ) );

	// bind the FBO texture and draw a full screen rectangle,
	// which conveniently is exactly what the following line does
	gl::draw( mFbo.getTexture(), Rectf(0, float(size.y), float(size.x), 0) );

	// disable the interlace shader
	mShaderInterlaced.unbind();
}
void SmoothDisplacementMappingApp::renderDisplacementMap()
{
	if( mDispMapShader && mDispMapFbo ) 
	{
		mDispMapFbo.bindFramebuffer();
		{
			// clear the color buffer
			gl::clear();			

			// setup viewport and matrices 
			glPushAttrib( GL_VIEWPORT_BIT );
			gl::setViewport( mDispMapFbo.getBounds() );

			gl::pushMatrices();
			gl::setMatricesWindow( mDispMapFbo.getSize(), false );

			// render the displacement map
			mDispMapShader.bind();
			mDispMapShader.uniform( "time", float( getElapsedSeconds() ) );
			mDispMapShader.uniform( "amplitude", mAmplitude );
			gl::drawSolidRect( mDispMapFbo.getBounds() );
			mDispMapShader.unbind();

			// clean up after ourselves
			gl::popMatrices();
			glPopAttrib();
		}
		mDispMapFbo.unbindFramebuffer();
	}
}
void KinectEcard::renderDepth(){
	if( !mDepthSurface || !mVideoSurface )
		return;

	gl::pushMatrices();
	{
		mDepthFbo.bindFramebuffer();

		// clear FBO
		gl::clear( Color::black() );
		gl::color( Color::white() );

		//
		gl::setMatricesWindowPersp( mDepthFbo.getSize() );

		// draw depth 
		gl::pushMatrices();
			gl::scale( 2, 2 );
			gl::draw( gl::Texture( mDepthSurface ) );
		gl::popMatrices();

		mDepthFbo.unbindFramebuffer();
	}
	gl::popMatrices();
}
/* 
 * @Description: need to blur[the SSAO texture] horizonatally then vertically (for shader performance reasons). Called ping-ponging as it one FBO drawn to another
 * @param: KeyEvent
 * @return: none
 */
void Base_ThreeD_ProjectApp::pingPongBlur()
{
	//render horizontal blue first
	gl::setViewport( mPingPongBlurH.getBounds() );
	
	mPingPongBlurH.bindFramebuffer();
	
	glClearColor( 0.5f, 0.5f, 0.5f, 1 );
	glClearDepth(1.0f);
	glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
	
	gl::setMatricesWindow( mPingPongBlurH.getSize() );
	
	mSSAOMap.getTexture().bind(0);
	mHBlurShader.bind();
	mHBlurShader.uniform("RTScene", 0);
    gl::drawSolidRect( Rectf( 0, 0, getWindowWidth(), getWindowHeight()) );
	mHBlurShader.unbind();
	mSSAOMap.getTexture().unbind(0);
	
	mPingPongBlurH.unbindFramebuffer();
	
	//gl::setViewport( getWindowBounds() ); //redundant
	
	//now render vertical blur
	gl::setViewport( mPingPongBlurV.getBounds() );
	
	mPingPongBlurV.bindFramebuffer();
	
	glClearColor( 0.5f, 0.5f, 0.5f, 1 );
	glClearDepth(1.0f);
	glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
	
	gl::setMatricesWindow( mPingPongBlurV.getSize() );
	
	mPingPongBlurH.getTexture().bind(0);
	mHBlurShader.bind();
	mHBlurShader.uniform("RTBlurH", 0);
	gl::drawSolidRect( Rectf( 0, 0, getWindowWidth(), getWindowHeight()) );
	mHBlurShader.unbind();
	mPingPongBlurH.getTexture().unbind(0);
	
	mPingPongBlurV.unbindFramebuffer();
	
	gl::setViewport( getWindowBounds() );
}
/* 
 * @Description: render SSAO now - woohoo!
 * @param: KeyEvent
 * @return: none
 */
void Base_ThreeD_ProjectApp::renderSSAOToFBO()
{
	gl::setViewport( mSSAOMap.getBounds() );
	
	//render out main scene to FBO
	mSSAOMap.bindFramebuffer();
	
	glClearColor( 0.5f, 0.5f, 0.5f, 1 );
	glClearDepth(1.0f);
	glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
	
	gl::setMatricesWindow( mSSAOMap.getSize() );
	
	mRandomNoise.bind(1);
	mNormalDepthMap.getTexture().bind(2);
	
	mSSAOShader.bind();
	
	mSSAOShader.uniform("rnm", 1 );
	mSSAOShader.uniform("normalMap", 2 );
    
    //look at shader and see you can set these through the client if you so desire.
    //	mSSAOShader.uniform("rnm", 1 );
    //	mSSAOShader.uniform("normalMap", 2 );	
    //	mSSAOShader.uniform("totStrength", 1.38f);
    //	mSSAOShader.uniform("strength", 0.07f);
    //	mSSAOShader.uniform("offset", 10.0f);
    //	mSSAOShader.uniform("falloff", 0.2f);
    //	mSSAOShader.uniform("rad", 0.8f);
    
    //	mSSAOShader.uniform("rnm", 1 );
    //	mSSAOShader.uniform("normalMap", 2 );
    //	mSSAOShader.uniform("farClipDist", 20.0f);
    //	mSSAOShader.uniform("screenSizeWidth", (float)getWindowWidth());
    //	mSSAOShader.uniform("screenSizeHeight", (float)getWindowHeight());
	
    //	mSSAOShader.uniform("grandom", 1 );
    //	mSSAOShader.uniform("gnormals", 2 );
    //	mSSAOShader.uniform("gdepth", 1 );
    //	mSSAOShader.uniform("gdiffuse", 1 );
    
    gl::drawSolidRect( Rectf( 0, 0, getWindowWidth(), getWindowHeight()) );
	
	mSSAOShader.unbind();
	
	mNormalDepthMap.getTexture().unbind(2);
	mRandomNoise.unbind(1);
	
	mSSAOMap.unbindFramebuffer();
	
	gl::setViewport( getWindowBounds() );
}
Beispiel #11
0
void syphonImpApp::renderSceneToFbo()
{
	// this will restore the old framebuffer binding when we leave this function
	// on non-OpenGL ES platforms, you can just call mFbo.unbindFramebuffer() at the end of the function
	// but this will restore the "screen" FBO on OpenGL ES, and does the right thing on both platforms
	gl::SaveFramebufferBinding bindingSaver;
	
	// bind the framebuffer - now everything we draw will go there
	myFbo.bindFramebuffer();
    gl::setViewport(myFbo.getBounds() );
    gl::setMatricesWindow( myFbo.getSize(), false );
	
	// clear out the FBO with blue
	gl::clear();
   mParticleController.update();
    mParticleController.draw();
    
}
void	KinectEcard::snapshot(){
	gl::Fbo fbo( 640, 480, false );

	// render stored depth FBO
	fbo.bindFramebuffer();
	gl::pushMatrices();
		gl::clear( Color::black() );
		gl::color( Color::white() );
		gl::setMatricesWindowPersp( fbo.getSize() );

		mDepthCompareShader.bind();

		mDepthCompareShader.uniform( "tex0", 0 );
		mDepthCompareShader.uniform( "tex1", 1 );

		mDepthFbo.bindTexture(0);
		mStoredDepthFbo.bindTexture(1);

		gl::translate( 0, 480 );
		gl::scale( 1, -1 );

		gl::drawSolidRect( fbo.getBounds() );

		mDepthCompareShader.unbind();
	gl::popMatrices();
	fbo.unbindFramebuffer();

	// save stored depth fbo
	fbo.blitTo( mStoredDepthFbo, fbo.getBounds(), mStoredDepthFbo.getBounds() );

	// render substracted video fbo
	fbo.bindFramebuffer();
	gl::pushMatrices();
		gl::clear( Color::black() );
		gl::color( Color::white() );
		gl::setMatricesWindowPersp( mSubstractedVideoFbo.getSize() );
		gl::draw( mSubstractedVideoFbo.getTexture() );
	gl::popMatrices();
	fbo.unbindFramebuffer();

	// save it
	fbo.blitTo( mStoredVideoFbo, fbo.getBounds(), mStoredVideoFbo.getBounds() );
}
Beispiel #13
0
void StarsApp::createFbo()
{
	// determine the size of the frame buffer
	int w = getWindowWidth() * 2;
	int h = getWindowHeight() * 2;

	if( mFbo && mFbo.getSize() == Vec2i(w, h) )
		return;

	// create the FBO
	gl::Fbo::Format fmt;
	fmt.setWrap( GL_REPEAT, GL_CLAMP_TO_BORDER );
	
	mFbo = gl::Fbo( w, h, fmt );

	// work-around for the flipped texture issue
	mFbo.getTexture().setFlipped();
	mFbo.getDepthTexture().setFlipped();
}
Beispiel #14
0
void Grove::copyBlur(gl::Fbo& source, gl::Fbo& target, Vec2f sampleOffset)
{
	// bind the blur shader
	mBlurShader.bind();
	mBlurShader.uniform("tex0", 0); // use texture unit 0
	mBlurShader.uniform("sampleOffset", sampleOffset);

	// copy a horizontally blurred version of our scene into the first blur Fbo
	gl::setViewport( target.getBounds() );
	target.bindFramebuffer();
		source.bindTexture(0);
		gl::pushMatrices();
		gl::setMatricesWindow(target.getSize(), false);
			gl::clear( Color::black() );
			gl::drawSolidRect( target.getBounds() );
		gl::popMatrices();
		source.unbindTexture();
	target.unbindFramebuffer();	

	// unbind the shader
	mBlurShader.unbind();
}
void SmoothDisplacementMappingApp::renderNormalMap()
{
	if( mNormalMapShader && mNormalMapFbo ) 
	{
		mNormalMapFbo.bindFramebuffer();
		{
			// setup viewport and matrices 
			glPushAttrib( GL_VIEWPORT_BIT );
			gl::setViewport( mNormalMapFbo.getBounds() );

			gl::pushMatrices();
			gl::setMatricesWindow( mNormalMapFbo.getSize(), false );

			// clear the color buffer
			gl::clear();			

			// bind the displacement map
			mDispMapFbo.getTexture().bind(0);

			// render the normal map
			mNormalMapShader.bind();
			mNormalMapShader.uniform( "texture", 0 );
			mNormalMapShader.uniform( "amplitude", 4.0f );

			Area bounds = mNormalMapFbo.getBounds(); //bounds.expand(-1, -1);
			gl::drawSolidRect( bounds );

			mNormalMapShader.unbind();

			// clean up after ourselves
			mDispMapFbo.getTexture().unbind();

			gl::popMatrices();

			glPopAttrib();
		}
		mNormalMapFbo.unbindFramebuffer();
	}
}
void KinectEcard::renderVideo(){
	if( !mVideoSurface )
		return;

	gl::pushMatrices();
	{
		//
		mVideoFbo.bindFramebuffer();

		// clear FBO
		gl::clear( Color::black() );
		gl::color( Color::white() );

		// 
		gl::Texture tex0( mVideoSurface );
		gl::Texture tex1( mCorrectionMap );

		mDepthCorrectionShader.bind();
		mDepthCorrectionShader.uniform( "tex0", 0 );
		mDepthCorrectionShader.uniform( "tex1", 1 );

		tex0.bind(0);
		tex1.bind(1);

		gl::setMatricesWindowPersp( mVideoFbo.getSize() );

		// draw video surface
		gl::drawSolidRect( mVideoFbo.getBounds() );
		//gl::draw( mCorrectionMap );

		mDepthCorrectionShader.unbind();

		mVideoFbo.unbindFramebuffer();
	}
	gl::popMatrices();
	
}
Beispiel #17
0
void ChargesApp::draw()
{
	mFbo.bindFramebuffer();
	gl::setViewport( mFbo.getBounds() );
	gl::setMatricesWindow( mFbo.getSize() );

	gl::clear( Color::black() );
	mEffectCharge.setLineWidth( mLineWidth );
	mEffectCharge.draw();

	mFbo.unbindFramebuffer();

	gl::color( Color::white() );
	gl::Texture output = mKawaseBloom.process( mFbo.getTexture(), 8, mBloomStrength );

	gl::setViewport( getWindowBounds() );
	gl::setMatricesWindow( getWindowSize() );

	gl::clear( Color::black() );
	gl::color( Color::white() );
	gl::draw( output, getWindowBounds() );

	mndl::kit::params::PInterfaceGl::draw();
}
void KinectEcard::renderSubstractedVideo(){
	mSubstractedVideoFbo.bindFramebuffer();

	gl::pushMatrices();
	{
		// clear FBO
		gl::clear( Color::black() );
		gl::color( Color::white() );

		//
		gl::setMatricesWindowPersp( mSubstractedVideoFbo.getSize() );

		mSubstractShader.bind();
		mSubstractShader.uniform( "tex0", 0 );
		mSubstractShader.uniform( "tex1", 1 );
		mSubstractShader.uniform( "tex2", 2 );
		mSubstractShader.uniform( "tex3", 3 );

		mVideoFbo.bindTexture(0);
		mDepthFbo.bindTexture(1);
		mStoredVideoFbo.bindTexture(2);
		mStoredDepthFbo.bindTexture(3);
		
		gl::drawSolidRect( mSubstractedVideoFbo.getBounds() );

		mVideoFbo.unbindTexture();
		mDepthFbo.unbindTexture();
		mStoredVideoFbo.unbindTexture();
		mStoredDepthFbo.unbindTexture();

		mSubstractShader.unbind();
	}
	gl::popMatrices();

	mSubstractedVideoFbo.unbindFramebuffer();
}
Beispiel #19
0
void ChargesApp::update()
{
	mFps = getAverageFps();

	// Update device
	if ( mLeap && mLeap->isConnected() )
	{
		mLeap->update();
	}

	vector< int32_t > currentFingersIds;

	for ( const std::pair< int32_t, LeapSdk::Hand > hand : mHands )
	{
		const LeapSdk::FingerMap &fingers = hand.second.getFingers();
		for ( const auto &fkv : fingers )
		{
			int32_t id = fkv.first;
			const LeapSdk::Finger &finger = fkv.second;

			currentFingersIds.push_back( id );

			// new finger?
			if ( mActiveFingers.find( id ) == mActiveFingers.end() )
			{
				mActiveFingers[ id ] = mTimestamp;
				mEffectCharge.addCursor( id, 0.f, 0.f, 1.f ); // init with (0, 0), will be updated below
			}

			// update finger
			const LeapSdk::ScreenMap &screens = mLeap->getScreens();
			if ( screens.begin() != screens.end() )
			{
				mActiveFingers[ id ] = mTimestamp;

				const LeapSdk::Screen &screen = screens.begin()->second;
				Vec3f normPos;
				screen.intersects( finger, normPos, true, 1.5f ); // normalized screen coordinates with 1.5 clamp ratio
				Vec2f fingertip = normPos.xy() * Vec2f( mFbo.getSize() );

				Vec3f screenPos;
				screen.intersects( finger, screenPos, false, 1.5f ); // screen coordinates with 1.5 clamp ratio
				float d = screenPos.distance( finger.getPosition() );
				const float dMin = 50.f;
				const float dMax = 500.f;
				const float sMin = 1.f;
				const float sMax = 100.f;
				d = math< float >::clamp( d, dMin, dMax );
				float strength = lmap( d, dMin, dMax, sMax, sMin );

				mEffectCharge.updateCursor( id, fingertip.x, fingertip.y, strength );
			}
		}
	}

	// erase disappeared fingers
	int64_t disappearThr = mFingerDisapperanceThreshold * 1000000;
	for ( auto it = mActiveFingers.begin(); it != mActiveFingers.end(); )
	{
		int32_t id = it->first;
		if ( find( currentFingersIds.begin(), currentFingersIds.end(), id ) == currentFingersIds.end() )
		{
			// seen earlier than the threshold?
			if ( mTimestamp - it->second > disappearThr )
			{
				mEffectCharge.removeCursor( id );
				it = mActiveFingers.erase( it );
			}
			else
			{
				it++;
			}
		}
		else
		{
			it++;
		}
	}
}
Beispiel #20
0
void FolApp::draw()
{
    gl::clear( Color::black() );

    if ( !mDepthTexture )
        return;

    // blur depth
    mDepthFbo.bindFramebuffer();
    gl::setMatricesWindow( mDepthFbo.getSize(), false );
    gl::setViewport( mDepthFbo.getBounds() );

    mBlurShader.bind();

    mBlurShader.uniform( "kernelSize", (float)mBlurKernelTexture.getWidth() );
    mBlurShader.uniform( "invKernelSize", 1.f / mBlurKernelTexture.getWidth() );
    mBlurShader.uniform( "imageTex", 0 );
    mBlurShader.uniform( "kernelTex", 1 );
    mBlurShader.uniform( "blurAmount", mBlurAmount );

    // pass 1
    glDrawBuffer( GL_COLOR_ATTACHMENT0_EXT );

    //gl::enable( GL_TEXTURE_2D );
    mDepthTexture.bind( 0 );
    mBlurKernelTexture.bind( 1 );
    mBlurShader.uniform( "stepVector", Vec2f( 1. / mDepthTexture.getWidth(), 0. ) );

    gl::drawSolidRect( mDepthFbo.getBounds() );

    mDepthTexture.unbind();

    // pass 2
    glDrawBuffer( GL_COLOR_ATTACHMENT1_EXT );

    mDepthFbo.bindTexture( 0 );
    mBlurShader.uniform( "stepVector", Vec2f( 0., 1. / mDepthFbo.getHeight() ) );
    gl::drawSolidRect( mDepthFbo.getBounds() );

    mDepthFbo.unbindTexture();
    mBlurKernelTexture.unbind();
    mBlurShader.unbind();

    mDepthFbo.unbindFramebuffer();

    // wave output
    mOutputFbo.bindFramebuffer();
    gl::setMatricesWindow( mOutputFbo.getSize(), false );
    gl::setViewport( mOutputFbo.getBounds() );

    gl::clear( Color::black() );
    gl::disableDepthRead();
    gl::disableDepthWrite();

    gl::enableAdditiveBlending();
    gl::color( ColorA( 1, 1, 1, .0195 ) );

    gl::pushMatrices();
    gl::scale( Vec2f( getWindowWidth() / (float)VBO_X_SIZE,
                      getWindowHeight() / (float)VBO_Y_SIZE) );

    mDepthFbo.getTexture( 1 ).bind();
    mWaveShader.bind();
    mWaveShader.uniform( "tex", 0 );
    mWaveShader.uniform( "invSize", Vec2f( mStep / mDepthFbo.getWidth(),
                                           mStep / mDepthFbo.getHeight() ) );
    mWaveShader.uniform( "clip", mClip );
    gl::draw( mVboMesh );
    mWaveShader.unbind();

    gl::popMatrices();

    gl::disableAlphaBlending();
    mOutputFbo.unbindFramebuffer();

    // bloom
    mBloomFbo.bindFramebuffer();

    gl::setMatricesWindow( mBloomFbo.getSize(), false );
    gl::setViewport( mBloomFbo.getBounds() );

    gl::color( Color::white() );
    mOutputFbo.getTexture().bind();

    mBloomShader.bind();
    for (int i = 0; i < 8; i++)
    {
        glDrawBuffer( GL_COLOR_ATTACHMENT0_EXT + i );
        mBloomShader.uniform( "iteration", i );
        gl::drawSolidRect( mBloomFbo.getBounds() );
        mBloomFbo.bindTexture( 0, i );
    }
    mBloomShader.unbind();

    glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
    mBloomFbo.unbindFramebuffer();

    // output mixer
    gl::setMatricesWindow( getWindowSize() );
    gl::setViewport( getWindowBounds() );

    mMixerShader.bind();

    gl::enable( GL_TEXTURE_2D );

    mOutputFbo.getTexture().bind( 0 );
    for (int i = 0; i < 8; i++)
    {
        mBloomFbo.getTexture( i ).bind( i + 1 );
    }

    gl::drawSolidRect( mOutputFbo.getBounds() );
    gl::disable( GL_TEXTURE_2D );
    mMixerShader.unbind();

    //gl::draw( mOutputFbo.getTexture(), getWindowBounds() );
    //gl::draw( mDepthFbo.getTexture( 1 ), getWindowBounds() );

    params::InterfaceGl::draw();
}