Changeset 337


Ignore:
Timestamp:
Mar 16, 2012, 10:44:23 PM (7 years ago)
Author:
Torben Dannhauer
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • experimental/distortionNG/extViewer.cpp

    r336 r337  
    274274
    275275                osg::TexMat* texmat = new osg::TexMat;
    276         texmat->setScaleByTextureRectangleSize(true);
     276            texmat->setScaleByTextureRectangleSize(true);
    277277        stateset->setTextureAttributeAndModes(0, texmat, osg::StateAttribute::ON);
    278278
     
    280280                if (!applyIntensityMapAsColours && intensityMap)
    281281        {
     282                        // Resize intensityMap if the dimensions are wrong
     283                        if(intensityMap->s()!=tex_width || intensityMap->t()!=tex_height)
     284                                intensityMap->scaleImage(tex_width, tex_height, intensityMap->r());
     285
    282286                        osg::TextureRectangle* intensityMapTexture = new osg::TextureRectangle(intensityMap);
    283                         intensityMapTexture->setTextureSize(tex_width, tex_height);
    284                         //intensityMapTexture->setInternalFormat(GL_RGB);
    285                  //   intensityMapTexture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR);
    286                         //intensityMapTexture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR);
     287                        intensityMapTexture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR);
     288                        intensityMapTexture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR);
    287289                        intensityMapTexture->setWrap(osg::Texture::WRAP_S,osg::Texture::CLAMP_TO_EDGE);
    288290                        intensityMapTexture->setWrap(osg::Texture::WRAP_T,osg::Texture::CLAMP_TO_EDGE);
     
    290292            stateset->setTextureAttributeAndModes(1, intensityMapTexture, osg::StateAttribute::ON);
    291293
    292                         //osg::TexMat* texmat1 = new osg::TexMat;
    293                         //texmat1->setScaleByTextureRectangleSize(true);
    294                         //stateset->setTextureAttributeAndModes(1, texmat1, osg::StateAttribute::ON);
    295         }
    296 
    297                 osg::Geometry* distortionMesh = createMesh(osg::Vec3(0.0f,0.0f,0.0f), osg::Vec3(width,0.0f,0.0f), osg::Vec3(0.0f,height,0.0f), 20, 20, intensityMap, applyIntensityMapAsColours, projectorMatrix);
    298                 geode->addDrawable(distortionMesh);
    299 
    300                 if (intensityMap && !applyIntensityMapAsColours)
    301                 {
    302294                        // create shaders for distortion
    303295                        osg::Program* distortProgram = new osg::Program;
     
    316308                                stateset->setAttributeAndModes(distortProgram, osg::StateAttribute::ON);
    317309                        }
     310        }
     311
     312                osg::Geometry* distortionMesh = createMesh(osg::Vec3(0.0f,0.0f,0.0f), osg::Vec3(width,0.0f,0.0f), osg::Vec3(0.0f,height,0.0f), 20, 20, intensityMap, applyIntensityMapAsColours, projectorMatrix);
     313                geode->addDrawable(distortionMesh);
     314
     315                if (intensityMap && !applyIntensityMapAsColours)
     316                {
     317                        //// create shaders for distortion
     318                        //osg::Program* distortProgram = new osg::Program;
     319                        //distortProgram->setName( "distortion" );
     320                        //osg::Shader* vShader = osg::Shader::readShaderFile( osg::Shader::VERTEX, "shader.vert" );
     321                        //vShader->setName("intensityMapVertShader");
     322                        //osg::Shader* fShader = osg::Shader::readShaderFile( osg::Shader::FRAGMENT, "shader.frag" );
     323                        //fShader->setName("intensityMapFragShader");
     324
     325                        //if ( vShader && fShader )
     326                        //{
     327                        //      //distortProgram->addShader( vShader );
     328                        //      distortProgram->addShader( fShader );
     329                        //      stateset->addUniform( new osg::Uniform("sceneTexture", 0) );
     330                        //      stateset->addUniform( new osg::Uniform("intensityMapTexture", 1) );
     331                        //      stateset->setAttributeAndModes(distortProgram, osg::StateAttribute::ON);
     332                        //}
    318333                }
    319334
Note: See TracChangeset for help on using the changeset viewer.