diff --git a/src/osgVolume/Shaders/volume_frag.cpp b/src/osgVolume/Shaders/volume_frag.cpp index c53bb7855..6351da4f9 100644 --- a/src/osgVolume/Shaders/volume_frag.cpp +++ b/src/osgVolume/Shaders/volume_frag.cpp @@ -9,7 +9,7 @@ char volume_frag[] = "uniform sampler3D baseTexture;\n" "varying vec4 baseColor;\n" "\n" "void main(void)\n" - "{ \n" + "{\n" " vec4 t0 = vertexPos;\n" " vec4 te = cameraPos;\n" "\n" @@ -61,20 +61,16 @@ char volume_frag[] = "uniform sampler3D baseTexture;\n" " t0 = t0 * texgen;\n" " te = te * texgen;\n" "\n" - " const float max_iteratrions = 2048.0;\n" - " float num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n" - " if (num_iterations<2.0) num_iterations = 2.0;\n" + " const int max_iteratrions = 2048;\n" + " int num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n" + " if (num_iterations<2) num_iterations = 2;\n" + " if (num_iterations>max_iteratrions) num_iterations = max_iteratrions;\n" "\n" - " if (num_iterations>max_iteratrions) \n" - " {\n" - " num_iterations = max_iteratrions;\n" - " }\n" - "\n" - " vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1.0);\n" + " vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1);\n" " vec3 texcoord = t0.xyz;\n" "\n" - " vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0); \n" - " while(num_iterations>0.0)\n" + " vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0);\n" + " while(num_iterations>0)\n" " {\n" " vec4 color = texture3D( baseTexture, texcoord);\n" " float r = color[3]*TransparencyValue;\n" @@ -88,7 +84,7 @@ char volume_frag[] = "uniform sampler3D baseTexture;\n" " {\n" " fragColor = color;\n" " }\n" - " texcoord += deltaTexCoord; \n" + " texcoord += deltaTexCoord;\n" "\n" " --num_iterations;\n" " }\n" @@ -99,7 +95,6 @@ char volume_frag[] = "uniform sampler3D baseTexture;\n" " fragColor *= baseColor;\n" "\n" " if (fragColor.wmax_iteratrions) num_iterations = max_iteratrions;\n" "\n" - " if (num_iterations>max_iteratrions) \n" - " {\n" - " num_iterations = max_iteratrions;\n" - " }\n" "\n" - " vec3 deltaTexCoord=(t0-te).xyz/float(num_iterations-1.0);\n" + " vec3 deltaTexCoord=(t0-te).xyz/float(num_iterations-1);\n" " vec3 texcoord = te.xyz;\n" "\n" " vec4 previousColor = texture3D( baseTexture, texcoord);\n" @@ -81,7 +78,7 @@ char volume_iso_frag[] = "uniform sampler3D baseTexture;\n" " vec3 deltaY = vec3(0.0, normalSampleDistance, 0.0);\n" " vec3 deltaZ = vec3(0.0, 0.0, normalSampleDistance);\n" " \n" - " while(num_iterations>0.0)\n" + " while(num_iterations>0)\n" " {\n" " vec4 color = texture3D( baseTexture, texcoord);\n" "\n" diff --git a/src/osgVolume/Shaders/volume_lit_frag.cpp b/src/osgVolume/Shaders/volume_lit_frag.cpp index 9dcc15a4e..97b4ef05b 100644 --- a/src/osgVolume/Shaders/volume_lit_frag.cpp +++ b/src/osgVolume/Shaders/volume_lit_frag.cpp @@ -10,7 +10,7 @@ char volume_lit_frag[] = "uniform sampler3D baseTexture;\n" "varying vec4 baseColor;\n" "\n" "void main(void)\n" - "{ \n" + "{\n" " vec4 t0 = vertexPos;\n" " vec4 te = cameraPos;\n" "\n" @@ -62,16 +62,12 @@ char volume_lit_frag[] = "uniform sampler3D baseTexture;\n" " t0 = t0 * texgen;\n" " te = te * texgen;\n" "\n" - " const float max_iteratrions = 2048.0;\n" - " float num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n" - " if (num_iterations<2.0) num_iterations = 2.0;\n" + " const int max_iteratrions = 2048;\n" + " int num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n" + " if (num_iterations<2) num_iterations = 2;\n" + " if (num_iterations>max_iteratrions) num_iterations = max_iteratrions;\n" "\n" - " if (num_iterations>max_iteratrions) \n" - " {\n" - " num_iterations = max_iteratrions;\n" - " }\n" - "\n" - " vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1.0);\n" + " vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1);\n" " vec3 texcoord = t0.xyz;\n" "\n" " float normalSampleDistance = 1.0/512.0;\n" @@ -80,7 +76,7 @@ char volume_lit_frag[] = "uniform sampler3D baseTexture;\n" " vec3 deltaZ = vec3(0.0, 0.0, normalSampleDistance);\n" "\n" " vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0); \n" - " while(num_iterations>0.0)\n" + " while(num_iterations>0)\n" " {\n" " vec4 color = texture3D( baseTexture, texcoord);\n" "\n" @@ -115,18 +111,17 @@ char volume_lit_frag[] = "uniform sampler3D baseTexture;\n" " {\n" " fragColor = color;\n" " }\n" - " texcoord += deltaTexCoord; \n" + " texcoord += deltaTexCoord;\n" "\n" " --num_iterations;\n" " }\n" "\n" " fragColor.w *= TransparencyValue;\n" - " if (fragColor.w>1.0) fragColor.w = 1.0; \n" + " if (fragColor.w>1.0) fragColor.w = 1.0;\n" "\n" " fragColor *= baseColor;\n" "\n" " if (fragColor.wmax_iteratrions) num_iterations = max_iteratrions;\n" "\n" - " if (num_iterations>max_iteratrions) \n" - " {\n" - " num_iterations = max_iteratrions;\n" - " }\n" - "\n" - " vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1.0);\n" + " vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1);\n" " vec3 texcoord = t0.xyz;\n" "\n" " float normalSampleDistance = 1.0/512.0;\n" @@ -87,7 +83,7 @@ char volume_lit_tf_frag[] = "uniform sampler3D baseTexture;\n" " vec3 deltaZ = vec3(0.0, 0.0, normalSampleDistance);\n" "\n" " vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0); \n" - " while(num_iterations>0.0)\n" + " while(num_iterations>0)\n" " {\n" " float v = texture3D( baseTexture, texcoord).a * tfScale + tfOffset;\n" " vec4 color = texture1D( tfTexture, v);\n" @@ -112,7 +108,6 @@ char volume_lit_tf_frag[] = "uniform sampler3D baseTexture;\n" " color.z *= lightScale;\n" " }\n" "\n" - "\n" " float r = color[3]*TransparencyValue;\n" " if (r>AlphaFuncValue)\n" " {\n" @@ -124,7 +119,7 @@ char volume_lit_tf_frag[] = "uniform sampler3D baseTexture;\n" " {\n" " fragColor = color;\n" " }\n" - " texcoord += deltaTexCoord; \n" + " texcoord += deltaTexCoord;\n" "\n" " --num_iterations;\n" " }\n" diff --git a/src/osgVolume/Shaders/volume_mip_frag.cpp b/src/osgVolume/Shaders/volume_mip_frag.cpp index 4732673a8..c399831c5 100644 --- a/src/osgVolume/Shaders/volume_mip_frag.cpp +++ b/src/osgVolume/Shaders/volume_mip_frag.cpp @@ -9,7 +9,7 @@ char volume_mip_frag[] = "uniform sampler3D baseTexture;\n" "varying vec4 baseColor;\n" "\n" "void main(void)\n" - "{ \n" + "{\n" " vec4 t0 = vertexPos;\n" " vec4 te = cameraPos;\n" "\n" @@ -61,38 +61,33 @@ char volume_mip_frag[] = "uniform sampler3D baseTexture;\n" " t0 = t0 * texgen;\n" " te = te * texgen;\n" "\n" - " const float max_iteratrions = 2048.0;\n" - " float num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n" - " if (num_iterations<2.0) num_iterations = 2.0;\n" + " const int max_iteratrions = 2048;\n" + " int num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n" + " if (num_iterations<2) num_iterations = 2;\n" + " if (num_iterations>max_iteratrions) num_iterations = max_iteratrions;\n" "\n" - " if (num_iterations>max_iteratrions) \n" - " {\n" - " num_iterations = max_iteratrions;\n" - " }\n" - "\n" - " vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1.0);\n" + " vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1);\n" " vec3 texcoord = t0.xyz;\n" "\n" - " vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0); \n" - " while(num_iterations>0.0)\n" + " vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0);\n" + " while(num_iterations>0)\n" " {\n" " vec4 color = texture3D( baseTexture, texcoord);\n" " if (fragColor.w1.0) fragColor.w = 1.0; \n" + " if (fragColor.w>1.0) fragColor.w = 1.0;\n" "\n" " fragColor *= baseColor;\n" "\n" " if (fragColor.wmax_iteratrions) num_iterations = max_iteratrions;\n" "\n" - " if (num_iterations>max_iteratrions) \n" - " {\n" - " num_iterations = max_iteratrions;\n" - " }\n" - "\n" - " vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1.0);\n" + " vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1);\n" " vec3 texcoord = t0.xyz;\n" "\n" - " vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0); \n" - " while(num_iterations>0.0)\n" + " vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0);\n" + " while(num_iterations>0)\n" " {\n" " float v = texture3D( baseTexture, texcoord).a * tfScale + tfOffset;\n" " vec4 color = texture1D( tfTexture, v);\n" @@ -95,7 +91,7 @@ char volume_tf_frag[] = "uniform sampler3D baseTexture;\n" " {\n" " fragColor = color;\n" " }\n" - " texcoord += deltaTexCoord; \n" + " texcoord += deltaTexCoord;\n" "\n" " --num_iterations;\n" " }\n" @@ -106,7 +102,6 @@ char volume_tf_frag[] = "uniform sampler3D baseTexture;\n" " fragColor *= baseColor;\n" "\n" " if (fragColor.wmax_iteratrions) num_iterations = max_iteratrions;\n" "\n" - " if (num_iterations>max_iteratrions)\n" - " {\n" - " num_iterations = max_iteratrions;\n" - " }\n" "\n" - " vec3 deltaTexCoord=(t0-te).xyz/float(num_iterations-1.0);\n" + " vec3 deltaTexCoord=(t0-te).xyz/float(num_iterations-1);\n" " vec3 texcoord = te.xyz;\n" " float previousV = texture3D( baseTexture, texcoord).a;\n" "\n" @@ -84,8 +81,8 @@ char volume_tf_iso_frag[] = "uniform sampler3D baseTexture;\n" " vec3 deltaX = vec3(normalSampleDistance, 0.0, 0.0);\n" " vec3 deltaY = vec3(0.0, normalSampleDistance, 0.0);\n" " vec3 deltaZ = vec3(0.0, 0.0, normalSampleDistance);\n" - "\n" - " while(num_iterations>0.0)\n" + " \n" + " while(num_iterations>0)\n" " {\n" "\n" " float v = texture3D( baseTexture, texcoord).a;\n" @@ -134,6 +131,5 @@ char volume_tf_iso_frag[] = "uniform sampler3D baseTexture;\n" "\n" " // we didn't find an intersection so just discard fragment\n" " discard;\n" - "\n" "}\n" "\n"; diff --git a/src/osgVolume/Shaders/volume_tf_mip_frag.cpp b/src/osgVolume/Shaders/volume_tf_mip_frag.cpp index 4fc50b798..fed843298 100644 --- a/src/osgVolume/Shaders/volume_tf_mip_frag.cpp +++ b/src/osgVolume/Shaders/volume_tf_mip_frag.cpp @@ -66,20 +66,16 @@ char volume_tf_mip_frag[] = "uniform sampler3D baseTexture;\n" " t0 = t0 * texgen;\n" " te = te * texgen;\n" "\n" - " const float max_iteratrions = 2048.0;\n" - " float num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n" - " if (num_iterations<2.0) num_iterations = 2.0;\n" + " const int max_iteratrions = 2048;\n" + " int num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n" + " if (num_iterations<2) num_iterations = 2;\n" + " if (num_iterations>max_iteratrions) num_iterations = max_iteratrions;\n" "\n" - " if (num_iterations>max_iteratrions)\n" - " {\n" - " num_iterations = max_iteratrions;\n" - " }\n" - "\n" - " vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1.0);\n" + " vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1);\n" " vec3 texcoord = t0.xyz;\n" "\n" " vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0);\n" - " while(num_iterations>0.0)\n" + " while(num_iterations>0)\n" " {\n" " float v = texture3D( baseTexture, texcoord).s * tfScale + tfOffset;\n" " vec4 color = texture1D( tfTexture, v);\n"