=0.0 ) for (float rayIterator = 0.0; rayIterator < 100.0; rayIterator += 1.0) { vec4 orig_sample_color = cTexture3D(uVolData, r0.xyz); orig_sample_color.a = orig_sample_color.r; //ORIG_SAMPLE_MANIP // color of this sample vec4 sample_color = orig_sample_color; //BEGIN INSIDE-LOOP OpacityMapVolumeStyle2D(sample_color, orig_sample_color, r0, true, 2, texTF); //END INSIDE-LOOP //BEGIN COMPOSITING // front-to-back compositing sample_color.rgb *= sample_color.a; rr.color += sample_color*(1.0-rr.color.a); if( rr.zpoint.x < 0.0 && rr.color.a > 0.0 ) { rr.zpoint = vec4( r0.xyz, 1 ); } //END COMPOSITING // step forward along ray r0 += dir; if (!(rr.color.a<0.95 && r0.w>=0.0)) break; } //BEGIN POST-LOOP //END POST-LOOP if( rr.color.a == 0.0 ) discard; // return result return rr; } void main() { textureMatrix = mat4(1.000, 0.000, 0.000, 0.500, 0.000, 1.000, 0.000, 0.500, 0.000, 0.000, 1.000, 0.500, 0.000, 0.000, 0.000, 1.000); textureMatrixInverse = mat4(1.000, 0.000, 0.000, -0.500, 0.000, 1.000, 0.000, -0.500, 0.000, 0.000, 1.000, -0.500, 0.000, 0.000, 0.000, 1.000); // initialize ray vec4 raydir = vec4(normalize(rayDir), -1.0); float texit = rayexit(rayStart,raydir.xyz); raydir = rayStep*raydir; vec4 raypos = vec4(rayStart, texit); // traverse ray RayResult rr = traverseRay(raypos, raydir); // set color gl_FragColor= rr.color; /* // set depth if computed if( rr.zpoint.x>=0.0 ) { // set depth vec4 tmp = modelViewProjectionMatrix*textureMatrixInverse*rr.zpoint; // in window coordinates gl_FragDepth = 0.5*(gl_DepthRange.diff*tmp.z/tmp.w + gl_DepthRange.near+gl_DepthRange.far); } else { gl_FragDepth = gl_FragCoord.z; }*/ } ]]>