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
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);
793
793
char vertexShaderSource[] =
794
794
"varying vec3 texcoord;\n"
795
"varying vec3 deltaTexCoord;\n"
795
"varying vec3 cameraPos;\n"
797
797
"void main(void)\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"
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"
825
"varying vec3 deltaTexCoord;\n"
825
"varying vec3 cameraPos;\n"
826
826
"varying vec3 texcoord;\n"
829
" vec3 deltaTexCoord2 = normalize(deltaTexCoord)*sampleDensity; \n"
831
" gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); \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"
837
" vec4 color = texture3D( baseTexture, texcoord);\n"
838
" float r = color[3]*transparency;\n"
839
" if (r>alphaCutOff)\n"
841
" gl_FragColor.xyz = gl_FragColor.xyz*(1.0-r)+color.xyz*r;\n"
842
" gl_FragColor.w += r;\n"
844
" texcoord += deltaTexCoord2; \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"
836
" vec4 color = texture3D( baseTexture, texcoord);\n"
837
" float r = color[3]*transparency;\n"
838
" if (r>alphaCutOff)\n"
840
" gl_FragColor.xyz = gl_FragColor.xyz*(1.0-r)+color.xyz*r;\n"
841
" gl_FragColor.w += r;\n"
843
" texcoord += deltaTexCoord; \n"
846
845
" if (gl_FragColor.w>1.0) gl_FragColor.w = 1.0; \n"
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);
1562
1561
// any option left unread are converted into errors to write out later.
1563
1562
arguments.reportRemainingOptionsAsUnrecognized();
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())
1568
1567
arguments.writeErrorMessages(std::cout);
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)
1575
1574
if (!arguments.isOption(pos))