예제 #1
0
void MotionBlurVelocityBufferApp::dilateVelocity()
{
    gl::ScopedFramebuffer fbo( mVelocityDilationBuffer );
    gl::ScopedViewport viewport( ivec2( 0, 0 ), mVelocityDilationBuffer->getSize() );
    gl::ScopedMatrices	matrices;
    gl::setMatricesWindowPersp( mVelocityDilationBuffer->getSize() );

    {   // downsample velocity into tilemax
        gl::ScopedTextureBind tex( mGBuffer->getTexture2d( G_VELOCITY ), 0 );
        gl::ScopedGlslProg prog( mTileProg );
        gl::drawBuffer( DILATE_TILE_MAX );

        mTileProg->uniform( "uVelocityMap", 0 );
        mTileProg->uniform( "uTileSize", mTileSize );

        gl::drawSolidRect( mVelocityDilationBuffer->getBounds() );
    }
    {   // build max neighbors from tilemax
        gl::ScopedTextureBind tex( mVelocityDilationBuffer->getTexture2d( DILATE_TILE_MAX ), 0 );
        gl::ScopedGlslProg prog( mNeighborProg );
        gl::drawBuffer( DILATE_NEIGHBOR_MAX );

        mNeighborProg->uniform( "uTileMap", 0 );

        gl::drawSolidRect( mVelocityDilationBuffer->getBounds() );
    }
}
예제 #2
0
void MotionBlurVelocityBufferApp::drawBlurredContent()
{
    gl::ScopedTextureBind colorTex( mGBuffer->getTexture2d( G_COLOR ), 0 );
    gl::ScopedTextureBind velTex( mGBuffer->getTexture2d( G_VELOCITY ), 1 );
    gl::ScopedTextureBind neigborTex( mVelocityDilationBuffer->getTexture2d( DILATE_NEIGHBOR_MAX ), 2 );
    gl::ScopedGlslProg prog( mMotionBlurProg );
    gl::ScopedBlendPremult blend;

    mMotionBlurProg->uniform( "uColorMap", 0 );
    mMotionBlurProg->uniform( "uVelocityMap", 1 );
    mMotionBlurProg->uniform( "uNeighborMaxMap", 2 );
    mMotionBlurProg->uniform( "uNoiseFactor", mBlurNoise );
    mMotionBlurProg->uniform( "uSamples", mSampleCount );

    gl::drawSolidRect( getWindowBounds() );
}
void FboMultipleRenderTargetsApp::draw()
{
	gl::clear( Color::gray( 0.35f ) );

	gl::setMatricesWindow( getWindowSize() );

	// draw the two textures we've created side-by-side
	auto tex0 = mFbo->getTexture2d( GL_COLOR_ATTACHMENT0 );
	auto tex1 = mFbo->getTexture2d( GL_COLOR_ATTACHMENT1 );
	gl::draw( tex0, tex0->getBounds() );
	gl::draw( tex1, tex1->getBounds() + vec2( tex1->getWidth(), 0 ) );
}
예제 #4
0
void MotionBlurVelocityBufferApp::drawVelocityBuffers()
{
    gl::ScopedGlslProg prog( mVelocityRenderProg );
    gl::ScopedModelMatrix matrix;
    gl::setDefaultShaderVars();

    float width = 200.0f;
    float height = width / Rectf( mVelocityDilationBuffer->getBounds() ).getAspectRatio();
    Rectf rect( 0.0f, 0.0f, width, height );

    gl::ScopedTextureBind velTex( mGBuffer->getTexture2d( G_VELOCITY ), 0 );
    gl::translate( getWindowWidth() - width - 10.0f, 10.0f );
    gl::drawSolidRect( rect );

    gl::ScopedTextureBind tileTex( mVelocityDilationBuffer->getTexture2d( DILATE_TILE_MAX ), 0 );
    gl::translate( 0.0f, height + 10.0f );
    gl::drawSolidRect( rect );

    gl::ScopedTextureBind neigborTex( mVelocityDilationBuffer->getTexture2d( DILATE_NEIGHBOR_MAX ), 0 );
    gl::translate( 0.0f, height + 10.0f );
    gl::drawSolidRect( rect );
}