Commit cfb3fbf3 authored by Ken Martin's avatar Ken Martin

Fix molecular rendering in parallel projection

The old code had some mathematically issues that were
exposed on a few dashbaords.  This should fix it.

Change-Id: Icd5f8e6296a23d9d336e29fccdd85f13082f9d85
parent 132a6fc3
......@@ -85,14 +85,21 @@ void vtkOpenGLSphereMapper::ReplaceShaderValues(std::string &VSSource,
substitute(FSSource,"//VTK::Normal::Impl",
// compute the eye position and unit direction
"vec4 vertexVC = vertexVCClose;\n"
" vec3 EyePos = vec3(0.0,0.0,0.0);\n"
" if (cameraParallel != 0) { EyePos = vertexVC.xyz;}\n"
" vec3 EyeDir = vertexVC.xyz - EyePos;\n"
" vec3 EyePos;\n"
" vec3 EyeDir;\n"
" if (cameraParallel != 0) {\n"
" EyePos = vec3(vertexVC.x, vertexVC.y, vertexVC.z + 3.0*radiusVC);\n"
" EyeDir = vec3(0.0,0.0,-1.0); }\n"
" else {\n"
" EyeDir = vertexVC.xyz;\n"
" EyePos = vec3(0.0,0.0,0.0);\n"
" float lengthED = length(EyeDir);\n"
" EyeDir = normalize(EyeDir);\n"
// we adjust the EyePos to be closer if it is too far away
// to prevent floating point precision noise
" float lengthED = length(EyeDir);\n"
" EyeDir = normalize(EyeDir);\n"
" if (lengthED > radiusVC*3.0) { EyePos = vertexVC.xyz - EyeDir*3.0*radiusVC;}\n"
" if (lengthED > radiusVC*3.0) {\n"
" EyePos = vertexVC.xyz - EyeDir*3.0*radiusVC; }\n"
" }\n"
// translate to Sphere center
" EyePos = EyePos - centerVC;\n"
......
......@@ -89,15 +89,21 @@ void vtkOpenGLStickMapper::ReplaceShaderValues(std::string &VSSource,
substitute(FSSource,"//VTK::Normal::Impl",
// compute the eye position and unit direction
" vec4 vertexVC = vertexVCClose;\n"
" vec3 EyePos = vec3(0.0,0.0,0.0);\n"
" if (cameraParallel != 0) { EyePos = vertexVC.xyz;}\n"
" vec3 EyePos;\n"
" vec3 EyeDir;\n"
" if (cameraParallel != 0) {\n"
" EyePos = vec3(vertexVC.x, vertexVC.y, vertexVC.z + 3.0*radiusVC);\n"
" EyeDir = vec3(0.0,0.0,-1.0); }\n"
" else {\n"
" EyeDir = vertexVC.xyz;\n"
" EyePos = vec3(0.0,0.0,0.0);\n"
" float lengthED = length(EyeDir);\n"
" EyeDir = normalize(EyeDir);\n"
// we adjust the EyePos to be closer if it is too far away
// to prevent floating point precision noise
" vec3 EyeDir = vertexVC.xyz - EyePos;\n"
" float lengthED = length(EyeDir);\n"
" EyeDir = normalize(EyeDir);\n"
" if (lengthED > (radiusVC+lengthVC)*3.0) \n"
" { EyePos = vertexVC.xyz - EyeDir*3.0*(radiusVC+lengthVC);}\n"
" if (lengthED > radiusVC*3.0) {\n"
" EyePos = vertexVC.xyz - EyeDir*3.0*radiusVC; }\n"
" }\n"
// translate to Cylinder center
" EyePos = EyePos - centerVC;\n"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment