Added cube and hull rendering support

This commit is contained in:
Robert Osfield
2014-03-27 12:47:44 +00:00
parent 2f8b0f7a70
commit 27b71e3927
18 changed files with 650 additions and 135 deletions

View File

@@ -6,7 +6,7 @@ char volume_accumulateSamples_iso_frag[] = "#version 110\n"
"\n"
"varying vec3 lightDirection;\n"
"\n"
"vec4 accumulateSamples(vec3 ts, vec3 te, vec3 dt, float scale, float cutoff, int num_iterations)\n"
"vec4 accumulateSamples(vec4 fragColor, vec3 ts, vec3 te, vec3 dt, float scale, float cutoff, int num_iterations)\n"
"{\n"
" vec3 texcoord = te.xyz;\n"
"\n"

View File

@@ -10,7 +10,7 @@ char volume_accumulateSamples_iso_tf_frag[] = "#version 110\n"
"\n"
"varying vec3 lightDirection;\n"
"\n"
"vec4 accumulateSamples(vec3 ts, vec3 te, vec3 dt, float scale, float cutoff, int num_iterations)\n"
"vec4 accumulateSamples(vec4 fragColor, vec3 ts, vec3 te, vec3 dt, float scale, float cutoff, int num_iterations)\n"
"{\n"
" vec3 texcoord = te.xyz;\n"
"\n"

View File

@@ -5,10 +5,9 @@ char volume_accumulateSamples_lit_frag[] = "#version 110\n"
"\n"
"varying vec3 lightDirection;\n"
"\n"
"vec4 accumulateSamples(vec3 ts, vec3 te, vec3 dt, float scale, float cutoff, int num_iterations)\n"
"vec4 accumulateSamples(vec4 fragColor, vec3 ts, vec3 te, vec3 dt, float scale, float cutoff, int num_iterations)\n"
"{\n"
" vec3 texcoord = te.xyz;\n"
" vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0);\n"
"\n"
" float normalSampleDistance = length(dt);\n"
" vec3 deltaX = vec3(normalSampleDistance, 0.0, 0.0);\n"

View File

@@ -10,10 +10,9 @@ char volume_accumulateSamples_lit_tf_frag[] = "#version 110\n"
"\n"
"varying vec3 lightDirection;\n"
"\n"
"vec4 accumulateSamples(vec3 ts, vec3 te, vec3 dt, float scale, float cutoff, int num_iterations)\n"
"vec4 accumulateSamples(vec4 fragColor, vec3 ts, vec3 te, vec3 dt, float scale, float cutoff, int num_iterations)\n"
"{\n"
" vec3 texcoord = te.xyz;\n"
" vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0);\n"
"\n"
" float normalSampleDistance = length(dt);\n"
" vec3 deltaX = vec3(normalSampleDistance, 0.0, 0.0);\n"

View File

@@ -2,10 +2,9 @@ char volume_accumulateSamples_mip_frag[] = "#version 110\n"
"\n"
"uniform sampler3D volumeTexture;\n"
"\n"
"vec4 accumulateSamples(vec3 ts, vec3 te, vec3 dt, float scale, float cutoff, int num_iterations)\n"
"vec4 accumulateSamples(vec4 fragColor, vec3 ts, vec3 te, vec3 dt, float scale, float cutoff, int num_iterations)\n"
"{\n"
" vec3 texcoord = te.xyz;\n"
" vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0);\n"
"\n"
" while(num_iterations>0)\n"
" {\n"

View File

@@ -6,10 +6,9 @@ char volume_accumulateSamples_mip_tf_frag[] = "#version 110\n"
"uniform float tfScale;\n"
"uniform float tfOffset;\n"
"\n"
"vec4 accumulateSamples(vec3 ts, vec3 te, vec3 dt, float scale, float cutoff, int num_iterations)\n"
"vec4 accumulateSamples(vec4 fragColor, vec3 ts, vec3 te, vec3 dt, float scale, float cutoff, int num_iterations)\n"
"{\n"
" vec3 texcoord = te.xyz;\n"
" vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0);\n"
"\n"
" float max_a = 0.0;\n"
" while(num_iterations>0)\n"

View File

@@ -4,10 +4,9 @@ char volume_accumulateSamples_standard_frag[] = "#version 110\n"
"\n"
"uniform float AlphaFuncValue;\n"
"\n"
"vec4 accumulateSamples(vec3 ts, vec3 te, vec3 dt, float scale, float cutoff, int num_iterations)\n"
"vec4 accumulateSamples(vec4 fragColor, vec3 ts, vec3 te, vec3 dt, float scale, float cutoff, int num_iterations)\n"
"{\n"
" vec3 texcoord = te.xyz;\n"
" vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0);\n"
"\n"
" while(num_iterations>0 && fragColor.a<cutoff)\n"
" {\n"

View File

@@ -8,10 +8,9 @@ char volume_accumulateSamples_standard_tf_frag[] = "#version 110\n"
"\n"
"uniform float AlphaFuncValue;\n"
"\n"
"vec4 accumulateSamples(vec3 ts, vec3 te, vec3 dt, float scale, float cutoff, int num_iterations)\n"
"vec4 accumulateSamples(vec4 fragColor, vec3 ts, vec3 te, vec3 dt, float scale, float cutoff, int num_iterations)\n"
"{\n"
" vec3 texcoord = te.xyz;\n"
" vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0);\n"
"\n"
" while(num_iterations>0 && fragColor.a<cutoff)\n"
" {\n"
@@ -32,6 +31,7 @@ char volume_accumulateSamples_standard_tf_frag[] = "#version 110\n"
" }\n"
"\n"
" if (num_iterations>0) fragColor.a = 1.0;\n"
" if (fragColor.a>1.0) fragColor.a = 1.0;\n"
"\n"
" return fragColor;\n"
"}\n"

View File

@@ -9,9 +9,9 @@ char volume_compute_ray_color_frag[] = "#version 110\n"
"varying mat4 texgen_withProjectionMatrixInverse;\n"
"\n"
"// forward declare, probided by volume_accumulateSamples*.frag shaders\n"
"vec4 accumulateSamples(vec3 ts, vec3 te, vec3 dt, float scale, float cutoff, int num_iterations);\n"
"vec4 accumulateSamples(vec4 fragColor, vec3 ts, vec3 te, vec3 dt, float scale, float cutoff, int num_iterations);\n"
"\n"
"vec4 accumulateSegment(vec3 ts, vec3 te)\n"
"vec4 accumulateSegment(vec4 fragColor, vec3 ts, vec3 te)\n"
"{\n"
" const int max_iterations = 8192;\n"
"\n"
@@ -45,9 +45,7 @@ char volume_compute_ray_color_frag[] = "#version 110\n"
"\n"
" float cutoff = 1.0-1.0/256.0;\n"
"\n"
" vec4 fragColor;\n"
"\n"
" fragColor = accumulateSamples(ts, te, deltaTexCoord, scale, cutoff, num_iterations);\n"
" fragColor = accumulateSamples(fragColor, ts, te, deltaTexCoord, scale, cutoff, num_iterations);\n"
"\n"
" fragColor *= baseColor;\n"
"\n"
@@ -105,7 +103,7 @@ char volume_compute_ray_color_frag[] = "#version 110\n"
"}\n"
"\n"
"\n"
"vec4 computeRayColor(float px, float py, float depth_start, float depth_end)\n"
"vec4 computeRayColor(vec4 fragColor, float px, float py, float depth_start, float depth_end)\n"
"{\n"
" float viewportWidth = viewportDimensions[2];\n"
" float viewportHeight = viewportDimensions[3];\n"
@@ -129,6 +127,6 @@ char volume_compute_ray_color_frag[] = "#version 110\n"
" vec3 clamped_start_texcoord = clampToUnitCube(end_texcoord.xyz, start_texcoord.xyz);\n"
" vec3 clamped_end_texcoord = clampToUnitCube(start_texcoord.xyz, end_texcoord.xyz);\n"
"\n"
" return accumulateSegment(clamped_start_texcoord, clamped_end_texcoord);\n"
" return accumulateSegment(fragColor, clamped_start_texcoord, clamped_end_texcoord);\n"
"}\n"
"\n";

View File

