From: ouv Date: Fri, 18 Nov 2005 14:48:03 +0000 (+0000) Subject: To simplify the vertex shader. X-Git-Tag: BR-D5-38-2003_D2005-24-11~18 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9d67e5c9f2b71ecd5bd432e3e03c34c14d490250;p=modules%2Fvisu.git To simplify the vertex shader. --- diff --git a/resources/Vertex_Program_ARB.txt b/resources/Vertex_Program_ARB.txt index 104e9aa8..0153917f 100755 --- a/resources/Vertex_Program_ARB.txt +++ b/resources/Vertex_Program_ARB.txt @@ -1,21 +1,12 @@ -attribute float results; attribute float clamp; -attribute float geomSize; -attribute float minSize; -attribute float maxSize; -attribute float magnification; void main() { gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; - gl_FrontColor = gl_Color; + gl_FrontColor.x = gl_Color.x; + gl_FrontColor.y = gl_Color.y; + gl_FrontColor.z = gl_Color.z; - float size; - if( results == 1 ) - size = minSize + ( maxSize - minSize ) * ( 1 - gl_Color.w / 241.0f ); - else - size = geomSize; - - gl_PointSize = min( magnification * size * gl_ProjectionMatrix[0].x, clamp ); + gl_PointSize = min( gl_Color.w * gl_ProjectionMatrix[0].x, clamp ); } diff --git a/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx b/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx index b2277081..208e8d3a 100755 --- a/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx +++ b/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx @@ -168,7 +168,6 @@ VISU_OpenGLPointSpriteMapper::VISU_OpenGLPointSpriteMapper() this->ListId = 0; this->TotalCells = 0; - this->ActorOpacity = 0; this->ExtensionsInitialized = 0; this->DefaultPointSize = 20.0; @@ -311,12 +310,7 @@ void VISU_OpenGLPointSpriteMapper::SetPointSpriteResults( bool theResults ) else this->ScalarVisibilityOff(); - float aResults = theResults ? 1.0 : 0.0; - - //cout << "SetPointSpriteResults " << this << " " << aResults << endl; - this->PointSpriteResults = theResults; - //this->SetShaderVariable( "results", theMagnification ); this->Modified(); } //----------------------------------------------------------------------------- @@ -386,7 +380,7 @@ void VISU_OpenGLPointSpriteMapper::RenderPiece(vtkRenderer *ren, vtkActor *act) if( !this->ExtensionsInitialized && !this->UseOpenGLMapper ) { this->InitExtensions(); - act->GetProperty()->SetPointSize( 1.0f ); + act->GetProperty()->SetPointSize( 10.0f ); } if( this->UseOpenGLMapper ) @@ -492,6 +486,7 @@ void VISU_OpenGLPointSpriteMapper::RenderPiece(vtkRenderer *ren, vtkActor *act) if (this->ImmediateModeRendering || this->GetGlobalImmediateModeRendering()) { + // sets this->Colors as side effect this->MapScalars( act->GetProperty()->GetOpacity() ); // Time the actual drawing @@ -684,12 +679,7 @@ void VISU_OpenGLPointSpriteMapper::DrawPoints(vtkPoints *p, vglUseProgramObjectARB( this->VertexProgram ); - this->SetShaderVariable( "results", this->PointSpriteResults ); - this->SetShaderVariable( "clamp", this->PointSpriteClamp ); - this->SetShaderVariable( "geomSize", this->PointSpriteSize ); - this->SetShaderVariable( "minSize", this->PointSpriteMinSize ); - this->SetShaderVariable( "maxSize", this->PointSpriteMaxSize ); - this->SetShaderVariable( "magnification", this->PointSpriteMagnification ); + this->SetShaderVariable( "clamp", this->PointSpriteClamp ); TVertex* aVertex = new TVertex[ this->TotalCells ]; @@ -726,7 +716,16 @@ void VISU_OpenGLPointSpriteMapper::DrawPoints(vtkPoints *p, aVertex[i].g = green; aVertex[i].b = blue; - aVertex[i].hue = ComputeHue( ( int )( red * 255 ), ( int )( green * 255 ), ( int )( blue * 255 ) ); + float size = 0.0; + if( this->PointSpriteResults ) + { + float h = ComputeHue( ( int )( red * 255 ), ( int )( green * 255 ), ( int )( blue * 255 ) ); + size = this->PointSpriteMinSize + ( PointSpriteMaxSize - PointSpriteMinSize ) * ( 1 - h / 241.0f ); + } + else + size = this->PointSpriteSize; + + aVertex[i].hue = this->PointSpriteMagnification * size; } GLuint aBufferObjectID = 0; @@ -744,13 +743,13 @@ void VISU_OpenGLPointSpriteMapper::DrawPoints(vtkPoints *p, glColorPointer( 4, GL_FLOAT, sizeof(TVertex), (void*)0 ); glVertexPointer( 3, GL_FLOAT, sizeof(TVertex), (void*)(4*sizeof(GLfloat)) ); - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_COLOR_ARRAY); + glEnableClientState( GL_VERTEX_ARRAY ); + glEnableClientState( GL_COLOR_ARRAY ); - glDrawArrays(GL_POINTS,0,this->TotalCells); + glDrawArrays( GL_POINTS, 0, this->TotalCells ); - glDisableClientState(GL_COLOR_ARRAY); - glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState( GL_COLOR_ARRAY ); + glDisableClientState( GL_VERTEX_ARRAY ); vglDeleteBuffersARB( 1, &aBufferObjectID ); diff --git a/src/PIPELINE/VISU_OpenGLPointSpriteMapper.hxx b/src/PIPELINE/VISU_OpenGLPointSpriteMapper.hxx index ee2b10cb..4a1683b4 100755 --- a/src/PIPELINE/VISU_OpenGLPointSpriteMapper.hxx +++ b/src/PIPELINE/VISU_OpenGLPointSpriteMapper.hxx @@ -242,7 +242,6 @@ private: int RenderMode; int ListId; vtkIdType TotalCells; - double ActorOpacity; int ExtensionsInitialized; float DefaultPointSize;