diff --git a/src/osgVolume/Shaders/volume_frag.cpp b/src/osgVolume/Shaders/volume_frag.cpp index 6351da4f9..c2cf5fc10 100644 --- a/src/osgVolume/Shaders/volume_frag.cpp +++ b/src/osgVolume/Shaders/volume_frag.cpp @@ -61,16 +61,18 @@ char volume_frag[] = "uniform sampler3D baseTexture;\n" " t0 = t0 * texgen;\n" " te = te * texgen;\n" "\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" + " const float min_iterations = 2.0;\n" + " const float max_iterations = 2048.0;\n" + " float num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n" + " if (num_iterationsmax_iterations) num_iterations = max_iterations;\n" + " else if (num_iterations!=num_iterations) num_iterations = max_iterations;\n" "\n" - " vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1);\n" + " vec3 deltaTexCoord=(te-t0).xyz/(num_iterations-1.0);\n" " vec3 texcoord = t0.xyz;\n" "\n" " vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0);\n" - " while(num_iterations>0)\n" + " while(num_iterations>0.0)\n" " {\n" " vec4 color = texture3D( baseTexture, texcoord);\n" " float r = color[3]*TransparencyValue;\n" diff --git a/src/osgVolume/Shaders/volume_iso_frag.cpp b/src/osgVolume/Shaders/volume_iso_frag.cpp index 85542b7ac..dbef5ef20 100644 --- a/src/osgVolume/Shaders/volume_iso_frag.cpp +++ b/src/osgVolume/Shaders/volume_iso_frag.cpp @@ -62,13 +62,14 @@ char volume_iso_frag[] = "uniform sampler3D baseTexture;\n" " t0 = t0 * texgen;\n" " te = te * texgen;\n" "\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" + " const float min_iterations = 2.0;\n" + " const float max_iterations = 2048.0;\n" + " float num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n" + " if (num_iterationsmax_iterations) num_iterations = max_iterations;\n" + " else if (num_iterations!=num_iterations) num_iterations = max_iterations;\n" "\n" - "\n" - " vec3 deltaTexCoord=(t0-te).xyz/float(num_iterations-1);\n" + " vec3 deltaTexCoord=(t0-te).xyz/(num_iterations-1.0);\n" " vec3 texcoord = te.xyz;\n" "\n" " vec4 previousColor = texture3D( baseTexture, texcoord);\n" @@ -78,7 +79,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)\n" + " while(num_iterations>0.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 97b4ef05b..584fed6e3 100644 --- a/src/osgVolume/Shaders/volume_lit_frag.cpp +++ b/src/osgVolume/Shaders/volume_lit_frag.cpp @@ -62,12 +62,14 @@ char volume_lit_frag[] = "uniform sampler3D baseTexture;\n" " t0 = t0 * texgen;\n" " te = te * texgen;\n" "\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" + " const float min_iterations = 2.0;\n" + " const float max_iterations = 2048.0;\n" + " float num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n" + " if (num_iterationsmax_iterations) num_iterations = max_iterations;\n" + " else if (num_iterations!=num_iterations) num_iterations = max_iterations;\n" "\n" - " vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1);\n" + " vec3 deltaTexCoord=(te-t0).xyz/(num_iterations-1.0);\n" " vec3 texcoord = t0.xyz;\n" "\n" " float normalSampleDistance = 1.0/512.0;\n" @@ -76,7 +78,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)\n" + " while(num_iterations>0.0)\n" " {\n" " vec4 color = texture3D( baseTexture, texcoord);\n" "\n" diff --git a/src/osgVolume/Shaders/volume_lit_tf_frag.cpp b/src/osgVolume/Shaders/volume_lit_tf_frag.cpp index 63e02dc2e..08c74b4d5 100644 --- a/src/osgVolume/Shaders/volume_lit_tf_frag.cpp +++ b/src/osgVolume/Shaders/volume_lit_tf_frag.cpp @@ -69,12 +69,14 @@ char volume_lit_tf_frag[] = "uniform sampler3D baseTexture;\n" "\n" " vec3 eyeDirection = normalize((te-t0).xyz);\n" "\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" + " const float min_iterations = 2.0;\n" + " const float max_iterations = 2048.0;\n" + " float num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n" + " if (num_iterationsmax_iterations) num_iterations = max_iterations;\n" + " else if (num_iterations!=num_iterations) num_iterations = max_iterations;\n" "\n" - " vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1);\n" + " vec3 deltaTexCoord=(te-t0).xyz/(num_iterations-1.0);\n" " vec3 texcoord = t0.xyz;\n" "\n" " float normalSampleDistance = 1.0/512.0;\n" @@ -83,7 +85,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)\n" + " while(num_iterations>0.0)\n" " {\n" " float v = texture3D( baseTexture, texcoord).a * tfScale + tfOffset;\n" " vec4 color = texture1D( tfTexture, v);\n" diff --git a/src/osgVolume/Shaders/volume_mip_frag.cpp b/src/osgVolume/Shaders/volume_mip_frag.cpp index c399831c5..5299c6bbc 100644 --- a/src/osgVolume/Shaders/volume_mip_frag.cpp +++ b/src/osgVolume/Shaders/volume_mip_frag.cpp @@ -61,16 +61,18 @@ char volume_mip_frag[] = "uniform sampler3D baseTexture;\n" " t0 = t0 * texgen;\n" " te = te * texgen;\n" "\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" + " const float min_iterations = 2.0;\n" + " const float max_iterations = 2048.0;\n" + " float num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n" + " if (num_iterationsmax_iterations) num_iterations = max_iterations;\n" + " else if (num_iterations!=num_iterations) num_iterations = max_iterations;\n" "\n" - " vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1);\n" + " vec3 deltaTexCoord=(te-t0).xyz/(num_iterations-1.0);\n" " vec3 texcoord = t0.xyz;\n" "\n" " vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0);\n" - " while(num_iterations>0)\n" + " while(num_iterations>0.0)\n" " {\n" " vec4 color = texture3D( baseTexture, texcoord);\n" " if (fragColor.wmax_iteratrions) num_iterations = max_iteratrions;\n" + " const float min_iterations = 2.0;\n" + " const float max_iterations = 2048.0;\n" + " float num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n" + " if (num_iterationsmax_iterations) num_iterations = max_iterations;\n" + " else if (num_iterations!=num_iterations) num_iterations = max_iterations;\n" "\n" - " vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1);\n" + " vec3 deltaTexCoord=(te-t0).xyz/(num_iterations-1.0);\n" " vec3 texcoord = t0.xyz;\n" "\n" " vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0);\n" - " while(num_iterations>0)\n" + " while(num_iterations>0.0)\n" " {\n" " float v = texture3D( baseTexture, texcoord).a * tfScale + tfOffset;\n" " vec4 color = texture1D( tfTexture, v);\n" diff --git a/src/osgVolume/Shaders/volume_tf_iso_frag.cpp b/src/osgVolume/Shaders/volume_tf_iso_frag.cpp index e0df5217c..76f4b85e0 100644 --- a/src/osgVolume/Shaders/volume_tf_iso_frag.cpp +++ b/src/osgVolume/Shaders/volume_tf_iso_frag.cpp @@ -67,13 +67,15 @@ char volume_tf_iso_frag[] = "uniform sampler3D baseTexture;\n" " t0 = t0 * texgen;\n" " te = te * texgen;\n" "\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" + " const float min_iterations = 2.0;\n" + " const float max_iterations = 2048.0;\n" + " float num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n" + " if (num_iterationsmax_iterations) num_iterations = max_iterations;\n" + " else if (num_iterations!=num_iterations) num_iterations = max_iterations;\n" "\n" "\n" - " vec3 deltaTexCoord=(t0-te).xyz/float(num_iterations-1);\n" + " vec3 deltaTexCoord=(t0-te).xyz/float(num_iterations-1.0);\n" " vec3 texcoord = te.xyz;\n" " float previousV = texture3D( baseTexture, texcoord).a;\n" "\n" @@ -82,7 +84,7 @@ char volume_tf_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)\n" + " while(num_iterations>0.0)\n" " {\n" "\n" " float v = texture3D( baseTexture, texcoord).a;\n" diff --git a/src/osgVolume/Shaders/volume_tf_mip_frag.cpp b/src/osgVolume/Shaders/volume_tf_mip_frag.cpp index fed843298..31f4b2545 100644 --- a/src/osgVolume/Shaders/volume_tf_mip_frag.cpp +++ b/src/osgVolume/Shaders/volume_tf_mip_frag.cpp @@ -66,16 +66,18 @@ char volume_tf_mip_frag[] = "uniform sampler3D baseTexture;\n" " t0 = t0 * texgen;\n" " te = te * texgen;\n" "\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" + " const float min_iterations = 2.0;\n" + " const float max_iterations = 2048.0;\n" + " float num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n" + " if (num_iterationsmax_iterations) num_iterations = max_iterations;\n" + " else if (num_iterations!=num_iterations) num_iterations = max_iterations;\n" "\n" - " vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1);\n" + " vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1.0);\n" " vec3 texcoord = t0.xyz;\n" "\n" " vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0);\n" - " while(num_iterations>0)\n" + " while(num_iterations>0.0)\n" " {\n" " float v = texture3D( baseTexture, texcoord).s * tfScale + tfOffset;\n" " vec4 color = texture1D( tfTexture, v);\n"