Improved shaders to better handle region of constant values when doing normal generation
This commit is contained in:
@@ -95,5 +95,4 @@ char volume_frag[] = "uniform sampler3D baseTexture;\n"
|
||||
" if (fragColor.w<AlphaFuncValue) discard;\n"
|
||||
" \n"
|
||||
" gl_FragColor = fragColor;\n"
|
||||
"}\n"
|
||||
"\n";
|
||||
"}\n";
|
||||
|
||||
@@ -72,7 +72,6 @@ char volume_iso_frag[] = "uniform sampler3D baseTexture;\n"
|
||||
" vec3 deltaTexCoord=(t0-te)/float(num_iterations-1.0);\n"
|
||||
" vec3 texcoord = te;\n"
|
||||
"\n"
|
||||
" vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0); \n"
|
||||
" vec4 previousColor = texture3D( baseTexture, texcoord);\n"
|
||||
" \n"
|
||||
" float normalSampleDistance = 1.0/512.0;\n"
|
||||
@@ -100,25 +99,18 @@ char volume_iso_frag[] = "uniform sampler3D baseTexture;\n"
|
||||
" float nz = texture3D( baseTexture, texcoord - deltaZ).a;\n"
|
||||
" \n"
|
||||
" vec3 grad = vec3(px-nx, py-ny, pz-nz);\n"
|
||||
" vec3 normal = normalize(grad);\n"
|
||||
" if (grad.x!=0.0 || grad.y!=0.0 || grad.z!=0.0)\n"
|
||||
" {\n"
|
||||
" vec3 normal = normalize(grad);\n"
|
||||
" float lightScale = 0.1 + abs(dot(normal.xyz, eyeDirection))*0.9;\n"
|
||||
"\n"
|
||||
" float lightScale = 0.1 + abs(dot(normal.xyz, eyeDirection))*0.9;\n"
|
||||
" color.x *= lightScale;\n"
|
||||
" color.y *= lightScale;\n"
|
||||
" color.z *= lightScale;\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" \n"
|
||||
"#if 0\n"
|
||||
" color.x *= lightScale;\n"
|
||||
" color.y *= lightScale;\n"
|
||||
" color.z *= lightScale;\n"
|
||||
"#else\n"
|
||||
" color.x = lightScale;\n"
|
||||
" color.y = lightScale;\n"
|
||||
" color.z = lightScale;\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
" fragColor = vec4(lightScale, lightScale, lightScale, 1.0);\n"
|
||||
" \n"
|
||||
" if (fragColor.w>1.0) fragColor.w = 1.0; \n"
|
||||
" gl_FragColor = fragColor;\n"
|
||||
" if (color.w>1.0) color.w = 1.0; \n"
|
||||
" gl_FragColor = color;\n"
|
||||
" \n"
|
||||
" return;\n"
|
||||
" }\n"
|
||||
@@ -132,5 +124,4 @@ char volume_iso_frag[] = "uniform sampler3D baseTexture;\n"
|
||||
"\n"
|
||||
" // we didn't find an intersection so just discard fragment\n"
|
||||
" discard;\n"
|
||||
"}\n"
|
||||
"\n";
|
||||
"}\n";
|
||||
|
||||
@@ -80,6 +80,7 @@ char volume_lit_frag[] = "uniform sampler3D baseTexture;\n"
|
||||
" while(num_iterations>0.0)\n"
|
||||
" {\n"
|
||||
" vec4 color = texture3D( baseTexture, texcoord);\n"
|
||||
"\n"
|
||||
" float a = color.a;\n"
|
||||
" float px = texture3D( baseTexture, texcoord + deltaX).a;\n"
|
||||
" float py = texture3D( baseTexture, texcoord + deltaY).a;\n"
|
||||
@@ -90,13 +91,15 @@ char volume_lit_frag[] = "uniform sampler3D baseTexture;\n"
|
||||
" float nz = texture3D( baseTexture, texcoord - deltaZ).a;\n"
|
||||
"\n"
|
||||
" vec3 grad = vec3(px-nx, py-ny, pz-nz);\n"
|
||||
" vec3 normal = normalize(grad);\n"
|
||||
" if (grad.x!=0.0 || grad.y!=0.0 || grad.z!=0.0)\n"
|
||||
" {\n"
|
||||
" vec3 normal = normalize(grad);\n"
|
||||
" float lightScale = 0.1 + abs(dot(normal.xyz, eyeDirection))*0.9;\n"
|
||||
"\n"
|
||||
" float lightScale = 0.1 + abs(dot(normal.xyz, eyeDirection));\n"
|
||||
"\n"
|
||||
" color.x *= lightScale;\n"
|
||||
" color.y *= lightScale;\n"
|
||||
" color.z *= lightScale;\n"
|
||||
" color.x *= lightScale;\n"
|
||||
" color.y *= lightScale;\n"
|
||||
" color.z *= lightScale;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" float r = color[3]*TransparencyValue;\n"
|
||||
" if (r>AlphaFuncValue)\n"
|
||||
@@ -120,5 +123,4 @@ char volume_lit_frag[] = "uniform sampler3D baseTexture;\n"
|
||||
" if (fragColor.w<AlphaFuncValue) discard;\n"
|
||||
" \n"
|
||||
" gl_FragColor = fragColor;\n"
|
||||
"}\n"
|
||||
"\n";
|
||||
"}\n";
|
||||
|
||||
@@ -93,13 +93,16 @@ char volume_lit_tf_frag[] = "uniform sampler3D baseTexture;\n"
|
||||
" float nz = texture3D( baseTexture, texcoord - deltaZ).a;\n"
|
||||
"\n"
|
||||
" vec3 grad = vec3(px-nx, py-ny, pz-nz);\n"
|
||||
" vec3 normal = normalize(grad);\n"
|
||||
" if (grad.x!=0.0 || grad.y!=0.0 || grad.z!=0.0)\n"
|
||||
" {\n"
|
||||
" vec3 normal = normalize(grad);\n"
|
||||
" float lightScale = 0.1 + abs(dot(normal.xyz, eyeDirection))*0.9;\n"
|
||||
"\n"
|
||||
" float lightScale = 0.1 + abs(dot(normal.xyz, eyeDirection));\n"
|
||||
" color.x *= lightScale;\n"
|
||||
" color.y *= lightScale;\n"
|
||||
" color.z *= lightScale;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" color.x *= lightScale;\n"
|
||||
" color.y *= lightScale;\n"
|
||||
" color.z *= lightScale;\n"
|
||||
"\n"
|
||||
" float r = color[3]*TransparencyValue;\n"
|
||||
" if (r>AlphaFuncValue)\n"
|
||||
@@ -123,5 +126,4 @@ char volume_lit_tf_frag[] = "uniform sampler3D baseTexture;\n"
|
||||
" if (fragColor.w<AlphaFuncValue) discard;\n"
|
||||
" \n"
|
||||
" gl_FragColor = fragColor;\n"
|
||||
"}\n"
|
||||
"\n";
|
||||
"}\n";
|
||||
|
||||
@@ -88,5 +88,4 @@ char volume_mip_frag[] = "uniform sampler3D baseTexture;\n"
|
||||
" if (fragColor.w<AlphaFuncValue) discard;\n"
|
||||
" \n"
|
||||
" gl_FragColor = fragColor;\n"
|
||||
"}\n"
|
||||
"\n";
|
||||
"}\n";
|
||||
|
||||
@@ -98,5 +98,4 @@ char volume_tf_frag[] = "uniform sampler3D baseTexture;\n"
|
||||
" if (fragColor.w<AlphaFuncValue) discard;\n"
|
||||
" \n"
|
||||
" gl_FragColor = fragColor;\n"
|
||||
"}\n"
|
||||
"\n";
|
||||
"}\n";
|
||||
|
||||
@@ -126,5 +126,4 @@ char volume_tf_iso_frag[] = "uniform sampler3D baseTexture;\n"
|
||||
" // we didn't find an intersection so just discard fragment\n"
|
||||
" discard;\n"
|
||||
"\n"
|
||||
"}\n"
|
||||
"\n";
|
||||
"}\n";
|
||||
|
||||
@@ -89,5 +89,4 @@ char volume_tf_mip_frag[] = "uniform sampler3D baseTexture;\n"
|
||||
" if (fragColor.w>1.0) fragColor.w = 1.0; \n"
|
||||
" if (fragColor.w<AlphaFuncValue) discard;\n"
|
||||
" gl_FragColor = fragColor;\n"
|
||||
"}\n"
|
||||
"\n";
|
||||
"}\n";
|
||||
|
||||
Reference in New Issue
Block a user