~ubuntu-branches/ubuntu/trusty/openscenegraph/trusty

« back to all changes in this revision

Viewing changes to OpenSceneGraph/examples/osgvolume/osgvolume.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Cyril Brulebois
  • Date: 2008-07-29 04:34:38 UTC
  • mfrom: (1.1.6 upstream) (2.1.3 lenny)
  • Revision ID: james.westby@ubuntu.com-20080729043438-no1h9h0dpsrlzp1y
* Non-maintainer upload.
* No longer try to detect (using /proc/cpuinfo when available) how many
  CPUs are available, fixing the FTBFS (due to -j0) on various platforms
  (Closes: #477353). The right way to do it is to support parallel=n in
  DEB_BUILD_OPTIONS (see Debian Policy §4.9.1), and adequate support has
  been implemented.
* Add patch to fix FTBFS due to the build system now refusing to handle
  whitespaces (Policy CMP0004 say the logs), thanks to Andreas Putzo who
  provided it (Closes: #482239):
   - debian/patches/fix-cmp0004-build-failure.dpatch
* Remove myself from Uploaders, as requested a while ago, done by Luk in
  his 2.2.0-2.1 NMU, which was never acknowledged.

Show diffs side-by-side

added added

removed removed

Lines of Context:
262
262
    }
263
263
 
264
264
    ///////////////////////////////////////////////////////////////////////////////
265
 
    // alpha luminiance sources..    
 
265
    // alpha luminance sources..    
266
266
    virtual void LA_to_A(unsigned int num, unsigned char* source, unsigned char* dest) const
267
267
    {
268
268
        for(unsigned int i=0;i<num;++i)
757
757
    // set up the 3d texture itself,
758
758
    // note, well set the filtering up so that mip mapping is disabled,
759
759
    // gluBuild3DMipsmaps doesn't do a very good job of handled the
760
 
    // inbalanced dimensions of the 256x256x4 texture.
 
760
    // imbalanced dimensions of the 256x256x4 texture.
761
761
    osg::Texture3D* texture3D = new osg::Texture3D;
762
762
    texture3D->setFilter(osg::Texture3D::MIN_FILTER,osg::Texture3D::LINEAR);
763
763
    texture3D->setFilter(osg::Texture3D::MAG_FILTER,osg::Texture3D::LINEAR);
792
792
    {
793
793
        char vertexShaderSource[] = 
794
794
            "varying vec3 texcoord;\n"
795
 
            "varying vec3 deltaTexCoord;\n"
 
795
            "varying vec3 cameraPos;\n"
796
796
            "\n"
797
797
            "void main(void)\n"
798
798
            "{\n"
799
 
            "    texcoord = gl_MultiTexCoord0.xyz;\n"
800
 
            "    gl_Position     = ftransform();  \n"
801
 
            "    deltaTexCoord = normalize(gl_ModelViewMatrixInverse * vec4(0,0,0,1) - gl_Vertex);\n"
 
799
            "        texcoord = gl_MultiTexCoord0.xyz;\n"
 
800
            "        gl_Position     = ftransform();\n"
 
801
            "        cameraPos=vec4(gl_ModelViewMatrixInverse*vec4(0,0,0,1)).xyz;\n"
802
802
            "}\n";
803
803
 
804
804
        osg::Shader* vertex_shader = new osg::Shader(osg::Shader::VERTEX, vertexShaderSource);
822
822
            "uniform float transparency;\n"
823
823
            "uniform float alphaCutOff;\n"
824
824
            "\n"
825
 
            "varying vec3 deltaTexCoord;\n"
 
825
            "varying vec3 cameraPos;\n"
826
826
            "varying vec3 texcoord;\n"
827
 
            "void main(void) \n"
 
827
            "\n"
 
828
            "void main(void)\n"
828
829
            "{ \n"
829
 
            "    vec3 deltaTexCoord2 = normalize(deltaTexCoord)*sampleDensity; \n"
830
 
            "\n"
831
 
            "    gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); \n"
832
 
            "    \n"
833
 
            "    while (texcoord.x>=0.0 && texcoord.x<=1.0 &&\n"
834
 
            "           texcoord.y>=0.0 && texcoord.y<=1.0 &&\n"
835
 
            "           texcoord.z>=0.0 && texcoord.z<=1.0)\n"
836
 
            "    {\n"
837
 
            "       vec4 color = texture3D( baseTexture, texcoord);\n"
838
 
            "       float r = color[3]*transparency;\n"
839
 
            "       if (r>alphaCutOff)\n"
840
 
            "       {\n"
841
 
            "         gl_FragColor.xyz = gl_FragColor.xyz*(1.0-r)+color.xyz*r;\n"
842
 
            "         gl_FragColor.w += r;\n"
843
 
            "       }\n"
844
 
            "       texcoord += deltaTexCoord2; \n"
845
 
            "    }\n"
 
830
            "        vec3 deltaTexCoord=normalize(cameraPos-texcoord.xyz)*sampleDensity;\n"
 
831
            "        gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); \n"
 
832
            "        while (texcoord.x>=0.0 && texcoord.x<=1.0 &&\n"
 
833
            "               texcoord.y>=0.0 && texcoord.y<=1.0 &&\n"
 
834
            "               texcoord.z>=0.0 && texcoord.z<=1.0)\n"
 
835
            "        {\n"
 
836
            "            vec4 color = texture3D( baseTexture, texcoord);\n"
 
837
            "            float r = color[3]*transparency;\n"
 
838
            "            if (r>alphaCutOff)\n"
 
839
            "            {\n"
 
840
            "                gl_FragColor.xyz = gl_FragColor.xyz*(1.0-r)+color.xyz*r;\n"
 
841
            "                gl_FragColor.w += r;\n"
 
842
            "            }\n"
 
843
            "            texcoord += deltaTexCoord; \n"
 
844
            "        }\n"
846
845
            "    if (gl_FragColor.w>1.0) gl_FragColor.w = 1.0; \n"
847
846
            "}\n";
848
847
 
1138
1137
        // set up the 3d texture itself,
1139
1138
        // note, well set the filtering up so that mip mapping is disabled,
1140
1139
        // gluBuild3DMipsmaps doesn't do a very good job of handled the
1141
 
        // inbalanced dimensions of the 256x256x4 texture.
 
1140
        // imbalanced dimensions of the 256x256x4 texture.
1142
1141
        osg::Texture3D* texture3D = new osg::Texture3D;
1143
1142
        texture3D->setFilter(osg::Texture3D::MIN_FILTER,osg::Texture3D::LINEAR);
1144
1143
        texture3D->setFilter(osg::Texture3D::MAG_FILTER,osg::Texture3D::LINEAR);
1332
1331
        {
1333
1332
            for(int t=0;t<sizeT;++t)
1334
1333
            {
1335
 
                // reset the indices to begining
 
1334
                // reset the indices to beginning
1336
1335
                readOp._pos = 0;
1337
1336
                writeOp._pos = 0;
1338
1337
            
1562
1561
    // any option left unread are converted into errors to write out later.
1563
1562
    arguments.reportRemainingOptionsAsUnrecognized();
1564
1563
 
1565
 
    // report any errors if they have occured when parsing the program aguments.
 
1564
    // report any errors if they have occurred when parsing the program arguments.
1566
1565
    if (arguments.errors())
1567
1566
    {
1568
1567
        arguments.writeErrorMessages(std::cout);
1569
1568
        return 1;
1570
1569
    }
1571
1570
 
1572
 
    // assume remaining argments are file names of textures.
 
1571
    // assume remaining arguments are file names of textures.
1573
1572
    for(int pos=1;pos<arguments.argc() && !image_3d;++pos)
1574
1573
    {
1575
1574
        if (!arguments.isOption(pos))