Commit fa73012c authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[CHANGE] the parameter texture in the postprocessing pipeline is now a float texture

parent f4757136
......@@ -135,6 +135,37 @@ osg::ref_ptr< osg::Texture2D > WGEOffscreenRenderPass::createTexture( GLint inte
tex->setTextureSize( m_width, m_height );
tex->setInternalFormat( internalFormat );
switch( internalFormat )
{
case GL_R16F:
tex->setSourceType( GL_HALF_FLOAT );
tex->setSourceFormat( GL_RED );
break;
case GL_R32F:
tex->setSourceType( GL_FLOAT );
tex->setSourceFormat( GL_RED );
break;
case GL_RGB16F:
tex->setSourceType( GL_HALF_FLOAT );
tex->setSourceFormat( GL_RGB );
break;
case GL_RGBA16F:
tex->setSourceType( GL_HALF_FLOAT );
tex->setSourceFormat( GL_RGBA );
break;
case GL_RGB32F:
tex->setSourceType( GL_FLOAT );
tex->setSourceFormat( GL_RGB );
break;
case GL_RGBA32F:
tex->setSourceType( GL_FLOAT );
tex->setSourceFormat( GL_RGBA );
break;
default:
// keep default format and type
break;
}
// setup interpolation
tex->setFilter( osg::Texture::MIN_FILTER, osg::Texture::LINEAR );
tex->setFilter( osg::Texture::MAG_FILTER, osg::Texture::LINEAR );
......
......@@ -124,7 +124,7 @@ WGEPostprocessor::PostprocessorInput WGEPostprocessor::PostprocessorInput::attac
PostprocessorInput buf;
buf.m_colorTexture = from->attach( osg::Camera::COLOR_BUFFER0 );
buf.m_normalTexture = from->attach( osg::Camera::COLOR_BUFFER1, GL_RGB );
buf.m_parameterTexture = from->attach( osg::Camera::COLOR_BUFFER2, GL_LUMINANCE );
buf.m_parameterTexture = from->attach( osg::Camera::COLOR_BUFFER2, GL_R32F );
buf.m_tangentTexture = from->attach( osg::Camera::COLOR_BUFFER3, GL_RGB );
buf.m_depthTexture = from->attach( osg::Camera::DEPTH_BUFFER );
......
......@@ -295,8 +295,6 @@ float getSSAO()
//
// - This implementation matches the paper in most cases. We made some additional improvements and
// simplifications here. This simply is due to the time-lag between first submission and final acceptance.
// - The paper proposes to use a gaussed version of the depth and normal maps. We skip this step here. This way,
// the images look more crispy and provide more _local_ detail.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
......
......@@ -165,12 +165,13 @@ vec4 getColor( in vec2 where, in float lod = 0.0 )
* Returns the original unprocessed color value at the current pixel.
*
* \note GLSL does not officially allow default values for function arguments which is why we need this additional function.
* \param lod the LOD level if using mip-maps.
*
* \return the color
*/
vec4 getColor()
vec4 getColor( in float lod = 0.0 )
{
return getColor( pixelCoord );
return getColor( pixelCoord, lod );
}
/**
......@@ -190,12 +191,13 @@ vec4 getNormal( in vec2 where, in float lod = 0.0 )
* Grabs the normal at the current pixel. The returned normal has been de-scaled to [-1,1]. The w component is 1.
*
* \note GLSL does not officially allow default values for function arguments which is why we need this additional function.
* \param lod the LOD level if using mip-maps.
*
* \return the normal
*/
vec4 getNormal()
vec4 getNormal( in float lod = 0.0 )
{
return getNormal( pixelCoord );
return getNormal( pixelCoord, lod );
}
/**
......@@ -216,11 +218,13 @@ vec4 getTangent( in vec2 where, in float lod = 0.0 )
*
* \note GLSL does not officially allow default values for function arguments which is why we need this additional function.
*
* \param lod the LOD level if using mip-maps.
*
* \return the normal
*/
vec4 getTangent()
vec4 getTangent( in float lod = 0.0 )
{
return getNormal( pixelCoord );
return getTangent( pixelCoord, lod );
}
/**
......@@ -241,11 +245,13 @@ float getDepth( in vec2 where, in float lod = 0.0 )
*
* \note GLSL does not officially allow default values for function arguments which is why we need this additional function.
*
* \param lod the LOD level if using mip-maps.
*
* \return the depth
*/
float getDepth()
float getDepth( in float lod = 0.0 )
{
return getDepth( pixelCoord );
return getDepth( pixelCoord, lod );
}
/**
......@@ -257,8 +263,7 @@ float getDepth()
*/
float getZoom( in vec2 where )
{
// TODO(ebaum): somehow remove this scaler
return texture2D( u_parameterSampler, pixelCoord ).r * 10.0;
return texture2D( u_parameterSampler, pixelCoord ).r;
}
/**
......
......@@ -133,7 +133,7 @@ void main()
// let it point towards the camera
v_normalWorld *= sign( dot( normalize( v_normalWorld ), vec3( 0.0, 0.0, 1.0 ) ) );
v_worldScale = 0.1 * getModelViewScale();
v_worldScale = getModelViewScale();
// vertex 1
gl_TexCoord[0] = vec4( -1.0, -1.0, 0.0, angle );
......
......@@ -138,7 +138,7 @@ void main()
wgeInitGBuffer();
wge_FragColor = vec4( vec3( light * finalColor.xyz * colorScaler ), finalColor.a );
wge_FragNormal = textureNormalize( normal );
wge_FragZoom = 0.1 * v_worldScale;
wge_FragZoom = v_worldScale;
wge_FragTangent = textureNormalize( v_tangent );
gl_FragDepth = depth;
}
......
......@@ -144,7 +144,7 @@ void main()
gl_FragDepth = 1.0;
#ifdef WGE_POSTPROCESSING_ENABLED
wge_FragZoom = 0.1 * v_worldScale;
wge_FragZoom = v_worldScale;
#endif
// please do not laugh, it is a very very very simple "isosurface" shader
......
......@@ -83,8 +83,7 @@ void main()
#ifdef WGE_POSTPROCESSING_ENABLED
// Keep track of scaling information. This is needed by some postprocessors.
// TODO(ebaum): I do not yet understand this factor! Fix this.
v_worldScale = 0.015 * getModelViewScale();
v_worldScale = getModelViewScale();
#endif
// Simply project the vertex
......
......@@ -117,7 +117,7 @@ void main()
wgeInitGBuffer();
wge_FragColor = vec4( gl_Color.rgb * r, 1.0 );
wge_FragNormal = textureNormalize( sphereSurf );
wge_FragZoom = 0.1 * v_worldScale;
wge_FragZoom = v_worldScale;
wge_FragTangent = textureNormalize( vec3( 0.0, 1.0, 0.0 ) );
#ifdef DEPTHWRITE_ENABLED
// we allow to disable depth write. This allows the GPU to disacard pixels before applying the fragment shader -> speedup
......
......@@ -264,7 +264,7 @@ void main( void )
// finally set the color and depth
wgeInitGBuffer();
wge_FragNormal = textureNormalize( normal );
wge_FragZoom = 0.1 * v_worldScale;
wge_FragZoom = v_worldScale;
wge_FragTangent = textureNormalize( vec3( 0.0, 1.0, 0.0 ) );
// draw shaded pixel
......
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