@@ -0,0 +1,119 @@
char volume_multipass_cube_and_hull_frag[] = "#version 110\n"
"\n"
"uniform sampler2D colorTexture;\n"
"uniform sampler2D depthTexture;\n"
"uniform sampler2D backFaceDepthTexture;\n"
"uniform sampler2D frontFaceDepthTexture;\n"
"uniform vec4 viewportDimensions;\n"
"uniform float ExteriorTransparencyFactorValue;\n"
"\n"
"\n"
"// declare function defined in volume_compute_ray_color.frag\n"
"vec4 computeRayColor(vec4 fragColor, float px, float py, float depth_start, float depth_end);\n"
"\n"
"vec4 computeSegment(vec4 fragColor, float px, float py, float depth_start, float depth_end, float transparencyFactor, vec4 scene_color, float scene_depth)\n"
"{\n"
"#if 1\n"
" //return mix(fragColor, computeRayColor(fragColor, px, py, depth_start, depth_end), transparencyFactor);\n"
" if ((depth_end<scene_depth) && (scene_depth<depth_start))\n"
" {\n"
" // scene fragment between segment end points\n"
" // compute front segment color and blend with scene fragment color\n"
" fragColor = mix( fragColor, computeRayColor(fragColor, px, py, scene_depth, depth_end), transparencyFactor);\n"
" fragColor = mix(scene_color, fragColor, fragColor.a);\n"
" if (fragColor.a>=1.0) return fragColor;\n"
"\n"
" // compute rear segement color and blend with accumulated_color\n"
" return mix( fragColor, computeRayColor(fragColor, px, py, depth_start, scene_depth), transparencyFactor);\n"
" }\n"
" else\n"
" {\n"
" return mix( fragColor, computeRayColor(fragColor, px, py, depth_start, depth_end), transparencyFactor);\n"
" }\n"
"#else\n"
" if ((depth_end<scene_depth) && (scene_depth<depth_start))\n"
" {\n"
" // scene fragment between segment end points\n"
" // compute front segment color and blend with scene fragment color\n"
" fragColor = computeRayColor(fragColor, px, py, scene_depth, depth_end) * transparencyFactor;\n"
" fragColor = mix(scene_color, fragColor, fragColor.a);\n"
" if (fragColor.a>=1.0) return fragColor;\n"
"\n"
" // compute rear segement color and blend with accumulated_color\n"
" return computeRayColor(fragColor, px, py, depth_start, scene_depth) * transparencyFactor;\n"
" }\n"
" else\n"
" {\n"
" return computeRayColor(fragColor, px, py, depth_start, depth_end) * transparencyFactor;\n"
" }\n"
"#endif\n"
"}\n"
"\n"
"void main(void)\n"
"{\n"
" vec2 texcoord = vec2((gl_FragCoord.x-viewportDimensions[0])/viewportDimensions[2], (gl_FragCoord.y-viewportDimensions[1])/viewportDimensions[3]);\n"
" vec4 color = texture2D( colorTexture, texcoord);\n"
" float texture_depth = texture2D( depthTexture, texcoord).s;\n"
" float back_depth = texture2D( backFaceDepthTexture, texcoord).s;\n"
" float front_depth = texture2D( frontFaceDepthTexture, texcoord).s;\n"
"\n"
" //float ExteriorTransparencyFactorValue = 1.0;\n"
" vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0);\n"
"\n"
" // make sure the front_depth and back_depth values represent usable depths for later tests\n"
" if (front_depth>back_depth)\n"
" {\n"
" if (front_depth==1.0)\n"
" {\n"
" // front face likely to have been clipped out by near plane\n"
" front_depth = 0.0;\n"
" }\n"
" else\n"
" {\n"
" // front and back faces of hull are reversed so treat them as empty.\n"
" front_depth = 1.0;\n"
" back_depth = 1.0;\n"
" }\n"
" }\n"
"\n"
" if (back_depth<gl_FragCoord.z)\n"
" {\n"
" // segment front_depth to 0.0, exterior transparancy\n"
" // segment back_depth to front_depth, interior transparency\n"
" // segment gl_FragCoord.z to back_depth, exterior transparency\n"
" fragColor = computeSegment(fragColor, gl_FragCoord.x, gl_FragCoord.y, front_depth, 0.0, ExteriorTransparencyFactorValue, color, texture_depth);\n"
" if (fragColor.a<1.0)\n"
" {\n"
" fragColor = computeSegment(fragColor, gl_FragCoord.x, gl_FragCoord.y, back_depth, front_depth, 1.0, color, texture_depth);\n"
" if (fragColor.a<1.0)\n"
" {\n"
" fragColor = computeSegment(fragColor, gl_FragCoord.x, gl_FragCoord.y, gl_FragCoord.z, back_depth, ExteriorTransparencyFactorValue, color, texture_depth);\n"
" }\n"
" }\n"
" }\n"
" else if (front_depth<gl_FragCoord.z)\n"
" {\n"
" // segment front_depth to 0, exterior transparancy\n"
" // segement gl_FragCoord.z to front_depth, interior transparancy\n"
" // back_depth behind gl_FragCoord.z so clipped out by cube and not required.\n"
" fragColor = computeSegment(fragColor, gl_FragCoord.x, gl_FragCoord.y, front_depth, 0.0, ExteriorTransparencyFactorValue, color, texture_depth);\n"
" if (fragColor.a<1.0)\n"
" {\n"
" fragColor = computeSegment(fragColor, gl_FragCoord.x, gl_FragCoord.y, gl_FragCoord.z, front_depth, 1.0, color, texture_depth);\n"
" }\n"
" }\n"
" else\n"
" {\n"
" // segment gl_FragCoord.z to 0.0\n"
" fragColor = computeSegment(fragColor, gl_FragCoord.x, gl_FragCoord.y, gl_FragCoord.z, 0.0, ExteriorTransparencyFactorValue, color, texture_depth);\n"
" }\n"
"\n"
" if (texture_depth>gl_FragCoord.z)\n"
" {\n"
" fragColor = mix(color, fragColor, fragColor.a);\n"
" }\n"
"\n"
" gl_FragColor = fragColor;\n"
" gl_FragDepth = 0.0;\n"
"}\n"
"\n";

