From 79276b316980042e5fdcb80a8e461a8439900cf4 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 28 Feb 2008 10:56:03 +0000 Subject: [PATCH] From He Sicong, "fixed shader calculation of ray tracing" --- examples/osgvolume/osgvolume.cpp | 45 ++++++++++++++++---------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/examples/osgvolume/osgvolume.cpp b/examples/osgvolume/osgvolume.cpp index 5b99ca873..885ac63c4 100644 --- a/examples/osgvolume/osgvolume.cpp +++ b/examples/osgvolume/osgvolume.cpp @@ -792,13 +792,13 @@ osg::Node* createShaderModel(osg::ref_ptr& image_3d, osg::ref_ptr& image_3d, osg::ref_ptr=0.0 && texcoord.x<=1.0 &&\n" - " texcoord.y>=0.0 && texcoord.y<=1.0 &&\n" - " texcoord.z>=0.0 && texcoord.z<=1.0)\n" - " {\n" - " vec4 color = texture3D( baseTexture, texcoord);\n" - " float r = color[3]*transparency;\n" - " if (r>alphaCutOff)\n" - " {\n" - " gl_FragColor.xyz = gl_FragColor.xyz*(1.0-r)+color.xyz*r;\n" - " gl_FragColor.w += r;\n" - " }\n" - " texcoord += deltaTexCoord2; \n" - " }\n" + "void main(void)\n" + "{ \n" + " vec3 deltaTexCoord=normalize(cameraPos-texcoord.xyz)*sampleDensity;\n" + " gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); \n" + " while (texcoord.x>=0.0 && texcoord.x<=1.0 &&\n" + " texcoord.y>=0.0 && texcoord.y<=1.0 &&\n" + " texcoord.z>=0.0 && texcoord.z<=1.0)\n" + " {\n" + " vec4 color = texture3D( baseTexture, texcoord);\n" + " float r = color[3]*transparency;\n" + " if (r>alphaCutOff)\n" + " {\n" + " gl_FragColor.xyz = gl_FragColor.xyz*(1.0-r)+color.xyz*r;\n" + " gl_FragColor.w += r;\n" + " }\n" + " texcoord += deltaTexCoord; \n" + " }\n" " if (gl_FragColor.w>1.0) gl_FragColor.w = 1.0; \n" "}\n";