Updated shaders from OpenSceneGraph-Data sources

This commit is contained in:
Robert Osfield
2014-06-04 08:59:31 +00:00
parent 6ea4f4a939
commit 35d6cb812f
5 changed files with 37 additions and 44 deletions

View File

@@ -1,7 +1,9 @@
char volume_accumulateSamples_lit_frag[] = "#version 110\n"
"\n"
"uniform sampler3D volumeTexture;\n"
"\n"
"uniform float AlphaFuncValue;\n"
"uniform float TransparencyValue;\n"
"\n"
"varying vec3 lightDirection;\n"
"\n"
@@ -14,11 +16,13 @@ char volume_accumulateSamples_lit_frag[] = "#version 110\n"
" vec3 deltaY = vec3(0.0, normalSampleDistance, 0.0);\n"
" vec3 deltaZ = vec3(0.0, 0.0, normalSampleDistance);\n"
"\n"
" while(num_iterations>0 && fragColor.a<cutoff)\n"
" float transmittance = 1.0;\n"
" float t_cutoff = 1.0-cutoff;\n"
" while(num_iterations>0 && transmittance>=t_cutoff)\n"
" {\n"
" vec4 color = texture3D( volumeTexture, texcoord);\n"
"\n"
" if (color.a>AlphaFuncValue)\n"
" if (color.a>=AlphaFuncValue)\n"
" {\n"
"\n"
" float px = texture3D( volumeTexture, texcoord + deltaX).a;\n"
@@ -40,9 +44,11 @@ char volume_accumulateSamples_lit_frag[] = "#version 110\n"
" color.b *= lightScale;\n"
" }\n"
"\n"
" float r = color.a * ((1.0-fragColor.a)*scale);\n"
" float ca = clamp(color.a*TransparencyValue, 0.0, 1.0);\n"
" float new_transmitance = transmittance*pow(1.0-ca, scale);\n"
" float r = transmittance-new_transmitance;\n"
" fragColor.rgb += color.rgb*r;\n"
" fragColor.a += r;\n"
" transmittance = new_transmitance;\n"
" }\n"
"\n"
" texcoord += dt;\n"
@@ -50,6 +56,7 @@ char volume_accumulateSamples_lit_frag[] = "#version 110\n"
" --num_iterations;\n"
" }\n"
"\n"
" fragColor.a = clamp(1.0-transmittance, 0.0, 1.0);\n"
" if (num_iterations>0) fragColor.a = 1.0;\n"
"\n"
" return fragColor;\n"

View File

@@ -6,37 +6,28 @@ char volume_accumulateSamples_lit_tf_frag[] = "#version 110\n"
"uniform float tfScale;\n"
"uniform float tfOffset;\n"
"uniform float TransparencyValue;\n"
"\n"
"uniform float AlphaFuncValue;\n"
"\n"
"varying vec3 lightDirection;\n"
"\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"
" float normalSampleDistance = length(dt);\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"
" vec3 texcoord = te.xyz;\n"
"\n"
" // scale = mix(scale, 1.0, 1.0);\n"
" //scale = mix(scale, 1.0, 0.75);\n"
"\n"
" // scale = 4.0;\n"
" if (scale>=1.0)\n"
" {\n"
" return vec4(1.0,1.0,1.0,1.0);\n"
" scale = 1.0;\n"
" }\n"
"\n"
" while(num_iterations>0 && fragColor.a<cutoff)\n"
" float transmittance = 1.0;\n"
" float t_cutoff = 1.0-cutoff;\n"
" while(num_iterations>0 && transmittance>=t_cutoff)\n"
" {\n"
" float a = texture3D( volumeTexture, texcoord).a;\n"
" float v = a * tfScale + tfOffset;\n"
" vec4 color = texture1D( tfTexture, v);\n"
"\n"
" if (a>AlphaFuncValue)\n"
" if (a>=AlphaFuncValue)\n"
" {\n"
"\n"
" float px = texture3D( volumeTexture, texcoord + deltaX).a;\n"
@@ -58,22 +49,11 @@ char volume_accumulateSamples_lit_tf_frag[] = "#version 110\n"
" color.b *= lightScale;\n"
" }\n"
"\n"
"#if 0\n"
" float r = color.a * (1.0-fragColor.a)*scale;\n"
" float ca = clamp(color.a*TransparencyValue, 0.0, 1.0);\n"
" float new_transmitance = transmittance*pow(1.0-ca, scale);\n"
" float r = transmittance-new_transmitance;\n"
" fragColor.rgb += color.rgb*r;\n"
" fragColor.a += r;\n"
"#else\n"
" if (color.a<fragColor.a)\n"
" {\n"
" float r = (1.0-fragColor.a)*scale;\n"
" fragColor.rgb += color.rgb*r;\n"
" fragColor.a += color.a * r;\n"
" }\n"
" else\n"
" {\n"
" fragColor = color;\n"
" }\n"
"#endif\n"
" transmittance = new_transmitance;\n"
" }\n"
"\n"
" texcoord += dt;\n"
@@ -81,8 +61,8 @@ char volume_accumulateSamples_lit_tf_frag[] = "#version 110\n"
" --num_iterations;\n"
" }\n"
"\n"
" fragColor.a = clamp(1.0-transmittance, 0.0, 1.0);\n"
" if (num_iterations>0) fragColor.a = 1.0;\n"
" if (fragColor.w<AlphaFuncValue) fragColor.w = 0.0;\n"
"\n"
" return fragColor;\n"
"}\n"

View File

@@ -10,7 +10,7 @@ char volume_accumulateSamples_mip_frag[] = "#version 110\n"
" {\n"
" vec4 color = texture3D( volumeTexture, texcoord);\n"
"\n"
" if (color.a>fragColor.a)\n"
" if (colorcolor.a>AlphaFuncValue && color.a>fragColor.a)\n"
" {\n"
" fragColor = color;\n"
" }\n"

View File

@@ -2,21 +2,26 @@ char volume_accumulateSamples_standard_frag[] = "#version 110\n"
"\n"
"uniform sampler3D volumeTexture;\n"
"\n"
"uniform float TransparencyValue;\n"
"uniform float AlphaFuncValue;\n"
"\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"
" while(num_iterations>0 && fragColor.a<cutoff)\n"
" float transmittance = 1.0;\n"
" float t_cutoff = 1.0-cutoff;\n"
" while(num_iterations>0 && transmittance>=t_cutoff)\n"
" {\n"
" vec4 color = texture3D( volumeTexture, texcoord);\n"
"\n"
" if (color.a>AlphaFuncValue)\n"
" if (color.a>=AlphaFuncValue)\n"
" {\n"
" float r = color.a * ((1.0-fragColor.a)*scale);\n"
" float ca = clamp(color.a*TransparencyValue, 0.0, 1.0);\n"
" float new_transmitance = transmittance*pow(1.0-ca, scale);\n"
" float r = transmittance-new_transmitance;\n"
" fragColor.rgb += color.rgb*r;\n"
" fragColor.a += r;\n"
" transmittance = new_transmitance;\n"
" }\n"
"\n"
" texcoord += dt;\n"
@@ -24,6 +29,7 @@ char volume_accumulateSamples_standard_frag[] = "#version 110\n"
" --num_iterations;\n"
" }\n"
"\n"
" fragColor.a = clamp(1.0-transmittance, 0.0, 1.0);\n"
" if (num_iterations>0) fragColor.a = 1.0;\n"
"\n"
" return fragColor;\n"

View File

@@ -1,13 +1,14 @@
char volume_multipass_vert[] = "#version 110\n"
"\n"
"uniform mat4 texgen;\n"
"uniform mat4 eyeToTile;\n"
"uniform mat4 tileToImage;\n"
"\n"
"varying vec4 cameraPos;\n"
"varying vec4 vertexPos;\n"
"varying vec3 lightDirection;\n"
"varying mat4 texgen_withProjectionMatrixInverse;\n"
"varying vec4 baseColor;\n"
"\n"
"varying mat4 texgen_eyeToTile;\n"
"\n"
"varying float near;\n"
"varying float far;\n"
"varying float near_mult_far;\n"
@@ -24,7 +25,6 @@ char volume_multipass_vert[] = "#version 110\n"
"\n"
" gl_Position = ftransform();\n"
"\n"
" cameraPos = gl_ModelViewMatrixInverse * vec4(0,0,0,1);\n"
" vertexPos = gl_Vertex;\n"
" baseColor = gl_FrontMaterial.diffuse;\n"
"\n"
@@ -40,6 +40,6 @@ char volume_multipass_vert[] = "#version 110\n"
" lightDirection = normalize((lightPosition-vertexPos).xyz);\n"
" }\n"
"\n"
" texgen_withProjectionMatrixInverse = texgen * gl_ProjectionMatrixInverse;\n"
" texgen_eyeToTile = eyeToTile * gl_ProjectionMatrixInverse;\n"
"}\n"
"\n";