View File

@@ -0,0 +1,87 @@
char volume_multipass_cube_frag[] = "#version 110\n"
"\n"
"uniform sampler2D colorTexture;\n"
"uniform sampler2D depthTexture;\n"
"uniform vec4 viewportDimensions;\n"
"\n"
"// declare function defined in volume_compute_ray_color.frag\n"
"vec4 computeRayColor(vec4 fragColor, float px, float py, float depth_start, float depth_end);\n"
"\n"
"void main(void)\n"
"{\n"
" vec2 texcoord = vec2((gl_FragCoord.x-viewportDimensions[0])/viewportDimensions[2], (gl_FragCoord.y-viewportDimensions[1])/viewportDimensions[3]);\n"
" vec4 color = texture2D( colorTexture, texcoord);\n"
" float texture_depth = texture2D( depthTexture, texcoord).s;\n"
" float front_depth = 0.0;\n"
"\n"
" if (gl_FragCoord.z<texture_depth)\n"
" {\n"
" // fragment starts infront of all other scene objects\n"
"\n"
" gl_FragDepth = front_depth; // gl_FragCoord.z;\n"
"\n"
" vec4 ray_color = computeRayColor(vec4(0.0,0.0,0.0,0.0), gl_FragCoord.x, gl_FragCoord.y, gl_FragCoord.z, front_depth);\n"
"\n"
" gl_FragColor = mix(color, ray_color, ray_color.a);\n"
" }\n"
" else\n"
" {\n"
" // fragment starts behind other scene objects\n"
"\n"
" if (front_depth<texture_depth)\n"
" {\n"
" gl_FragDepth = front_depth;\n"
" }\n"
" else\n"
" {\n"
" gl_FragDepth = texture_depth;\n"
" }\n"
"\n"
" if (color.a<1.0)\n"
" {\n"
" // need to blend ray behind objects with object color and then with the ray from the object depth to the eye point\n"
"\n"
" if (front_depth<texture_depth)\n"
" {\n"
" vec4 front_ray_color = computeRayColor(vec4(0.0,0.0,0.0,0.0), gl_FragCoord.x, gl_FragCoord.y, texture_depth, front_depth);\n"
" // front_ray_color *= vec4(0.0,0.0,1.0,1.0);\n"
" if (front_ray_color.a<1.0)\n"
" {\n"
" if (color.a<1.0)\n"
" {\n"
" vec4 back_ray_color = computeRayColor(vec4(0.0,0.0,0.0,0.0), gl_FragCoord.x, gl_FragCoord.y, gl_FragCoord.z, texture_depth);\n"
" // back_ray_color *= vec4(0.0,1.0,0.0,1.0);\n"
" color = mix(back_ray_color, color, color.a);\n"
" }\n"
" gl_FragColor = mix(color, front_ray_color, front_ray_color.a);\n"
" }\n"
" else\n"
" {\n"
" gl_FragColor = front_ray_color;\n"
" }\n"
" }\n"
" else\n"
" {\n"
" vec4 back_ray_color = computeRayColor(vec4(0.0,0.0,0.0,0.0), gl_FragCoord.x, gl_FragCoord.y, gl_FragCoord.z, front_depth);\n"
" // back_ray_color *= vec4(0.0,1.0,1.0,1.0);\n"
" gl_FragColor = mix(back_ray_color, color, color.a);\n"
" }\n"
" }\n"
" else\n"
" {\n"
" // main scene fragment is opaque so no blending required with ray beyond scene depth\n"
"\n"
" // if the front face depth is behind the depth in the main scene\n"
" if (front_depth>texture_depth) discard;\n"
"\n"
" // gl_FragDepth = texture_depth;\n"
"\n"
" // need to blend the object color with the ray from the object depth to the eye point\n"
" vec4 ray_color = computeRayColor(vec4(0.0,0.0,0.0,0.0), gl_FragCoord.x, gl_FragCoord.y, texture_depth, front_depth);\n"
" // ray_color *= vec4(1.0,1.0,0.0,1.0);\n"
" gl_FragColor = mix(color, ray_color, ray_color.a);\n"
" }\n"
" }\n"
"\n"
"}\n"
"\n";

