Commit 51c133ed authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[DOC] added some examples how to achieve high-resolution offscreen rendering...

[DOC] added some examples how to achieve high-resolution offscreen rendering and finally tiling it to the screen
parent 40f51308
......@@ -28,8 +28,6 @@
#include <osg/Camera>
#include <osg/Node>
/**
* This callback is useful to update viewport information on several nodes supporting it. The specified type must support an setViewport method.
* This is especially useful to keep offscreen render cameras in sync with the scene cam or to update HUD viewport information. Note that the
......@@ -91,6 +89,8 @@ void WGEViewportCallback< T, Source >::operator()( osg::Node* node, osg::NodeVis
if( t )
{
t->setViewport( m_reference->getViewport() );
// NOTE: you want to use a fixed size for the offscreen textures? Try this:
// t->setViewport( new osg::Viewport( 0, 0, 3840, 2160 ) );
}
traverse( node, nv );
}
......
......@@ -97,16 +97,44 @@ float getDepth( in vec2 where )
*/
void main()
{
// don't do this stuff for background pixel
float depth = getDepth( pixelCoord );
gl_FragDepth = depth;
vec2 coord = pixelCoord;
float depth = getDepth( coord );
// interested in rendering only a part of the final texture?
#ifdef TILED
// modify the pixel coordinate and assume a 3x3 tiled texture you want to use
// -> pick the tiles accordingly by
coord +=
vec2( 0./3., 0./3. );
//vec2( 1./3., 0./3. );
//vec2( 2./3., 0./3. );
//vec2( 0./3., 1./3. );
//vec2( 1./3., 1./3. );
//vec2( 2./3., 1./3. );
//vec2( 0./3., 2./3. );
//vec2( 1./3., 2./3. );
//vec2( 2./3., 2./3. );
#endif
// interested in having a color gradient in your final image?
#ifdef BG_GRADIENT
if( depth > 0.99 )
{
vec3 colorBottom = vec3( 0.0 );
vec3 colorTop = vec3( 0.2, 0.2, 0.2 );
gl_FragColor = vec4( mix( colorBottom, colorTop, coord.y ), 1.0 );
return;
}
#else
// avoid drawing any pixels which are "empty" in the source data
if( depth > 0.99 )
{
discard;
}
#endif
// output the depth and final color.
gl_FragColor = getColor( pixelCoord );
gl_FragColor = getColor( coord );
}
#endif // WGEPOSTPROCESSORCOMBINER_FRAGMENT_GLSL
......
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