Skip to content
Snippets Groups Projects

Split Hull Bug Fix

Closed Eric Wait requested to merge bioimage/lever-3d:master into master
+ 46
21
Compare changes
  • Side-by-side
  • Inline

Files

+ 35
18
@@ -274,8 +274,8 @@ void createStaticVolumeShaderText(std::string strChans)
shaderText += "\n";
shaderText += "struct PixelOutputType\n";
shaderText += "{\n";
shaderText += " float4 color : SV_TARGET;\n";
shaderText += " float depth : SV_DEPTH;\n";
shaderText += "\tfloat4 color : SV_TARGET;\n";
shaderText += "\tfloat depth : SV_DEPTH;\n";
shaderText += "};\n";
shaderText += "\n";
shaderText += "Texture3D g_txDiffuse[" + strChans + "] : register( t0 );\n";
@@ -295,14 +295,26 @@ void createStaticVolumeShaderText(std::string strChans)
shaderText += "\tfloat alpha = 0.0f;\n";
shaderText += "\n";
shaderText += "\tfloat4 mainLightDir = float4(-0.5774,-0.5774,0.5774,0);\n";
shaderText += "\tfloat unlitComposite = 0.0f;\n";
shaderText += "\tfloat3 unlitComposite = float3(0.0f,0.0f,0.0f);\n";
shaderText += "\tfloat3 alphaComposite = float3(0.0f,0.0f,0.0f);\n";
shaderText += "\n";
shaderText += "\tint numAlpha = 0;\n";
shaderText += "\tfloat3 grad;\n";
shaderText += "\n";
shaderText += "float maxIntensity = 0;\n";
shaderText += "\n";
shaderText += "\t[unroll(" + strChans + ")] for (int i=0; i<" + strChans + "; ++i)\n";
shaderText += "\t{\n";
shaderText += "\t\tfloat intensity = g_txDiffuse[i].Sample( g_samLinear[i], input.TextureUV );\n";
shaderText += "\t\tintensity = clamp(intensity,ranges[i][0],ranges[i][1]);\n";
shaderText += "\t\tintensity = transferFunctions[i][0]*intensity*intensity+transferFunctions[i][1]*intensity+transferFunctions[i][2];\n";
shaderText += "\t\tif (intensity < 0.2f || channelColor[i].a < 0.01f)\n";
shaderText += "\t\t{\n";
shaderText += "\t\t\tintensity = 0;\n";
shaderText += "\t\t}\n";
//shaderText += "\t\tmaxIntensity = max(intensity*channelColor[i].a,maxIntensity);\n";
shaderText += "\t\tmaxIntensity = max(intensity,maxIntensity);\n";
shaderText += "\n";
shaderText += "\t\tfloat lightMod = 1.0f;\n";
shaderText += "\t\tif(lightOn.x>0)\n";
shaderText += "\t\t{\n";
@@ -313,28 +325,33 @@ void createStaticVolumeShaderText(std::string strChans)
shaderText += "\t\t\tgrad.z = g_txDiffuse[i].Sample(g_samLinear[i], input.TextureUV+gradientSampleDirection[2]) - \n";
shaderText += "\t\t\t\tg_txDiffuse[i].Sample(g_samLinear[i], input.TextureUV-gradientSampleDirection[2]);\n";
shaderText += "\t\t\tgrad = normalize(grad);\n";
shaderText += "\t\t\tlightMod = saturate(dot(grad,mainLightDir)*2.0)*0.7 + 0.3;\n";
shaderText += "\t\t\tlightMod = saturate(dot(grad,mainLightDir)*2.0)*0.65 + 0.35;\n";
shaderText += "\t\t}\n";
shaderText += "\t\tif (channelColor[i].a>0)\n";
shaderText += "\t\t\t++numAlpha;\n";
shaderText += "\n";
shaderText += "\t\talpha += channelColor[i].a;\n";
shaderText += "\t\toutput.color.rgb += (lightMod*intensity*channelColor[i].rgb*channelColor[i].a);\n";
shaderText += "\t\tunlitComposite += intensity*channelColor[i].a;\n";
shaderText += "\t\toutput.color.rgb += (lightMod*intensity*channelColor[i].rgb);\n";
shaderText += "\t\tunlitComposite += intensity*channelColor[i].rgb;\n";
shaderText += "\t\talphaComposite += intensity*channelColor[i].rgb*channelColor[i].a;\n";
shaderText += "\t}\n";
shaderText += "\tif (alpha!=0)\n";
shaderText += "\n";
shaderText += "\tfloat maxComponent = max(max(unlitComposite.r,unlitComposite.g),unlitComposite.b);\n";
shaderText += "\tfloat maxAplha = max(max(alphaComposite.r,alphaComposite.g),alphaComposite.b);\n";
shaderText += "\tif (maxComponent!=0)\n";
shaderText += "\t{\n";
shaderText += "\t\toutput.color.rgb /= maxComponent;\n";
shaderText += "\t\toutput.color.rgb *= maxIntensity;\n";
shaderText += "\t}\n";
shaderText += "\tif (maxAplha!=0)\n";
shaderText += "\t{\n";
shaderText += "\t\toutput.color.rgb /= alpha;\n";
shaderText += "\t\toutput.color.rgb = saturate(output.color.rgb*numAlpha*0.5f);\n";
shaderText += "\t\tunlitComposite /= alpha;\n";
shaderText += "\t\toutput.color.a = alpha / numAlpha;\n";
shaderText += "\t\toutput.color.a = maxAplha;\n";
shaderText += "\t}else{\n";
shaderText += "\t\toutput.color.a = 0;\n";
shaderText += "\t}\n";
shaderText += "\toutput.color.a *= saturate(unlitComposite);\n";
shaderText += "\toutput.color.a = output.color.a*step(0.15,output.color.a);\n";
shaderText += "\n";
shaderText += "\n";
shaderText += "\tif(lightOn.y>0)\n";
shaderText += "\t{\n";
shaderText += "\t\tfloat distMult = (input.Dpth.z<=0) ? (1) : (1-input.Dpth.z);\n";
shaderText += "\t\toutput.color.r *= distMult;\n";
shaderText += "\t\tfloat distMult = (input.Dpth.z<=0) ? (1) : (1-input.Dpth.z);\n";
shaderText += "\t\toutput.color.r *= distMult;\n";
shaderText += "\t\toutput.color.g *= distMult;\n";
shaderText += "\t\toutput.color.b *= distMult;\n";
shaderText += "\t\toutput.color.a *= distMult;\n";
Loading