View File

@@ -6,7 +6,7 @@ char volume_multipass_frag[] = "#version 110\n"
"uniform vec4 viewportDimensions;\n"
"\n"
"// declare function defined in volume_compute_ray_color.frag\n"
"vec4 computeRayColor(float px, float py, float depth_start, float depth_end);\n"
"vec4 computeRayColor(vec4 fragColor, float px, float py, float depth_start, float depth_end);\n"
"\n"
"void main(void)\n"
"{\n"
@@ -26,7 +26,7 @@ char volume_multipass_frag[] = "#version 110\n"
"\n"
" gl_FragDepth = front_depth; // gl_FragCoord.z;\n"
"\n"
" vec4 ray_color = computeRayColor(gl_FragCoord.x, gl_FragCoord.y, gl_FragCoord.z, front_depth);\n"
" vec4 ray_color = computeRayColor(vec4(0.0,0.0,0.0,0.0), gl_FragCoord.x, gl_FragCoord.y, gl_FragCoord.z, front_depth);\n"
"\n"
" gl_FragColor = mix(color, ray_color, ray_color.a);\n"
" }\n"
@@ -49,13 +49,13 @@ char volume_multipass_frag[] = "#version 110\n"
"\n"
" if (front_depth<texture_depth)\n"
" {\n"
" vec4 front_ray_color = computeRayColor(gl_FragCoord.x, gl_FragCoord.y, texture_depth, front_depth);\n"
" vec4 front_ray_color = computeRayColor(vec4(0.0,0.0,0.0,0.0), gl_FragCoord.x, gl_FragCoord.y, texture_depth, front_depth);\n"
" // front_ray_color *= vec4(0.0,0.0,1.0,1.0);\n"
" if (front_ray_color.a<1.0)\n"
" {\n"
" if (color.a<1.0)\n"
" {\n"
" vec4 back_ray_color = computeRayColor(gl_FragCoord.x, gl_FragCoord.y, gl_FragCoord.z, texture_depth);\n"
" vec4 back_ray_color = computeRayColor(vec4(0.0,0.0,0.0,0.0), gl_FragCoord.x, gl_FragCoord.y, gl_FragCoord.z, texture_depth);\n"
" // back_ray_color *= vec4(0.0,1.0,0.0,1.0);\n"
" color = mix(back_ray_color, color, color.a);\n"
" }\n"
@@ -68,7 +68,7 @@ char volume_multipass_frag[] = "#version 110\n"
" }\n"
" else\n"
" {\n"
" vec4 back_ray_color = computeRayColor(gl_FragCoord.x, gl_FragCoord.y, gl_FragCoord.z, front_depth);\n"
" vec4 back_ray_color = computeRayColor(vec4(0.0,0.0,0.0,0.0), gl_FragCoord.x, gl_FragCoord.y, gl_FragCoord.z, front_depth);\n"
" // back_ray_color *= vec4(0.0,1.0,1.0,1.0);\n"
" gl_FragColor = mix(back_ray_color, color, color.a);\n"
" }\n"
@@ -83,7 +83,7 @@ char volume_multipass_frag[] = "#version 110\n"
" // gl_FragDepth = texture_depth;\n"
"\n"
" // need to blend the object color with the ray from the object depth to the eye point\n"
" vec4 ray_color = computeRayColor(gl_FragCoord.x, gl_FragCoord.y, texture_depth, front_depth);\n"
" vec4 ray_color = computeRayColor(vec4(0.0,0.0,0.0,0.0), gl_FragCoord.x, gl_FragCoord.y, texture_depth, front_depth);\n"
" // ray_color *= vec4(1.0,1.0,0.0,1.0);\n"
" gl_FragColor = mix(color, ray_color, ray_color.a);\n"
" }\n"

View File

