Skip to content
Snippets Groups Projects
Commit 65ec10c2 authored by Michael Heyde's avatar Michael Heyde
Browse files

fix some possible div zero bugs

parent 018ce484
No related branches found
No related tags found
No related merge requests found
......@@ -151,7 +151,8 @@ public class MultiVolumeRendererShaderSource extends AbstractShaderSource{
"#version "+getShaderLanguageVersion(),
"#line "+Thread.currentThread().getStackTrace()[1].getLineNumber(),
"",
"const int "+scvMaxNumberOfVolumes+" = "+maxNumberOfVolumes+";",
"const int "+scvMaxNumberOfVolumes+" = "+maxNumberOfVolumes+";",
"const float "+scvMinDelta+" = 0.00001;",
"",
"uniform mat4x4 "+suvViewMatrix+";",
"uniform mat4x4 "+suvProjectionMatrix+";",
......@@ -169,7 +170,7 @@ public class MultiVolumeRendererShaderSource extends AbstractShaderSource{
" vec4 positionInGlobalSpace = "+suvDrawCubeTransformation+" * position4d;",
"",
" gl_Position ="+suvProjectionMatrix+" * "+suvViewMatrix+" * positionInGlobalSpace;",
" "+svRayStartCoordinate+"= positionInGlobalSpace.xyz /positionInGlobalSpace.w;",
" "+svRayStartCoordinate+"= positionInGlobalSpace.xyz /max(positionInGlobalSpace.w,"+scvMinDelta+");",
"}",
};
......@@ -221,7 +222,7 @@ public class MultiVolumeRendererShaderSource extends AbstractShaderSource{
"",
"vec3 getCoordinateInVolumeSpace(vec3 positionOnRay, int volumeNumber){",
" vec4 transformedPosition ="+suvTextureTransformationInverse+"[volumeNumber]*vec4(positionOnRay.xyz,1.0); ",
" transformedPosition /= transformedPosition.w;",
" transformedPosition /= max(transformedPosition.w,"+scvMinDelta+");",
" return transformedPosition.xyz;",
"}",
"",
......@@ -343,7 +344,7 @@ public class MultiVolumeRendererShaderSource extends AbstractShaderSource{
" "+sgvRayPositions+" = "+svRayStartCoordinate+";",
" for(int n = 0; n < "+scvMaxNumberOfVolumes+"; n++){",
" vec3 tmp = "+suvVoxelCount+"[n];",
" vtextOffsets[n] = vec3(1.0/(2.0*tmp));",
" vtextOffsets[n] = vec3(1.0/(2.0*max(tmp,vec3(1.0))));",
" vtextScales[n] = (vec3("+suvVoxelCount+"[n]-ivec3(1)))/max((vec3("+suvVoxelCount+"[n])*vec3("+suvVoxelCount+"[n]-ivec3(1))),vec3(1.0));",
"",
" }",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment