Show
Ignore:
Timestamp:
09/28/08 17:16:13 (6 years ago)
Author:
robert
Message:

Improved the isosurface shaders, and mde GLSL usage the default

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osgvolume/osgvolume.cpp

    r8952 r8953  
    922922    else if (shadingModel==Isosurface) 
    923923    { 
    924         osg::Uniform* normalMapSampler = new osg::Uniform("normalMap",1); 
    925         stateset->addUniform(normalMapSampler); 
    926  
    927         osg::Texture3D* normalMap = new osg::Texture3D; 
    928         normalMap->setImage(normalmap_3d);     
    929         normalMap->setResizeNonPowerOfTwoHint(false); 
    930         normalMap->setInternalFormatMode(internalFormatMode); 
    931         normalMap->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR); 
    932         normalMap->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR); 
    933         normalMap->setWrap(osg::Texture::WRAP_R,osg::Texture::CLAMP_TO_EDGE); 
    934         normalMap->setWrap(osg::Texture::WRAP_S,osg::Texture::CLAMP_TO_EDGE); 
    935         normalMap->setWrap(osg::Texture::WRAP_T,osg::Texture::CLAMP_TO_EDGE); 
    936  
    937         stateset->setTextureAttributeAndModes(1,normalMap,osg::StateAttribute::ON); 
    938924 
    939925        if (tf) 
     
    945931            texture1D->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR); 
    946932            texture1D->setWrap(osg::Texture::WRAP_R,osg::Texture::CLAMP_TO_EDGE); 
    947             stateset->setTextureAttributeAndModes(0,texture1D,osg::StateAttribute::ON); 
     933            stateset->setTextureAttributeAndModes(1,texture1D,osg::StateAttribute::ON); 
     934 
     935            osg::Uniform* tfTextureSampler = new osg::Uniform("tfTexture",1); 
     936            stateset->addUniform(tfTextureSampler); 
    948937 
    949938            osg::Shader* fragmentShader = osgDB::readShaderFile(osg::Shader::FRAGMENT, "volume_tf_iso.frag"); 
     
    957946                program->addShader(new osg::Shader(osg::Shader::FRAGMENT, volume_tf_iso_frag)); 
    958947            } 
    959  
    960             osg::Uniform* tfTextureSampler = new osg::Uniform("tfTexture",0); 
    961             stateset->addUniform(tfTextureSampler); 
    962  
    963948        } 
    964949        else 
     
    17701755    arguments.getApplicationUsage()->addCommandLineOption("-s <numSlices>","Number of slices to create."); 
    17711756    arguments.getApplicationUsage()->addCommandLineOption("--images [filenames]","Specify a stack of 2d images to build the 3d volume from."); 
    1772     arguments.getApplicationUsage()->addCommandLineOption("--shader","Use OpenGL Shading Language."); 
     1757    arguments.getApplicationUsage()->addCommandLineOption("--shader","Use OpenGL Shading Language. (default)"); 
     1758    arguments.getApplicationUsage()->addCommandLineOption("--no-shader","Disable use of OpenGL Shading Language."); 
     1759    arguments.getApplicationUsage()->addCommandLineOption("--gpu-tf","Aply the transfer function on the GPU. (default)"); 
     1760    arguments.getApplicationUsage()->addCommandLineOption("--cpu-tf","Apply the transfer function on the CPU."); 
    17731761    arguments.getApplicationUsage()->addCommandLineOption("--mip","Use Maximum Intensity Projection (MIP) filtering."); 
    17741762    arguments.getApplicationUsage()->addCommandLineOption("--xSize <size>","Relative width of rendered brick."); 
     
    18501838    { 
    18511839        shadingModel = Isosurface; 
    1852         createNormalMap=true; 
    18531840    } 
    18541841 
     
    19021889    while(arguments.read("--num-components", numComponentsDesired)) {} 
    19031890 
    1904     bool useShader = false;  
     1891    bool useShader = true;  
    19051892    while(arguments.read("--shader")) { useShader = true; } 
    1906  
    1907     bool gpuTransferFunction = false;  
     1893    while(arguments.read("--no-shader")) { useShader = true; } 
     1894 
     1895    bool gpuTransferFunction = true;  
    19081896    while(arguments.read("--gpu-tf")) { gpuTransferFunction = true; } 
     1897    while(arguments.read("--cpu-tf")) { gpuTransferFunction = false; } 
    19091898 
    19101899    osg::ref_ptr<osg::Image> image_3d;