Commit 8411700e authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[ADD #312] Image Overlay for a WGEViewer. Disabled code until there is a configure option for it

parent 6b0f9ef7
......@@ -167,7 +167,6 @@ void WGEViewer::setScene( osg::ref_ptr< WGEGroupNode > node )
// vignetting cam
{
/*
osg::ref_ptr< osg::Camera > bkCam = new osg::Camera();
bkCam->setClearMask( GL_DEPTH_BUFFER_BIT );
bkCam->setRenderOrder( osg::Camera::POST_RENDER );
......@@ -191,7 +190,43 @@ void WGEViewer::setScene( osg::ref_ptr< WGEGroupNode > node )
// add the slice to the geode
bkCam->addChild( geode );
node->insert( bkCam );
*/
}
// overlay texture cam
{
osg::ref_ptr< osg::Camera > bkCam = new osg::Camera();
bkCam->setClearMask( GL_DEPTH_BUFFER_BIT );
bkCam->setRenderOrder( osg::Camera::POST_RENDER );
bkCam->setReferenceFrame( osg::Transform::ABSOLUTE_RF );
bkCam->setProjectionMatrixAsOrtho2D( 0.0, 1.0, 0.0, 1.0 );
bkCam->setViewMatrix( osg::Matrixd::identity() );
osg::StateSet* state = bkCam->getOrCreateStateSet();
state->setMode( GL_DEPTH_TEST, osg::StateAttribute::OFF );
state->setMode( GL_LIGHTING, osg::StateAttribute::PROTECTED );
state->setMode( GL_LIGHTING, osg::StateAttribute::OFF );
state->setMode( GL_BLEND, osg::StateAttribute::PROTECTED );
state->setMode( GL_BLEND, osg::StateAttribute::ON );
osg::ref_ptr< osg::Geode > geode = wge::genFinitePlane( osg::Vec3( 0.0, 0.0, 0.0 ),
osg::Vec3( 1.0, 0.0, 0.0 ),
osg::Vec3( 0.0, 1.0, 0.0 ) );
osg::ref_ptr< WGEShader > vignetteShader = new WGEShader( "WGECameraOverlayTexture" );
vignetteShader->apply( geode );
// some logo
osg::ref_ptr< osg::Texture2D > logoTexture = new osg::Texture2D;
osg::Image* logoImage = osgDB::readImageFile( "/home/seth/CameraOverlay.png" );
if ( logoImage )
{
// Assign the texture to the image we read from file:
logoTexture->setImage( logoImage );
state->setTextureAttributeAndModes( 0, logoTexture, osg::StateAttribute::ON );
}
// add the slice to the geode
bkCam->addChild( geode );
node->insert( bkCam );
}
// horizon background cam
......
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV-Leipzig and CNCF-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#version 120
/**
* Overlay texture
*/
uniform sampler2D u_overlay;
/**
* Pixel position in [0,1]
*/
varying vec2 v_pos;
void main()
{
// overlay texture
vec4 tex = texture2D( u_overlay, v_pos * 3 );
// use texture coordinate to mix along the cylinder
gl_FragColor = vec4( tex );
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV-Leipzig and CNCF-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#version 120
/**
* Pixel position in [0,1]
*/
varying vec2 v_pos;
void main()
{
v_pos = gl_MultiTexCoord0.st;
// apply standard pipeline
gl_FrontColor = gl_Color;
gl_Position = ftransform();
}
......@@ -24,6 +24,9 @@
#version 120
/**
* Intensity of effect
*/
uniform float u_vignetteIntensity = 0.5;
/**
......@@ -33,16 +36,14 @@ varying vec2 v_pos;
void main()
{
vec3 color = vec3( 0.0, 0.0, 0.0 );
float alpha = 0.0;
// Basically, use a unit circle and shade alpha when nearing radius 1
vec2 posInUnitCircle = 2.0 * ( v_pos - 0.5 );
float xsqr = posInUnitCircle.x * posInUnitCircle.x;
float ysqr = posInUnitCircle.y * posInUnitCircle.y;
alpha = u_vignetteIntensity * ( xsqr * ysqr );
// intensity of the vignette
float alpha = u_vignetteIntensity * ( xsqr * ysqr );
// use texture coordinate to mix along the cylinder
gl_FragColor = vec4( color, alpha );
gl_FragColor = vec4( vec3( 0.0 ), alpha );
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment