Updated shaders from OpenSceneGraph-Data.

git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@15059 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
Robert Osfield 2015-08-06 10:09:29 +00:00
parent 687e77ddc9
commit d205919881
8 changed files with 66 additions and 102 deletions

View File

@ -9,7 +9,7 @@ char volume_frag[] = "uniform sampler3D baseTexture;\n"
"varying vec4 baseColor;\n" "varying vec4 baseColor;\n"
"\n" "\n"
"void main(void)\n" "void main(void)\n"
"{ \n" "{\n"
" vec4 t0 = vertexPos;\n" " vec4 t0 = vertexPos;\n"
" vec4 te = cameraPos;\n" " vec4 te = cameraPos;\n"
"\n" "\n"
@ -61,20 +61,16 @@ char volume_frag[] = "uniform sampler3D baseTexture;\n"
" t0 = t0 * texgen;\n" " t0 = t0 * texgen;\n"
" te = te * texgen;\n" " te = te * texgen;\n"
"\n" "\n"
" const float max_iteratrions = 2048.0;\n" " const int max_iteratrions = 2048;\n"
" float num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n" " int num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n"
" if (num_iterations<2.0) num_iterations = 2.0;\n" " if (num_iterations<2) num_iterations = 2;\n"
" if (num_iterations>max_iteratrions) num_iterations = max_iteratrions;\n"
"\n" "\n"
" if (num_iterations>max_iteratrions) \n" " vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1);\n"
" {\n"
" num_iterations = max_iteratrions;\n"
" }\n"
"\n"
" vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1.0);\n"
" vec3 texcoord = t0.xyz;\n" " vec3 texcoord = t0.xyz;\n"
"\n" "\n"
" vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0); \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" " {\n"
" vec4 color = texture3D( baseTexture, texcoord);\n" " vec4 color = texture3D( baseTexture, texcoord);\n"
" float r = color[3]*TransparencyValue;\n" " float r = color[3]*TransparencyValue;\n"
@ -88,7 +84,7 @@ char volume_frag[] = "uniform sampler3D baseTexture;\n"
" {\n" " {\n"
" fragColor = color;\n" " fragColor = color;\n"
" }\n" " }\n"
" texcoord += deltaTexCoord; \n" " texcoord += deltaTexCoord;\n"
"\n" "\n"
" --num_iterations;\n" " --num_iterations;\n"
" }\n" " }\n"
@ -99,7 +95,6 @@ char volume_frag[] = "uniform sampler3D baseTexture;\n"
" fragColor *= baseColor;\n" " fragColor *= baseColor;\n"
"\n" "\n"
" if (fragColor.w<AlphaFuncValue) discard;\n" " if (fragColor.w<AlphaFuncValue) discard;\n"
" \n"
" gl_FragColor = fragColor;\n" " gl_FragColor = fragColor;\n"
"}\n" "}\n"
"\n"; "\n";

View File

@ -10,7 +10,7 @@ char volume_iso_frag[] = "uniform sampler3D baseTexture;\n"
"varying vec4 baseColor;\n" "varying vec4 baseColor;\n"
"\n" "\n"
"void main(void)\n" "void main(void)\n"
"{ \n" "{\n"
" vec4 t0 = vertexPos;\n" " vec4 t0 = vertexPos;\n"
" vec4 te = cameraPos;\n" " vec4 te = cameraPos;\n"
"\n" "\n"
@ -62,16 +62,13 @@ char volume_iso_frag[] = "uniform sampler3D baseTexture;\n"
" t0 = t0 * texgen;\n" " t0 = t0 * texgen;\n"
" te = te * texgen;\n" " te = te * texgen;\n"
"\n" "\n"
" const float max_iteratrions = 2048.0;\n" " const int max_iteratrions = 2048;\n"
" float num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n" " int num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n"
" if (num_iterations<2.0) num_iterations = 2.0;\n" " if (num_iterations<2) num_iterations = 2;\n"
" if (num_iterations>max_iteratrions) num_iterations = max_iteratrions;\n"
"\n" "\n"
" if (num_iterations>max_iteratrions) \n"
" {\n"
" num_iterations = max_iteratrions;\n"
" }\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" " vec3 texcoord = te.xyz;\n"
"\n" "\n"
" vec4 previousColor = texture3D( baseTexture, texcoord);\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 deltaY = vec3(0.0, normalSampleDistance, 0.0);\n"
" vec3 deltaZ = vec3(0.0, 0.0, normalSampleDistance);\n" " vec3 deltaZ = vec3(0.0, 0.0, normalSampleDistance);\n"
" \n" " \n"
" while(num_iterations>0.0)\n" " while(num_iterations>0)\n"
" {\n" " {\n"
" vec4 color = texture3D( baseTexture, texcoord);\n" " vec4 color = texture3D( baseTexture, texcoord);\n"
"\n" "\n"

