Commit 98bb0913 by ledig

[ADD] cmake flag to compile ow for low end graphics cards, at least navslices work there now

parent b32ffe08
......@@ -50,6 +50,8 @@ IF( PYTHONINTERP_FOUND )
ENDIF(NOT EXISTS "${PCH_INCLUDE_FILE}")
ENDIF( PYTHONINTERP_FOUND )
OPTION( OW_BUILD_FORLOWEND_GRAPHICS "Build OW so that nav slices work on older graphics cards" OFF )
# define libnames with small suffix letters because GCC does not cope with -DOWLibname_Exports
IF( OW_BUILD_WITH_PCH AND NOT OW_BUILD_AS_ONE_BIG_FILE AND CMAKE_COMPILER_IS_GNUCXX )
SET( OWCommonName "_OWcommon" )
......@@ -238,6 +240,10 @@ IF( CMAKE_GENERATOR MATCHES "Visual Studio" )
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"NOMINMAX\"" )
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /wd4101" )
SET( CMAKE_DEBUG_POSTFIX "d" CACHE STRING "add a postfix, usually d on windows" )
IF( OW_BUILD_FORLOWEND_GRAPHICS )
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"LOWGRAPHICS\"" )
ENDIF( OW_BUILD_FORLOWEND_GRAPHICS )
ELSE()
# Unfortunately libstdc++'s header files don't work with mingw in ansi mode (basically libstdc++'s fault)
IF( CMAKE_HOST_SYSTEM MATCHES "Windows" )
......@@ -254,6 +260,9 @@ ELSE()
ENDIF()
SET( CMAKE_CXX_FLAGS_RELEASE "-O3" CACHE STRING "" FORCE )
SET( CMAKE_CXX_FLAGS_DEBUG "-g -DDEBUG -O0" CACHE STRING "" FORCE )
IF( OW_BUILD_FORLOWEND_GRAPHICS )
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLOWGRAPHICS" )
ENDIF( OW_BUILD_FORLOWEND_GRAPHICS )
ENDIF()
SET( CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -DDEBUG -O2" CACHE STRING "" FORCE )
......
......@@ -61,6 +61,9 @@ WDataTexture3D::WDataTexture3D( boost::shared_ptr<WValueSetBase> valueSet, boost
" than 2048 pixels/voxels in one dimension." );
WAssert( m_grid->getNbCoordsZ() <= wlimits::MAX_TEXTURE_DIMENSION, "Cannot create a texture with more"
" than 2048 pixels/voxels in one dimension." );
#ifdef LOWGRAPHICS
scaleTexture();
#endif
}
WDataTexture3D::~WDataTexture3D()
......@@ -535,4 +538,111 @@ boost::shared_ptr< WProperties > WDataTexture3D::getInformationProperties() cons
return m_infoProperties;
}
// note (ledig): sry for macro but its no fun fixing the same code again and again
#define DATADEP_SCALE( data_type ) \
boost::shared_ptr< WValueSet< data_type > > vs = boost::shared_dynamic_cast< WValueSet< data_type > >( m_valueSet ); \
boost::shared_ptr< std::vector< data_type > > data = boost::shared_ptr< std::vector< data_type > >( \
new std::vector< data_type >( newsizeX * newsizeY * newsizeZ ) \
); \
newvalueSet = boost::shared_ptr< WValueSet< data_type > >( \
new WValueSet< data_type >( vs->order(), vs->dimension(), data, vs->getDataType() \
) \
); \
\
data_type* source = const_cast< data_type* > ( vs->rawData() ); \
data_type* dest = const_cast< data_type* > ( boost::shared_dynamic_cast< WValueSet< data_type > >( newvalueSet )->rawData() ); \
\
size_t x; \
size_t y; \
size_t z; \
double orgx = 0.0; \
double orgy = 0.0; \
double orgz = 0.0; \
size_t newcellId = 0; \
size_t orgId; \
for ( z = 0; z < newsizeZ; ++z ) \
{ \ // NOLINT
orgy = 0.0; \
for ( y = 0; y < newsizeY; ++y ) \
{ \ // NOLINT
orgx = 0.0; \
for ( x = 0; x < newsizeX; ++x ) \
{ \ // NOLINT
orgId = floor( orgx ) + floor( orgy ) * orgsizeX + floor( orgz ) * orgsizeX * orgsizeY; \
\
dest[ newcellId ] = source[ orgId ]; \
\
++newcellId; \
orgx += invscaleX; \
} \ // NOLINT
orgy += invscaleY; \
} \ // NOLINT
orgz += invscaleZ; \
}
void WDataTexture3D::scaleTexture()
{
// note this function might not be correct for dimensions above 1
unsigned int orgsizeX = m_grid->getNbCoordsX();
unsigned int orgsizeY = m_grid->getNbCoordsY();
unsigned int orgsizeZ = m_grid->getNbCoordsZ();
unsigned int newsizeX = 1;
unsigned int newsizeY = 1;
unsigned int newsizeZ = 1;
while ( newsizeX < orgsizeX )
{
newsizeX <<= 1;
}
while ( newsizeY < orgsizeY )
{
newsizeY <<= 1;
}
while ( newsizeZ < orgsizeZ )
{
newsizeZ <<= 1;
}
double invscaleX = static_cast< double >( orgsizeX ) / static_cast< double >( newsizeX );
double invscaleY = static_cast< double >( orgsizeY ) / static_cast< double >( newsizeY );
double invscaleZ = static_cast< double >( orgsizeZ ) / static_cast< double >( newsizeZ );
boost::shared_ptr< WGridRegular3D > newgrid = boost::shared_ptr< WGridRegular3D >(
new WGridRegular3D( newsizeX, newsizeY, newsizeZ,
m_grid->getOffsetX() * invscaleX,
m_grid->getOffsetY() * invscaleY,
m_grid->getOffsetZ() * invscaleZ )
);
boost::shared_ptr< WValueSetBase > newvalueSet;
if ( m_valueSet->getDataType() == W_DT_UINT8 )
{
DATADEP_SCALE( uint8_t )
}
else if ( m_valueSet->getDataType() == W_DT_INT16 )
{
DATADEP_SCALE( int16_t )
}
else if ( m_valueSet->getDataType() == W_DT_SIGNED_INT )
{
DATADEP_SCALE( int32_t )
}
else if ( m_valueSet->getDataType() == W_DT_FLOAT )
{
DATADEP_SCALE( float )
}
else if ( m_valueSet->getDataType() == W_DT_DOUBLE )
{
DATADEP_SCALE( double )
}
else
{
return;
}
m_grid = newgrid;
m_valueSet = newvalueSet;
}
......@@ -378,6 +378,11 @@ protected:
float scaleInterval( float value ) const;
private:
/**
* Scales the texture to a size of power two, this is only need if a graphics card does not
* suppport other texture size like on older laptops
*/
void scaleTexture();
};
#endif // WDATATEXTURE3D_H
......
......@@ -73,7 +73,11 @@ WMNavSlices::WMNavSlices():
// Implement WModule::initializeConnectors instead.
// initialize members
#ifndef LOWGRAPHICS
m_shader = osg::ref_ptr< WShader > ( new WShader( "WMNavSlices" ) );
#else
m_shader = osg::ref_ptr< WShader > ( new WShader( "WMNavSlices-simple" ) );
#endif
}
WMNavSlices::~WMNavSlices()
......
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-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/>.
//
//---------------------------------------------------------------------------
varying vec4 VaryingTexCoord0;
varying vec4 VaryingTexCoord1;
varying vec4 VaryingTexCoord2;
varying vec4 VaryingTexCoord3;
varying vec4 VaryingTexCoord4;
varying vec4 VaryingTexCoord5;
varying vec4 VaryingTexCoord6;
varying vec4 VaryingTexCoord7;
uniform sampler3D tex0;
uniform sampler3D tex1;
uniform sampler3D tex2;
uniform sampler3D tex3;
uniform sampler3D tex4;
uniform sampler3D tex5;
uniform sampler3D tex6;
uniform sampler3D tex7;
uniform float threshold0;
uniform float threshold1;
uniform float threshold2;
uniform float threshold3;
uniform float threshold4;
uniform float threshold5;
uniform float threshold6;
uniform float threshold7;
uniform int type0;
uniform int type1;
uniform int type2;
uniform int type3;
uniform int type4;
uniform int type5;
uniform int type6;
uniform int type7;
uniform float alpha0;
uniform float alpha1;
uniform float alpha2;
uniform float alpha3;
uniform float alpha4;
uniform float alpha5;
uniform float alpha6;
uniform float alpha7;
uniform int useCmap0;
uniform int useCmap1;
uniform int useCmap2;
uniform int useCmap3;
uniform int useCmap4;
uniform int useCmap5;
uniform int useCmap6;
uniform int useCmap7;
uniform bool highlighted;
uniform bool showComplete;
void lookupTex( inout vec4 col, in int type, in sampler3D tex, in float threshold, in vec3 v, in float alpha, in int cmap )
{
vec3 col1 = vec3( 0.0 );
col1 = clamp( texture3D( tex, v ).rgb, 0.0, 1.0 );
if( ( col1.r + col1.g + col1.b ) / 3.0 - threshold <= -0.0001 ) return;
col.rgb = mix( col.rgb, col1.rgb, alpha );
}
void main()
{
vec4 col = vec4( 0.0, 0.0, 0.0, 1.0 );
if ( type7 > 0 ) lookupTex( col, type7, tex7, threshold7, VaryingTexCoord7.xyz, alpha7, useCmap7 );
if ( type6 > 0 ) lookupTex( col, type6, tex6, threshold6, VaryingTexCoord6.xyz, alpha6, useCmap6 );
if ( type5 > 0 ) lookupTex( col, type5, tex5, threshold5, VaryingTexCoord5.xyz, alpha5, useCmap5 );
if ( type4 > 0 ) lookupTex( col, type4, tex4, threshold4, VaryingTexCoord4.xyz, alpha4, useCmap4 );
if ( type3 > 0 ) lookupTex( col, type3, tex3, threshold3, VaryingTexCoord3.xyz, alpha3, useCmap3 );
if ( type2 > 0 ) lookupTex( col, type2, tex2, threshold2, VaryingTexCoord2.xyz, alpha2, useCmap2 );
if ( type1 > 0 ) lookupTex( col, type1, tex1, threshold1, VaryingTexCoord1.xyz, alpha1, useCmap1 );
if ( type0 > 0 ) lookupTex( col, type0, tex0, threshold0, VaryingTexCoord0.xyz, alpha0, useCmap0 );
col = clamp( col, 0.0, 1.0 );
if ( ( col.r + col.g + col.b ) < 0.01 )
{
if( highlighted && !showComplete )
{
// higlight picked slice in the areas where ther are zero (very small) values
col = vec4( .7, .7, 1, 1 );
}
else
{
if ( !showComplete )
discard;
}
}
gl_FragColor = col;
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-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/>.
//
//---------------------------------------------------------------------------
varying vec4 VaryingTexCoord0;
varying vec4 VaryingTexCoord1;
varying vec4 VaryingTexCoord2;
varying vec4 VaryingTexCoord3;
varying vec4 VaryingTexCoord4;
varying vec4 VaryingTexCoord5;
varying vec4 VaryingTexCoord6;
varying vec4 VaryingTexCoord7;
void main()
{
VaryingTexCoord0 = gl_MultiTexCoord0;
VaryingTexCoord1 = gl_MultiTexCoord1;
VaryingTexCoord2 = gl_MultiTexCoord2;
VaryingTexCoord3 = gl_MultiTexCoord3;
VaryingTexCoord4 = gl_MultiTexCoord4;
VaryingTexCoord5 = gl_MultiTexCoord5;
VaryingTexCoord6 = gl_MultiTexCoord6;
VaryingTexCoord7 = gl_MultiTexCoord7;
gl_Position = ftransform();
}
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