@@ -0,0 +1,94 @@
char volume_multipass_hull_frag[] = "#version 110\n"
"\n"
"uniform sampler2D colorTexture;\n"
"uniform sampler2D depthTexture;\n"
"uniform sampler2D frontFaceDepthTexture;\n"
"uniform vec4 viewportDimensions;\n"
"\n"
"// declare function defined in volume_compute_ray_color.frag\n"
"vec4 computeRayColor(vec4 fragColor, float px, float py, float depth_start, float depth_end);\n"
"\n"
"void main(void)\n"
"{\n"
" vec2 texcoord = vec2((gl_FragCoord.x-viewportDimensions[0])/viewportDimensions[2], (gl_FragCoord.y-viewportDimensions[1])/viewportDimensions[3]);\n"
" vec4 color = texture2D( colorTexture, texcoord);\n"
" float texture_depth = texture2D( depthTexture, texcoord).s;\n"
" float front_depth = texture2D( frontFaceDepthTexture, texcoord).s;\n"
"\n"
" // if front_depth is set to the far plane then front\n"
" // face has been clipped out by the near plane, so assume\n"
" // front_depth is near plane and reset depth to 0.0\n"
" if (front_depth==1.0) front_depth = 0.0;\n"
"\n"
" if (gl_FragCoord.z<texture_depth)\n"
" {\n"
" // fragment starts infront of all other scene objects\n"
"\n"
" gl_FragDepth = front_depth; // gl_FragCoord.z;\n"
"\n"
" vec4 ray_color = computeRayColor(vec4(0.0,0.0,0.0,0.0), gl_FragCoord.x, gl_FragCoord.y, gl_FragCoord.z, front_depth);\n"
"\n"
" gl_FragColor = mix(color, ray_color, ray_color.a);\n"
" }\n"
" else\n"
" {\n"
" // fragment starts behind other scene objects\n"
" discard;\n"
"\n"
" if (front_depth<texture_depth)\n"
" {\n"
" gl_FragDepth = front_depth;\n"
" }\n"
" else\n"
" {\n"
" gl_FragDepth = texture_depth;\n"
" }\n"
"\n"
" if (color.a<1.0)\n"
" {\n"
" // need to blend ray behind objects with object color and then with the ray from the object depth to the eye point\n"
"\n"
" if (front_depth<texture_depth)\n"
" {\n"
" vec4 front_ray_color = computeRayColor(vec4(0.0,0.0,0.0,0.0), gl_FragCoord.x, gl_FragCoord.y, texture_depth, front_depth);\n"
" // front_ray_color *= vec4(0.0,0.0,1.0,1.0);\n"
" if (front_ray_color.a<1.0)\n"
" {\n"
" if (color.a<1.0)\n"
" {\n"
" vec4 back_ray_color = computeRayColor(vec4(0.0,0.0,0.0,0.0), gl_FragCoord.x, gl_FragCoord.y, gl_FragCoord.z, texture_depth);\n"
" // back_ray_color *= vec4(0.0,1.0,0.0,1.0);\n"
" color = mix(back_ray_color, color, color.a);\n"
" }\n"
" gl_FragColor = mix(color, front_ray_color, front_ray_color.a);\n"
" }\n"
" else\n"
" {\n"
" gl_FragColor = front_ray_color;\n"
" }\n"
" }\n"
" else\n"
" {\n"
" vec4 back_ray_color = computeRayColor(vec4(0.0,0.0,0.0,0.0), gl_FragCoord.x, gl_FragCoord.y, gl_FragCoord.z, front_depth);\n"
" // back_ray_color *= vec4(0.0,1.0,1.0,1.0);\n"
" gl_FragColor = mix(back_ray_color, color, color.a);\n"
" }\n"
" }\n"
" else\n"
" {\n"
" // main scene fragment is opaque so no blending required with ray beyond scene depth\n"
"\n"
" // if the front face depth is behind the depth in the main scene\n"
" if (front_depth>texture_depth) discard;\n"
"\n"
" // gl_FragDepth = texture_depth;\n"
"\n"
" // need to blend the object color with the ray from the object depth to the eye point\n"
" vec4 ray_color = computeRayColor(vec4(0.0,0.0,0.0,0.0), gl_FragCoord.x, gl_FragCoord.y, texture_depth, front_depth);\n"
" // ray_color *= vec4(1.0,1.0,0.0,1.0);\n"
" gl_FragColor = mix(color, ray_color, ray_color.a);\n"
" }\n"
" }\n"
"\n"
"}\n"
"\n";