View File

@ -10,7 +10,7 @@ char volume_lit_frag[] = "uniform sampler3D baseTexture;\n"
"varying vec4 baseColor;\n" "varying vec4 baseColor;\n"
"\n" "\n"
"void main(void)\n" "void main(void)\n"
"{ \n" "{\n"
" vec4 t0 = vertexPos;\n" " vec4 t0 = vertexPos;\n"
" vec4 te = cameraPos;\n" " vec4 te = cameraPos;\n"
"\n" "\n"
@ -62,16 +62,12 @@ char volume_lit_frag[] = "uniform sampler3D baseTexture;\n"
" t0 = t0 * texgen;\n" " t0 = t0 * texgen;\n"
" te = te * texgen;\n" " te = te * texgen;\n"
"\n" "\n"
" const float max_iteratrions = 2048.0;\n" " const int max_iteratrions = 2048;\n"
" float num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n" " int num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n"
" if (num_iterations<2.0) num_iterations = 2.0;\n" " if (num_iterations<2) num_iterations = 2;\n"
" if (num_iterations>max_iteratrions) num_iterations = max_iteratrions;\n"
"\n" "\n"
" if (num_iterations>max_iteratrions) \n" " vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1);\n"
" {\n"
" num_iterations = max_iteratrions;\n"
" }\n"
"\n"
" vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1.0);\n"
" vec3 texcoord = t0.xyz;\n" " vec3 texcoord = t0.xyz;\n"
"\n" "\n"
" float normalSampleDistance = 1.0/512.0;\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" " vec3 deltaZ = vec3(0.0, 0.0, normalSampleDistance);\n"
"\n" "\n"
" vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0); \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" " {\n"
" vec4 color = texture3D( baseTexture, texcoord);\n" " vec4 color = texture3D( baseTexture, texcoord);\n"
"\n" "\n"
@ -115,18 +111,17 @@ char volume_lit_frag[] = "uniform sampler3D baseTexture;\n"
" {\n" " {\n"
" fragColor = color;\n" " fragColor = color;\n"
" }\n" " }\n"
" texcoord += deltaTexCoord; \n" " texcoord += deltaTexCoord;\n"
"\n" "\n"
" --num_iterations;\n" " --num_iterations;\n"
" }\n" " }\n"
"\n" "\n"
" fragColor.w *= TransparencyValue;\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" "\n"
" fragColor *= baseColor;\n" " fragColor *= baseColor;\n"
"\n" "\n"
" if (fragColor.w<AlphaFuncValue) discard;\n" " if (fragColor.w<AlphaFuncValue) discard;\n"
" \n"
" gl_FragColor = fragColor;\n" " gl_FragColor = fragColor;\n"
"}\n" "}\n"
"\n"; "\n";

View File

@ -15,7 +15,7 @@ char volume_lit_tf_frag[] = "uniform sampler3D baseTexture;\n"
"varying vec4 baseColor;\n" "varying vec4 baseColor;\n"
"\n" "\n"
"void main(void)\n" "void main(void)\n"
"{ \n" "{\n"
" vec4 t0 = vertexPos;\n" " vec4 t0 = vertexPos;\n"
" vec4 te = cameraPos;\n" " vec4 te = cameraPos;\n"
"\n" "\n"
@ -69,16 +69,12 @@ char volume_lit_tf_frag[] = "uniform sampler3D baseTexture;\n"
"\n" "\n"
" vec3 eyeDirection = normalize((te-t0).xyz);\n" " vec3 eyeDirection = normalize((te-t0).xyz);\n"
"\n" "\n"
" const float max_iteratrions = 2048.0;\n" " const int max_iteratrions = 2048;\n"
" float num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n" " int num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n"
" if (num_iterations<2.0) num_iterations = 2.0;\n" " if (num_iterations<2) num_iterations = 2;\n"
" if (num_iterations>max_iteratrions) num_iterations = max_iteratrions;\n"
"\n" "\n"
" if (num_iterations>max_iteratrions) \n" " vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1);\n"
" {\n"
" num_iterations = max_iteratrions;\n"
" }\n"
"\n"
" vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1.0);\n"
" vec3 texcoord = t0.xyz;\n" " vec3 texcoord = t0.xyz;\n"
"\n" "\n"
" float normalSampleDistance = 1.0/512.0;\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" " vec3 deltaZ = vec3(0.0, 0.0, normalSampleDistance);\n"
"\n" "\n"
" vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0); \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" " {\n"
" float v = texture3D( baseTexture, texcoord).a * tfScale + tfOffset;\n" " float v = texture3D( baseTexture, texcoord).a * tfScale + tfOffset;\n"
" vec4 color = texture1D( tfTexture, v);\n" " vec4 color = texture1D( tfTexture, v);\n"
@ -112,7 +108,6 @@ char volume_lit_tf_frag[] = "uniform sampler3D baseTexture;\n"
" color.z *= lightScale;\n" " color.z *= lightScale;\n"
" }\n" " }\n"
"\n" "\n"
"\n"
" float r = color[3]*TransparencyValue;\n" " float r = color[3]*TransparencyValue;\n"
" if (r>AlphaFuncValue)\n" " if (r>AlphaFuncValue)\n"
" {\n" " {\n"
@ -124,7 +119,7 @@ char volume_lit_tf_frag[] = "uniform sampler3D baseTexture;\n"
" {\n" " {\n"
" fragColor = color;\n" " fragColor = color;\n"
" }\n" " }\n"
" texcoord += deltaTexCoord; \n" " texcoord += deltaTexCoord;\n"
"\n" "\n"
" --num_iterations;\n" " --num_iterations;\n"
" }\n" " }\n"

View File

@ -9,7 +9,7 @@ char volume_mip_frag[] = "uniform sampler3D baseTexture;\n"
"varying vec4 baseColor;\n" "varying vec4 baseColor;\n"
"\n" "\n"
"void main(void)\n" "void main(void)\n"
"{ \n" "{\n"
" vec4 t0 = vertexPos;\n" " vec4 t0 = vertexPos;\n"
" vec4 te = cameraPos;\n" " vec4 te = cameraPos;\n"
"\n" "\n"
@ -61,38 +61,33 @@ char volume_mip_frag[] = "uniform sampler3D baseTexture;\n"
" t0 = t0 * texgen;\n" " t0 = t0 * texgen;\n"
" te = te * texgen;\n" " te = te * texgen;\n"
"\n" "\n"
" const float max_iteratrions = 2048.0;\n" " const int max_iteratrions = 2048;\n"
" float num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n" " int num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n"
" if (num_iterations<2.0) num_iterations = 2.0;\n" " if (num_iterations<2) num_iterations = 2;\n"
" if (num_iterations>max_iteratrions) num_iterations = max_iteratrions;\n"
"\n" "\n"
" if (num_iterations>max_iteratrions) \n" " vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1);\n"
" {\n"
" num_iterations = max_iteratrions;\n"
" }\n"
"\n"
" vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1.0);\n"
" vec3 texcoord = t0.xyz;\n" " vec3 texcoord = t0.xyz;\n"
"\n" "\n"
" vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0); \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" " {\n"
" vec4 color = texture3D( baseTexture, texcoord);\n" " vec4 color = texture3D( baseTexture, texcoord);\n"
" if (fragColor.w<color.w)\n" " if (fragColor.w<color.w)\n"
" {\n" " {\n"
" fragColor = color;\n" " fragColor = color;\n"
" }\n" " }\n"
" texcoord += deltaTexCoord; \n" " texcoord += deltaTexCoord;\n"
"\n" "\n"
" --num_iterations;\n" " --num_iterations;\n"
" }\n" " }\n"
"\n" "\n"
" fragColor.w *= TransparencyValue;\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" "\n"
" fragColor *= baseColor;\n" " fragColor *= baseColor;\n"
"\n" "\n"
" if (fragColor.w<AlphaFuncValue) discard;\n" " if (fragColor.w<AlphaFuncValue) discard;\n"
" \n"
" gl_FragColor = fragColor;\n" " gl_FragColor = fragColor;\n"
"}\n" "}\n"
"\n"; "\n";

View File

@ -14,7 +14,7 @@ char volume_tf_frag[] = "uniform sampler3D baseTexture;\n"
"varying vec4 baseColor;\n" "varying vec4 baseColor;\n"
"\n" "\n"
"void main(void)\n" "void main(void)\n"
"{ \n" "{\n"
" vec4 t0 = vertexPos;\n" " vec4 t0 = vertexPos;\n"
" vec4 te = cameraPos;\n" " vec4 te = cameraPos;\n"
"\n" "\n"
@ -66,20 +66,16 @@ char volume_tf_frag[] = "uniform sampler3D baseTexture;\n"
" t0 = t0 * texgen;\n" " t0 = t0 * texgen;\n"
" te = te * texgen;\n" " te = te * texgen;\n"
"\n" "\n"
" const float max_iteratrions = 2048.0;\n" " const int max_iteratrions = 2048;\n"
" float num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n" " int num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n"
" if (num_iterations<2.0) num_iterations = 2.0;\n" " if (num_iterations<2) num_iterations = 2;\n"
" if (num_iterations>max_iteratrions) num_iterations = max_iteratrions;\n"
"\n" "\n"
" if (num_iterations>max_iteratrions) \n" " vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1);\n"
" {\n"
" num_iterations = max_iteratrions;\n"
" }\n"
"\n"
" vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1.0);\n"
" vec3 texcoord = t0.xyz;\n" " vec3 texcoord = t0.xyz;\n"
"\n" "\n"
" vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0); \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" " {\n"
" float v = texture3D( baseTexture, texcoord).a * tfScale + tfOffset;\n" " float v = texture3D( baseTexture, texcoord).a * tfScale + tfOffset;\n"
" vec4 color = texture1D( tfTexture, v);\n" " vec4 color = texture1D( tfTexture, v);\n"
@ -95,7 +91,7 @@ char volume_tf_frag[] = "uniform sampler3D baseTexture;\n"
" {\n" " {\n"
" fragColor = color;\n" " fragColor = color;\n"
" }\n" " }\n"
" texcoord += deltaTexCoord; \n" " texcoord += deltaTexCoord;\n"
"\n" "\n"
" --num_iterations;\n" " --num_iterations;\n"
" }\n" " }\n"
@ -106,7 +102,6 @@ char volume_tf_frag[] = "uniform sampler3D baseTexture;\n"
" fragColor *= baseColor;\n" " fragColor *= baseColor;\n"
"\n" "\n"
" if (fragColor.w<AlphaFuncValue) discard;\n" " if (fragColor.w<AlphaFuncValue) discard;\n"
" \n"
" gl_FragColor = fragColor;\n" " gl_FragColor = fragColor;\n"
"}\n" "}\n"
"\n"; "\n";

View File

@ -15,7 +15,7 @@ char volume_tf_iso_frag[] = "uniform sampler3D baseTexture;\n"
"varying vec4 baseColor;\n" "varying vec4 baseColor;\n"
"\n" "\n"
"void main(void)\n" "void main(void)\n"
"{ \n" "{\n"
" vec4 t0 = vertexPos;\n" " vec4 t0 = vertexPos;\n"
" vec4 te = cameraPos;\n" " vec4 te = cameraPos;\n"
"\n" "\n"
@ -67,16 +67,13 @@ char volume_tf_iso_frag[] = "uniform sampler3D baseTexture;\n"
" t0 = t0 * texgen;\n" " t0 = t0 * texgen;\n"
" te = te * texgen;\n" " te = te * texgen;\n"
"\n" "\n"
" const float max_iteratrions = 2048.0;\n" " const int max_iteratrions = 2048;\n"
" float num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n" " int num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n"
" if (num_iterations<2.0) num_iterations = 2.0;\n" " if (num_iterations<2) num_iterations = 2;\n"
" if (num_iterations>max_iteratrions) num_iterations = max_iteratrions;\n"
"\n" "\n"
" if (num_iterations>max_iteratrions)\n"
" {\n"
" num_iterations = max_iteratrions;\n"
" }\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" " vec3 texcoord = te.xyz;\n"
" float previousV = texture3D( baseTexture, texcoord).a;\n" " float previousV = texture3D( baseTexture, texcoord).a;\n"
"\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 deltaX = vec3(normalSampleDistance, 0.0, 0.0);\n"
" vec3 deltaY = vec3(0.0, normalSampleDistance, 0.0);\n" " vec3 deltaY = vec3(0.0, normalSampleDistance, 0.0);\n"
" vec3 deltaZ = vec3(0.0, 0.0, normalSampleDistance);\n" " vec3 deltaZ = vec3(0.0, 0.0, normalSampleDistance);\n"
"\n" " \n"
" while(num_iterations>0.0)\n" " while(num_iterations>0)\n"
" {\n" " {\n"
"\n" "\n"
" float v = texture3D( baseTexture, texcoord).a;\n" " float v = texture3D( baseTexture, texcoord).a;\n"
@ -134,6 +131,5 @@ char volume_tf_iso_frag[] = "uniform sampler3D baseTexture;\n"
"\n" "\n"
" // we didn't find an intersection so just discard fragment\n" " // we didn't find an intersection so just discard fragment\n"
" discard;\n" " discard;\n"
"\n"
"}\n" "}\n"
"\n"; "\n";

View File

@ -66,20 +66,16 @@ char volume_tf_mip_frag[] = "uniform sampler3D baseTexture;\n"
" t0 = t0 * texgen;\n" " t0 = t0 * texgen;\n"
" te = te * texgen;\n" " te = te * texgen;\n"
"\n" "\n"
" const float max_iteratrions = 2048.0;\n" " const int max_iteratrions = 2048;\n"
" float num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n" " int num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n"
" if (num_iterations<2.0) num_iterations = 2.0;\n" " if (num_iterations<2) num_iterations = 2;\n"
" if (num_iterations>max_iteratrions) num_iterations = max_iteratrions;\n"
"\n" "\n"
" if (num_iterations>max_iteratrions)\n" " vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1);\n"
" {\n"
" num_iterations = max_iteratrions;\n"
" }\n"
"\n"
" vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1.0);\n"
" vec3 texcoord = t0.xyz;\n" " vec3 texcoord = t0.xyz;\n"
"\n" "\n"
" vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0);\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" " {\n"
" float v = texture3D( baseTexture, texcoord).s * tfScale + tfOffset;\n" " float v = texture3D( baseTexture, texcoord).s * tfScale + tfOffset;\n"
" vec4 color = texture1D( tfTexture, v);\n" " vec4 color = texture1D( tfTexture, v);\n"