<html><body><div>Hi,</div><div><br data-mce-bogus="1"></div><div>I was able to isolate the problem.</div><div><br data-mce-bogus="1"></div><div>We are using vtkLightKit in our application.</div><div><br data-mce-bogus="1"></div><div>Here is a small app that will demonstrate the problem</div><div><br data-mce-bogus="1"></div><div>https://www.dropbox.com/s/crwlm6njmqvdrz4/Source.7z?dl=0<br><div class="msg-quote" style="word-wrap: break-word;" data-mce-style="word-wrap: break-word;"><br data-mce-bogus="1"></div><div class="msg-quote" style="word-wrap: break-word;" data-mce-style="word-wrap: break-word;"><br data-mce-bogus="1"></div><div class="msg-quote" style="word-wrap: break-word;" data-mce-style="word-wrap: break-word;">But basically all you have to do is:</div><div class="msg-quote" style="word-wrap: break-word;" data-mce-style="word-wrap: break-word;"><br data-mce-bogus="1"></div><div class="msg-quote" style="word-wrap: break-word;" data-mce-style="word-wrap: break-word;"> vtkSmartPointer<vtkLightKit> lightKit = vtkSmartPointer<vtkLightKit>::New();<br> lightKit->AddLightsToRenderer(ren1);</div><div class="msg-quote" style="word-wrap: break-word;" data-mce-style="word-wrap: break-word;"><br data-mce-bogus="1"></div><div class="msg-quote" style="word-wrap: break-word;" data-mce-style="word-wrap: break-word;">and render a volume</div><div class="msg-quote" style="word-wrap: break-word;" data-mce-style="word-wrap: break-word;">and the shader fails to compile.</div><div class="msg-quote" style="word-wrap: break-word;" data-mce-style="word-wrap: break-word;"><br data-mce-bogus="1"></div><div class="msg-quote" style="word-wrap: break-word;" data-mce-style="word-wrap: break-word;">Can you verify?</div><div class="msg-quote" style="word-wrap: break-word;" data-mce-style="word-wrap: break-word;"><br data-mce-bogus="1"></div><div class="msg-quote" style="word-wrap: break-word;" data-mce-style="word-wrap: break-word;">Also, while in there the code</div><div class="msg-quote" style="word-wrap: break-word;" data-mce-style="word-wrap: break-word;"><br data-mce-bogus="1"></div><div class="msg-quote" style="word-wrap: break-word;" data-mce-style="word-wrap: break-word;">this->Impl->ShaderProgram = this->Impl->ShaderCache->ReadyShaderProgram(<br> vertexShader.c_str(), fragmentShader.c_str(), "");<br> if (!this->Impl->ShaderProgram->GetCompiled())<br> {<br> vtkErrorMacro("Shader failed to compile");<br> }</div><div class="msg-quote" style="word-wrap: break-word;" data-mce-style="word-wrap: break-word;"><br data-mce-bogus="1"></div><div class="msg-quote" style="word-wrap: break-word;" data-mce-style="word-wrap: break-word;">should be changed to </div><div class="msg-quote" style="word-wrap: break-word;" data-mce-style="word-wrap: break-word;"><span style="color: #000000; font-family: SFNSText, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 300; letter-spacing: normal; line-height: 22.5px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;" data-mce-style="color: #000000; font-family: SFNSText, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 300; letter-spacing: normal; line-height: 22.5px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;">if (this->Impl->ShaderProgram == nullptr || !this->Impl->ShaderProgram->GetCompiled())</span></div><div class="msg-quote" style="word-wrap: break-word;" data-mce-style="word-wrap: break-word;">{<br><br>}</div><div class="msg-quote" style="word-wrap: break-word;" data-mce-style="word-wrap: break-word;"><br data-mce-bogus="1"></div><div class="msg-quote" style="word-wrap: break-word;" data-mce-style="word-wrap: break-word;">as <span style="color: #000000; font-family: SFNSText, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 300; letter-spacing: normal; line-height: 22.5px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;" data-mce-style="color: #000000; font-family: SFNSText, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 300; letter-spacing: normal; line-height: 22.5px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;">ReadyShaderProgram returns nullptr at least in this case (which causes the crash)</span></div><div class="msg-quote" style="word-wrap: break-word;" data-mce-style="word-wrap: break-word;"><span style="color: #000000; font-family: SFNSText, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 300; letter-spacing: normal; line-height: 22.5px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;" data-mce-style="color: #000000; font-family: SFNSText, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 300; letter-spacing: normal; line-height: 22.5px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;"><br data-mce-bogus="1"></span></div><div class="msg-quote" style="word-wrap: break-word;" data-mce-style="word-wrap: break-word;"><span style="color: #000000; font-family: SFNSText, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 300; letter-spacing: normal; line-height: 22.5px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;" data-mce-style="color: #000000; font-family: SFNSText, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 300; letter-spacing: normal; line-height: 22.5px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;">Let me know if you can repro and, if you fix it I will fetch from git and try again.</span></div><div class="msg-quote" style="word-wrap: break-word;" data-mce-style="word-wrap: break-word;"><span style="color: #000000; font-family: SFNSText, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 300; letter-spacing: normal; line-height: 22.5px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;" data-mce-style="color: #000000; font-family: SFNSText, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 300; letter-spacing: normal; line-height: 22.5px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;"><br data-mce-bogus="1"></span></div><div class="msg-quote" style="word-wrap: break-word;" data-mce-style="word-wrap: break-word;"><span style="color: #000000; font-family: SFNSText, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 300; letter-spacing: normal; line-height: 22.5px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;" data-mce-style="color: #000000; font-family: SFNSText, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 300; letter-spacing: normal; line-height: 22.5px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;">Thanks!</span></div><div class="msg-quote" style="word-wrap: break-word;" data-mce-style="word-wrap: break-word;"><span style="color: #000000; font-family: SFNSText, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 300; letter-spacing: normal; line-height: 22.5px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;" data-mce-style="color: #000000; font-family: SFNSText, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 300; letter-spacing: normal; line-height: 22.5px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;"><br data-mce-bogus="1"></span></div><div class="msg-quote" style="word-wrap: break-word;" data-mce-style="word-wrap: break-word;"><span style="color: #000000; font-family: SFNSText, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 300; letter-spacing: normal; line-height: 22.5px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;" data-mce-style="color: #000000; font-family: SFNSText, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 300; letter-spacing: normal; line-height: 22.5px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;">Rick Frank</span></div><div class="msg-quote" style="word-wrap: break-word;" data-mce-style="word-wrap: break-word;"><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">Begin forwarded message:</div><div style="margin: 0px;" class="" data-mce-style="margin: 0px;"><span style="font-family: , 'helvetica neue' , 'helvetica' , sans-serif; color: rgba(0 , 0 , 0 , 1.0);" class="" data-mce-style="font-family: , 'helvetica neue' , 'helvetica' , sans-serif; color: rgba(0 , 0 , 0 , 1.0);"><b class="">From: </b></span><span style="font-family: , 'helvetica neue' , 'helvetica' , sans-serif;" class="" data-mce-style="font-family: , 'helvetica neue' , 'helvetica' , sans-serif;">Richard Frank <<a href="mailto:rickfrank@me.com" class="" data-mce-href="mailto:rickfrank@me.com">rickfrank@me.com</a>><br class=""></span></div><div style="margin: 0px;" class="" data-mce-style="margin: 0px;"><span style="font-family: , 'helvetica neue' , 'helvetica' , sans-serif; color: rgba(0 , 0 , 0 , 1.0);" class="" data-mce-style="font-family: , 'helvetica neue' , 'helvetica' , sans-serif; color: rgba(0 , 0 , 0 , 1.0);"><b class="">Date: </b></span><span style="font-family: , 'helvetica neue' , 'helvetica' , sans-serif;" class="" data-mce-style="font-family: , 'helvetica neue' , 'helvetica' , sans-serif;">April 7, 2016 at 11:45:48 AM EDT<br class=""></span></div><div style="margin: 0px;" class="" data-mce-style="margin: 0px;"><span style="font-family: , 'helvetica neue' , 'helvetica' , sans-serif; color: rgba(0 , 0 , 0 , 1.0);" class="" data-mce-style="font-family: , 'helvetica neue' , 'helvetica' , sans-serif; color: rgba(0 , 0 , 0 , 1.0);"><b class="">To: </b></span><span style="font-family: , 'helvetica neue' , 'helvetica' , sans-serif;" class="" data-mce-style="font-family: , 'helvetica neue' , 'helvetica' , sans-serif;">Aashish Chaudhary <<a href="mailto:aashish.chaudhary@kitware.com" class="" data-mce-href="mailto:aashish.chaudhary@kitware.com">aashish.chaudhary@kitware.com</a>><br class=""></span></div><div style="margin: 0px;" class="" data-mce-style="margin: 0px;"><span style="font-family: , 'helvetica neue' , 'helvetica' , sans-serif; color: rgba(0 , 0 , 0 , 1.0);" class="" data-mce-style="font-family: , 'helvetica neue' , 'helvetica' , sans-serif; color: rgba(0 , 0 , 0 , 1.0);"><b class="">Cc: </b></span><span style="font-family: , 'helvetica neue' , 'helvetica' , sans-serif;" class="" data-mce-style="font-family: , 'helvetica neue' , 'helvetica' , sans-serif;"><a href="mailto:vtkusers@vtk.org" class="" data-mce-href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a><br class=""></span></div><div style="margin: 0px;" class="" data-mce-style="margin: 0px;"><span style="font-family: , 'helvetica neue' , 'helvetica' , sans-serif; color: rgba(0 , 0 , 0 , 1.0);" class="" data-mce-style="font-family: , 'helvetica neue' , 'helvetica' , sans-serif; color: rgba(0 , 0 , 0 , 1.0);"><b class="">Subject: </b></span><span style="font-family: , 'helvetica neue' , 'helvetica' , sans-serif;" class="" data-mce-style="font-family: , 'helvetica neue' , 'helvetica' , sans-serif;"><b class="">Re: [vtkusers] Error in vtkOpenGLGPUVolumeRayCastMapper.cxx, continued</b><br class=""></span></div><br class=""><div class=""><div class=""><div class="">Hi,</div><div class=""><br class=""></div><div class="">I pulled from git about 2 or 3 days ago, and got around to testing this AM.</div><div class=""><br class=""></div><div class="">I still crash, albeit slightly different place it seems but the same undefined gl_aspect</div><div class=""><br class=""></div><div class="">:</div><div class=""><br class=""></div><div class="">ERROR: In Y:\ThirdParty\vtk700\Rendering\OpenGL2\vtkShaderProgram.cxx, line 378<br class="">vtkShaderProgram (00000000362FFA50): 1: #version 150<br class="">2: #ifdef GL_ES<br class="">3: #if __VERSION__ == 300<br class="">4: #define varying in<br class="">5: #ifdef GL_FRAGMENT_PRECISION_HIGH<br class="">6: precision highp float;<br class="">7: precision highp sampler2D;<br class="">8: precision highp sampler3D;<br class="">9: #else<br class="">10: precision mediump float;<br class="">11: precision mediump sampler2D;<br class="">12: precision mediump sampler3D;<br class="">13: #endif<br class="">14: #define texelFetchBuffer texelFetch<br class="">15: #define texture1D texture<br class="">16: #define texture2D texture<br class="">17: #define texture3D texture<br class="">18: #endif // 300<br class="">19: #if __VERSION__ == 100<br class="">20: #extension GL_OES_standard_derivatives : enable<br class="">21: #ifdef GL_FRAGMENT_PRECISION_HIGH<br class="">22: precision highp float;<br class="">23: #else<br class="">24: precision mediump float;<br class="">25: #endif<br class="">26: #endif // 100<br class="">27: #else // GL_ES<br class="">28: #define highp<br class="">29: #define mediump<br class="">30: #define lowp<br class="">31: #if __VERSION__ == 150<br class="">32: #define varying in<br class="">33: #define texelFetchBuffer texelFetch<br class="">34: #define texture1D texture<br class="">35: #define texture2D texture<br class="">36: #define texture3D texture<br class="">37: #endif<br class="">38: #if __VERSION__ == 120<br class="">39: #extension GL_EXT_gpu_shader4 : require<br class="">40: #endif<br class="">41: #endif // GL_ES<br class="">42: <br class="">43: <br class="">44: /*=========================================================================<br class="">45: <br class="">46: Program: Visualization Toolkit<br class="">47: Module: raycasterfs.glsl<br class="">48: <br class="">49: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen<br class="">50: All rights reserved.<br class="">51: See Copyright.txt or <a href="http://www.kitware.com/Copyright.htm" class="" data-mce-href="http://www.kitware.com/Copyright.htm">http://www.kitware.com/Copyright.htm</a> for details.<br class="">52: <br class="">53: This software is distributed WITHOUT ANY WARRANTY; without even<br class="">54: the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR<br class="">55: PURPOSE. See the above copyright notice for more information.<br class="">56: <br class="">57: =========================================================================*/<br class="">58: <br class="">59: //////////////////////////////////////////////////////////////////////////////<br class="">60: ///<br class="">61: /// Inputs<br class="">62: ///<br class="">63: //////////////////////////////////////////////////////////////////////////////<br class="">64: <br class="">65: /// 3D texture coordinates form vertex shader<br class="">66: varying vec3 ip_textureCoords;<br class="">67: varying vec3 ip_vertexPos;<br class="">68: <br class="">69: //////////////////////////////////////////////////////////////////////////////<br class="">70: ///<br class="">71: /// Outputs<br class="">72: ///<br class="">73: //////////////////////////////////////////////////////////////////////////////<br class="">74: <br class="">75: vec4 g_fragColor = vec4(0.0);<br class="">76: <br class="">77: //////////////////////////////////////////////////////////////////////////////<br class="">78: ///<br class="">79: /// Uniforms, attributes, and globals<br class="">80: ///<br class="">81: //////////////////////////////////////////////////////////////////////////////<br class="">82: vec3 g_dataPos;<br class="">83: vec3 g_dirStep;<br class="">84: vec4 g_srcColor;<br class="">85: vec4 g_eyePosObj;<br class="">86: bool g_exit;<br class="">87: <br class="">88: uniform vec4 in_volume_scale;<br class="">89: uniform vec4 in_volume_bias;<br class="">90: <br class="">91: out vec4 fragOutput0;<br class="">92: <br class="">93: <br class="">94: <br class="">95: // Volume dataset <br class="">96: uniform sampler3D in_volume; <br class="">97: uniform int in_noOfComponents; <br class="">98: uniform int in_independentComponents; <br class="">99: <br class="">100: uniform sampler2D in_noiseSampler; <br class="">101: #ifndef GL_ES <br class="">102: uniform sampler2D in_depthSampler; <br class="">103: #endif <br class="">104: <br class="">105: // Camera position <br class="">106: uniform vec3 in_cameraPos; <br class="">107: <br class="">108: // view and model matrices <br class="">109: uniform mat4 in_volumeMatrix; <br class="">110: uniform mat4 in_inverseVolumeMatrix; <br class="">111: uniform mat4 in_projectionMatrix; <br class="">112: uniform mat4 in_inverseProjectionMatrix; <br class="">113: uniform mat4 in_modelViewMatrix; <br class="">114: uniform mat4 in_inverseModelViewMatrix; <br class="">115: uniform mat4 in_textureDatasetMatrix; <br class="">116: uniform mat4 in_inverseTextureDatasetMatrix; <br class="">117: uniform mat4 in_texureToEyeIt; <br class="">118: <br class="">119: // Ray step size <br class="">120: uniform vec3 in_cellStep; <br class="">121: uniform vec2 in_scalarsRange[4]; <br class="">122: uniform vec3 in_cellSpacing; <br class="">123: <br class="">124: // Sample distance <br class="">125: uniform float in_sampleDistance; <br class="">126: <br class="">127: // Scales <br class="">128: uniform vec3 in_cellScale; <br class="">129: uniform vec2 in_windowLowerLeftCorner; <br class="">130: uniform vec2 in_inverseOriginalWindowSize; <br class="">131: uniform vec2 in_inverseWindowSize; <br class="">132: uniform vec3 in_textureExtentsMax; <br class="">133: uniform vec3 in_textureExtentsMin; <br class="">134: <br class="">135: // Material and lighting <br class="">136: uniform vec3 in_diffuse; <br class="">137: uniform vec3 in_ambient; <br class="">138: uniform vec3 in_specular; <br class="">139: uniform float in_shininess; <br class="">140: <br class="">141: // Others <br class="">142: uniform bool in_cellFlag; <br class="">143: uniform bool in_useJittering; <br class="">144: vec3 g_xvec; <br class="">145: vec3 g_yvec; <br class="">146: vec3 g_zvec; <br class="">147: uniform bool in_twoSidedLighting; <br class="">148: vec3 g_cellSpacing; <br class="">149: float g_avgSpacing; <br class="">150: vec4 g_fragWorldPos; <br class="">151: uniform int in_numberOfLights; <br class="">152: uniform vec3 in_lightAmbientColor[6]; <br class="">153: uniform vec3 in_lightDiffuseColor[6]; <br class="">154: uniform vec3 in_lightSpecularColor[6]; <br class="">155: uniform vec3 in_lightDirection[6]; <br class="">156: <br class="">157: //VTK::Termination::Dec<br class="">158: <br class="">159: //VTK::Cropping::Dec<br class="">160: <br class="">161: //VTK::Shading::Dec<br class="">162: <br class="">163: //VTK::BinaryMask::Dec<br class="">164: <br class="">165: //VTK::CompositeMask::Dec<br class="">166: <br class="">167: <br class="">168: uniform sampler2D in_opacityTransferFunc; <br class="">169: float computeOpacity(vec4 scalar) <br class="">170: { <br class="">171: return texture2D(in_opacityTransferFunc, vec2(scalar.w, 0)).r; <br class="">172: }<br class="">173: <br class="">174: <br class="">175: uniform sampler2D in_gradientTransferFunc; <br class="">176: float computeGradientOpacity(vec4 grad) <br class="">177: { <br class="">178: return texture2D(in_gradientTransferFunc, vec2(grad.w, 0.0)).r; <br class="">179: } <br class="">180: // c is short for component <br class="">181: vec4 computeGradient(int c) <br class="">182: { <br class="">183: vec3 g1; <br class="">184: vec4 g2; <br class="">185: g1.x = texture3D(in_volume, vec3(g_dataPos + g_xvec)).x; <br class="">186: g1.y = texture3D(in_volume, vec3(g_dataPos + g_yvec)).x; <br class="">187: g1.z = texture3D(in_volume, vec3(g_dataPos + g_zvec)).x; <br class="">188: g2.x = texture3D(in_volume, vec3(g_dataPos - g_xvec)).x; <br class="">189: g2.y = texture3D(in_volume, vec3(g_dataPos - g_yvec)).x; <br class="">190: g2.z = texture3D(in_volume, vec3(g_dataPos - g_zvec)).x; <br class="">191: g1 = g1 * in_volume_scale.r + in_volume_bias.r; <br class="">192: g2 = g2 * in_volume_scale.r + in_volume_bias.r; <br class="">193: g1.x = in_scalarsRange[c][0] + ( <br class="">194: in_scalarsRange[c][1] - in_scalarsRange[c][0]) * g1.x; <br class="">195: g1.y = in_scalarsRange[c][0] + ( <br class="">196: in_scalarsRange[c][1] - in_scalarsRange[c][0]) * g1.y; <br class="">197: g1.z = in_scalarsRange[c][0] + ( <br class="">198: in_scalarsRange[c][1] - in_scalarsRange[c][0]) * g1.z; <br class="">199: g2.x = in_scalarsRange[c][0] + ( <br class="">200: in_scalarsRange[c][1] - in_scalarsRange[c][0]) * g2.x; <br class="">201: g2.y = in_scalarsRange[c][0] + ( <br class="">202: in_scalarsRange[c][1] - in_scalarsRange[c][0]) * g2.y; <br class="">203: g2.z = in_scalarsRange[c][0] + ( <br class="">204: in_scalarsRange[c][1] - in_scalarsRange[c][0]) * g2.z; <br class="">205: g2.xyz = g1 - g2.xyz; <br class="">206: g2.x /= g_aspect.x; <br class="">207: g2.y /= g_aspect.y; <br class="">208: g2.z /= g_aspect.z; <br class="">209: g2.w = 0.0; <br class="">210: float grad_mag = length(g2); <br class="">211: if (grad_mag > 0.0) <br class="">212: { <br class="">213: g2.x /= grad_mag; <br class="">214: g2.y /= grad_mag; <br class="">215: g2.z /= grad_mag; <br class="">216: } <br class="">217: else <br class="">218: { <br class="">219: g2.xyz = vec3(0.0, 0.0, 0.0); <br class="">220: } <br class="">221: grad_mag = grad_mag * 1.0 / (0.25 * (in_scalarsRange[c][1] - <br class="">222: (in_scalarsRange[c][0]))); <br class="">223: grad_mag = clamp(grad_mag, 0.0, 1.0); <br class="">224: g2.w = grad_mag; <br class="">225: return g2; <br class="">226: }<br class="">227: <br class="">228: <br class="">229: vec4 computeLighting(vec4 color, int component) <br class="">230: { <br class="">231: vec4 finalColor = vec4(0.0); <br class="">232: // Compute gradient function only once <br class="">233: vec4 gradient = computeGradient(component); <br class="">234: g_fragWorldPos = in_modelViewMatrix * in_volumeMatrix * <br class="">235: in_textureDatasetMatrix * vec4(-g_dataPos, 1.0); <br class="">236: if (g_fragWorldPos.w != 0.0) <br class="">237: { <br class="">238: g_fragWorldPos /= g_fragWorldPos.w; <br class="">239: } <br class="">240: vec3 vdir = normalize(g_fragWorldPos.xyz); <br class="">241: vec3 normal = gradient.xyz; <br class="">242: vec3 ambient = vec3(0.0); <br class="">243: vec3 diffuse = vec3(0.0); <br class="">244: vec3 specular = vec3(0.0); <br class="">245: float normalLength = length(normal); <br class="">246: if (normalLength > 0.0) <br class="">247: { <br class="">248: normal = normalize((in_texureToEyeIt * vec4(normal, 0.0)).xyz); <br class="">249: } <br class="">250: else <br class="">251: { <br class="">252: normal = vec3(0.0, 0.0, 0.0); <br class="">253: } <br class="">254: for (int lightNum = 0; lightNum < in_numberOfLights; lightNum++) <br class="">255: { <br class="">256: vec3 ldir = in_lightDirection[lightNum].xyz; <br class="">257: vec3 h = normalize(ldir + vdir); <br class="">258: float nDotH = dot(normal, h); <br class="">259: if (nDotH < 0.0 && in_twoSidedLighting) <br class="">260: { <br class="">261: nDotH = -nDotH; <br class="">262: } <br class="">263: float nDotL = dot(normal, ldir); <br class="">264: if (nDotL < 0.0 && in_twoSidedLighting) <br class="">265: { <br class="">266: nDotL = -nDotL; <br class="">267: } <br class="">268: if (nDotL > 0.0) <br class="">269: { <br class="">270: diffuse += in_lightDiffuseColor[lightNum] * nDotL; <br class="">271: } <br class="">272: if (nDotH > 0.0) <br class="">273: { <br class="">274: specular = in_lightSpecularColor[lightNum] * pow(nDotH, in_shininess); <br class="">275: } <br class="">276: ambient += in_lightAmbientColor[lightNum]; <br class="">277: } <br class="">278: finalColor.xyz = in_ambient * ambient + <br class="">279: in_diffuse * diffuse * color.rgb + <br class="">280: in_specular * specular; <br class="">281: if (gradient.w >= 0.0) <br class="">282: { <br class="">283: color.a = color.a * <br class="">284: computeGradientOpacity(gradient); <br class="">285: } <br class="">286: finalColor.a = color.a; <br class="">287: return finalColor; <br class="">288: }<br class="">289: <br class="">290: <br class="">291: uniform sampler2D in_colorTransferFunc; <br class="">292: vec4 computeColor(vec4 scalar, float opacity) <br class="">293: { <br class="">294: return computeLighting(vec4(texture2D(in_colorTransferFunc, <br class="">295: vec2(scalar.w, 0.0)).xyz, opacity), 0); <br class="">296: }<br class="">297: <br class="">298: <br class="">299: vec3 computeRayDirection() <br class="">300: { <br class="">301: return normalize(ip_vertexPos.xyz - g_eyePosObj.xyz); <br class="">302: }<br class="">303: <br class="">304: /// We support only 8 clipping planes for now<br class="">305: /// The first value is the size of the data array for clipping<br class="">306: /// planes (origin, normal)<br class="">307: uniform float in_clippingPlanes[49];<br class="">308: uniform float in_scale;<br class="">309: uniform float in_bias;<br class="">310: <br class="">311: //////////////////////////////////////////////////////////////////////////////<br class="">312: ///<br class="">313: /// Main<br class="">314: ///<br class="">315: //////////////////////////////////////////////////////////////////////////////<br class="">316: void main()<br class="">317: {<br class="">318: /// Initialize g_fragColor (output) to 0<br class="">319: g_fragColor = vec4(0.0);<br class="">320: g_dirStep = vec3(0.0);<br class="">321: g_srcColor = vec4(0.0);<br class="">322: g_exit = false;<br class="">323: <br class="">324: <br class="">325: bool l_adjustTextureExtents = !in_cellFlag; <br class="">326: // Get the 3D texture coordinates for lookup into the in_volume dataset <br class="">327: g_dataPos = ip_textureCoords.xyz; <br class="">328: <br class="">329: // Eye position in object space <br class="">330: g_eyePosObj = (in_inverseVolumeMatrix * vec4(in_cameraPos, 1.0)); <br class="">331: if (g_eyePosObj.w != 0.0) <br class="">332: { <br class="">333: g_eyePosObj.x /= g_eyePosObj.w; <br class="">334: g_eyePosObj.y /= g_eyePosObj.w; <br class="">335: g_eyePosObj.z /= g_eyePosObj.w; <br class="">336: g_eyePosObj.w = 1.0; <br class="">337: } <br class="">338: <br class="">339: // Getting the ray marching direction (in object space); <br class="">340: vec3 rayDir = computeRayDirection(); <br class="">341: <br class="">342: // Multiply the raymarching direction with the step size to get the <br class="">343: // sub-step size we need to take at each raymarching step <br class="">344: g_dirStep = (in_inverseTextureDatasetMatrix * <br class="">345: vec4(rayDir, 0.0)).xyz * in_sampleDistance; <br class="">346: <br class="">347: float jitterValue = (texture2D(in_noiseSampler, g_dataPos.xy).x); <br class="">348: if (in_useJittering) <br class="">349: { <br class="">350: g_dataPos += g_dirStep * jitterValue; <br class="">351: } <br class="">352: else <br class="">353: { <br class="">354: g_dataPos += g_dirStep; <br class="">355: } <br class="">356: <br class="">357: // Flag to deternmine if voxel should be considered for the rendering <br class="">358: bool l_skip = false; <br class="">359: g_cellSpacing = vec3(in_cellSpacing[0], <br class="">360: in_cellSpacing[1], <br class="">361: in_cellSpacing[2]); <br class="">362: g_avgSpacing = (g_cellSpacing[0] + <br class="">363: g_cellSpacing[1] + <br class="">364: g_cellSpacing[2])/3.0; <br class="">365: g_xvec = vec3(in_cellStep[0], 0.0, 0.0); <br class="">366: g_yvec = vec3(0.0, in_cellStep[1], 0.0); <br class="">367: g_zvec = vec3(0.0, 0.0, in_cellStep[2]); <br class="">368: // Adjust the aspect <br class="">369: g_aspect.x = g_cellSpacing[0] * 2.0 / g_avgSpacing; <br class="">370: g_aspect.y = g_cellSpacing[1] * 2.0 / g_avgSpacing; <br class="">371: g_aspect.z = g_cellSpacing[2] * 2.0 / g_avgSpacing;<br class="">372: <br class="">373: <br class="">374: // Minimum texture access coordinate <br class="">375: vec3 l_texMin = vec3(0.0); <br class="">376: vec3 l_texMax = vec3(1.0); <br class="">377: if (l_adjustTextureExtents) <br class="">378: { <br class="">379: vec3 delta = in_textureExtentsMax - in_textureExtentsMin; <br class="">380: l_texMin = vec3(0.5) / delta; <br class="">381: l_texMax = (delta - vec3(0.5)) / delta; <br class="">382: } <br class="">383: <br class="">384: // Flag to indicate if the raymarch loop should terminate <br class="">385: bool stop = false; <br class="">386: <br class="">387: // 2D Texture fragment coordinates [0,1] from fragment coordinates <br class="">388: // the frame buffer texture has the size of the plain buffer but <br class="">389: // we use a fraction of it. The texture coordinates is less than 1 if <br class="">390: // the reduction factor is less than 1. <br class="">391: // Device coordinates are between -1 and 1. We need texture <br class="">392: // coordinates between 0 and 1 the in_depthSampler buffer has the <br class="">393: // original size buffer. <br class="">394: vec2 fragTexCoord = (gl_FragCoord.xy - in_windowLowerLeftCorner) * <br class="">395: in_inverseWindowSize; <br class="">396: float l_terminatePointMax = 0.0; <br class="">397: <br class="">398: #ifdef GL_ES <br class="">399: vec4 l_depthValue = vec4(1.0,1.0,1.0,1.0); <br class="">400: #else <br class="">401: vec4 l_depthValue = texture2D(in_depthSampler, fragTexCoord); <br class="">402: #endif <br class="">403: // Depth test <br class="">404: if(gl_FragCoord.z >= l_depthValue.x) <br class="">405: { <br class="">406: discard; <br class="">407: } <br class="">408: <br class="">409: // color buffer or max scalar buffer have a reduced size. <br class="">410: fragTexCoord = (gl_FragCoord.xy - in_windowLowerLeftCorner) * <br class="">411: in_inverseOriginalWindowSize; <br class="">412: <br class="">413: // Compute max number of iterations it will take before we hit <br class="">414: // the termination point <br class="">415: <br class="">416: // Abscissa of the point on the depth buffer along the ray. <br class="">417: // point in texture coordinates <br class="">418: vec4 terminatePoint; <br class="">419: terminatePoint.x = (gl_FragCoord.x - in_windowLowerLeftCorner.x) * 2.0 * <br class="">420: in_inverseWindowSize.x - 1.0; <br class="">421: terminatePoint.y = (gl_FragCoord.y - in_windowLowerLeftCorner.y) * 2.0 * <br class="">422: in_inverseWindowSize.y - 1.0; <br class="">423: terminatePoint.z = (2.0 * l_depthValue.x - (gl_DepthRange.near + <br class="">424: gl_DepthRange.far)) / gl_DepthRange.diff; <br class="">425: terminatePoint.w = 1.0; <br class="">426: <br class="">427: // From normalized device coordinates to eye coordinates. <br class="">428: // in_projectionMatrix is inversed because of way VT <br class="">429: // From eye coordinates to texture coordinates <br class="">430: terminatePoint = in_inverseTextureDatasetMatrix * <br class="">431: in_inverseVolumeMatrix * <br class="">432: in_inverseModelViewMatrix * <br class="">433: in_inverseProjectionMatrix * <br class="">434: terminatePoint; <br class="">435: terminatePoint /= terminatePoint.w; <br class="">436: <br class="">437: l_terminatePointMax = length(terminatePoint.xyz - g_dataPos.xyz) / <br class="">438: length(g_dirStep); <br class="">439: float l_currentT = 0.0;<br class="">440: <br class="">441: //VTK::Shading::Init<br class="">442: <br class="">443: //VTK::Cropping::Init<br class="">444: <br class="">445: //VTK::Clipping::Init<br class="">446: <br class="">447: //VTK::RenderToImage::Init<br class="">448: <br class="">449: //VTK::DepthPass::Init<br class="">450: <br class="">451: /// For all samples along the ray<br class="">452: while (!g_exit)<br class="">453: {<br class="">454: <br class="">455: l_skip = false;<br class="">456: <br class="">457: //VTK::Cropping::Impl<br class="">458: <br class="">459: //VTK::Clipping::Impl<br class="">460: <br class="">461: //VTK::BinaryMask::Impl<br class="">462: <br class="">463: //VTK::CompositeMask::Impl<br class="">464: <br class="">465: <br class="">466: if (!l_skip) <br class="">467: { <br class="">468: vec4 scalar = texture3D(in_volume, g_dataPos); <br class="">469: scalar.r = scalar.r*in_volume_scale.r + in_volume_bias.r; <br class="">470: scalar = vec4(scalar.r,scalar.r,scalar.r,scalar.r); <br class="">471: g_srcColor = vec4(0.0); <br class="">472: g_srcColor.a = computeOpacity(scalar); <br class="">473: if (g_srcColor.a > 0.0) <br class="">474: { <br class="">475: g_srcColor = computeColor(scalar, g_srcColor.a); <br class="">476: // Opacity calculation using compositing: <br class="">477: // Here we use front to back compositing scheme whereby <br class="">478: // the current sample value is multiplied to the <br class="">479: // currently accumulated alpha and then this product <br class="">480: // is subtracted from the sample value to get the <br class="">481: // alpha from the previous steps. Next, this alpha is <br class="">482: // multiplied with the current sample colour <br class="">483: // and accumulated to the composited colour. The alpha <br class="">484: // value from the previous steps is then accumulated <br class="">485: // to the composited colour alpha. <br class="">486: g_srcColor.rgb *= g_srcColor.a; <br class="">487: g_fragColor = (1.0f - g_fragColor.a) * g_srcColor + g_fragColor; <br class="">488: } <br class="">489: }<br class="">490: <br class="">491: //VTK::RenderToImage::Impl<br class="">492: <br class="">493: //VTK::DepthPass::Impl<br class="">494: <br class="">495: /// Advance ray<br class="">496: g_dataPos += g_dirStep;<br class="">497: <br class="">498: <br class="">499: // sign function performs component wise operation and returns -1 <br class="">500: // if the difference is less than 0, 0 if equal to 0, and 1 if <br class="">501: // above 0. So if the ray is inside the volume, dot product will <br class="">502: // always be 3. <br class="">503: stop = dot(sign(g_dataPos - l_texMin), sign(l_texMax - g_dataPos)) <br class="">504: < 3.0; <br class="">505: <br class="">506: // If the stopping condition is true we brek out of the ray marching <br class="">507: // loop <br class="">508: if (stop) <br class="">509: { <br class="">510: break; <br class="">511: } <br class="">512: // Early ray termination <br class="">513: // if the currently composited colour alpha is already fully saturated <br class="">514: // we terminated the loop or if we have hit an obstacle in the <br class="">515: // direction of they ray (using depth buffer) we terminate as well. <br class="">516: if((g_fragColor.a > (1.0 - 1.0/255.0)) || <br class="">517: l_currentT >= l_terminatePointMax) <br class="">518: { <br class="">519: break; <br class="">520: } <br class="">521: ++l_currentT;<br class="">522: }<br class="">523: <br class="">524: //VTK::Base::Exit<br class="">525: <br class="">526: //VTK::Terminate::Exit<br class="">527: <br class="">528: //VTK::Cropping::Exit<br class="">529: <br class="">530: //VTK::Clipping::Exit<br class="">531: <br class="">532: //VTK::Shading::Exit<br class="">533: <br class="">534: g_fragColor.r = g_fragColor.r * in_scale + in_bias * g_fragColor.a;<br class="">535: g_fragColor.g = g_fragColor.g * in_scale + in_bias * g_fragColor.a;<br class="">536: g_fragColor.b = g_fragColor.b * in_scale + in_bias * g_fragColor.a;<br class="">537: fragOutput0 = g_fragColor;<br class="">538: <br class="">539: //VTK::RenderToImage::Exit<br class="">540: <br class="">541: //VTK::DepthPass::Exit<br class="">542: }<br class="">543: <br class=""><br class=""><br class=""><br class="">ERROR: In Y:\ThirdParty\vtk700\Rendering\OpenGL2\vtkShaderProgram.cxx, line 379<br class="">vtkShaderProgram (00000000362FFA50): 0(206) : error C1008: undefined variable "g_aspect"<br class="">0(207) : error C1008: undefined variable "g_aspect"<br class="">0(208) : error C1008: undefined variable "g_aspect"<br class="">0(369) : error C1008: undefined variable "g_aspect"<br class="">0(370) : error C1008: undefined variable "g_aspect"<br class="">0(371) : error C1008: undefined variable "g_aspect"<br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class="">On Apr 04, 2016, at 11:49 AM, Aashish Chaudhary <<a href="mailto:aashish.chaudhary@kitware.com" class="" data-mce-href="mailto:aashish.chaudhary@kitware.com">aashish.chaudhary@kitware.com</a>> wrote:<br class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class="msg-quote"><div dir="ltr" class="">Yes please. If you can checkout the latest master, this should not happen. <div class=""><br class=""></div><div class="">Thanks,</div><div class="">Aashish</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Mon, Apr 4, 2016 at 11:48 AM, Richard Frank <span dir="ltr" class=""><<a href="mailto:rickfrank@me.com" class="" data-mce-href="mailto:rickfrank@me.com">rickfrank@me.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0 0 0 0.8ex; border-left: 1px #ccc solid; padding-left: 1ex;" data-mce-style="margin: 0 0 0 0.8ex; border-left: 1px #ccc solid; padding-left: 1ex;"><div class=""><div class="">No I'm using 7.0.0 release not a git clone.</div><div class=""><br class=""></div><div class="">I guess I should get the latest? </div><div class=""><br class=""></div><div class="">Rick</div><div class=""><div class="h5"><div class=""><br class=""></div><div class=""><br class="">On Apr 04, 2016, at 10:53 AM, Aashish Chaudhary <<a href="mailto:aashish.chaudhary@kitware.com" class="" data-mce-href="mailto:aashish.chaudhary@kitware.com">aashish.chaudhary@kitware.com</a>> wrote:<br class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class="">Thanks, and are you using VTK master as of last week since we had this problem and got fixed recently. <div class=""><br class=""></div><div class="">- Aashish</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Mon, Apr 4, 2016 at 10:47 AM, Richard Frank <span dir="ltr" class=""><<a href="mailto:rickfrank@me.com" class="" data-mce-href="mailto:rickfrank@me.com">rickfrank@me.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0 0 0 0.8ex; border-left: 1px #ccc solid; padding-left: 1ex;" data-mce-style="margin: 0 0 0 0.8ex; border-left: 1px #ccc solid; padding-left: 1ex;"><div class=""><div class="">Hi,</div><div class=""><br class=""></div><div class="">Here is a portion of code:</div><div class=""><br class=""></div><div class=""><br class=""> volumeProperty->SetColor(0, colorTransferFunction);<br class=""> volumeProperty->SetColor(1, maskColorTransferFunction);<br class=""> volumeProperty->SetScalarOpacity(opacityTransferFunction);<br class=""> volumeProperty->SetGradientOpacity(volumeGradientOpacityFunction);<br class=""> volumeProperty->SetInterpolationTypeToLinear();<br class=""> volumeProperty->ShadeOn();<br class=""> volumeProperty->SetAmbient(0.4);<br class=""> volumeProperty->SetDiffuse(0.8);<br class=""> volumeProperty->SetSpecular(0.2);<br class=""> volumeProperty->SetSpecularPower(105.0);<br class=""> volumeProperty->SetScalarOpacityUnitDistance(0.7);<br class=""> volume->SetProperty(volumeProperty);</div><div class=""><br class=""></div><div class="">The hard coded numbers are just picked empirically by viewing our most common inputs.</div><div class=""><div class=""><div class=""><br class="">On Apr 03, 2016, at 10:26 PM, Aashish Chaudhary <<a href="mailto:aashish.chaudhary@kitware.com" class="" data-mce-href="mailto:aashish.chaudhary@kitware.com">aashish.chaudhary@kitware.com</a>> wrote:<br class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class="">Rick, <div class=""><br class=""></div><div class="">Can you send me information on what you are turning on in volume property and in mapper that leads to this crash? Also, is your data is single or 2 or 4 component? </div><div class=""><br class=""></div><div class="">Thanks,</div><div class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Sun, Apr 3, 2016 at 9:25 PM, Richard Frank <span dir="ltr" class=""><<a href="mailto:rickfrank@me.com" class="" data-mce-href="mailto:rickfrank@me.com">rickfrank@me.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0 0 0 0.8ex; border-left: 1px #ccc solid; padding-left: 1ex;" data-mce-style="margin: 0 0 0 0.8ex; border-left: 1px #ccc solid; padding-left: 1ex;"><div class=""><div class="">Further investigation seems to point the GradientOpacity section of shader raycasterfs.glsl, code which seems to be inserted at runtime: I guess gl_aspect is not defined in this scenario?</div><div class=""><br class=""></div><div class="">Any suggestions welcome!</div><div class=""><br class=""></div><div class="">Rick</div><div class=""><br class=""></div><div class="">vec4 computeGradient() <br class="">145: { <br class="">146: vec3 g1; <br class="">147: vec4 g2; <br class="">148: g1.x = texture3D(in_volume, vec3(g_dataPos + g_xvec)).x; <br class="">149: g1.y = texture3D(in_volume, vec3(g_dataPos + g_yvec)).x; <br class="">150: g1.z = texture3D(in_volume, vec3(g_dataPos + g_zvec)).x; <br class="">151: g2.x = texture3D(in_volume, vec3(g_dataPos - g_xvec)).x; <br class="">152: g2.y = texture3D(in_volume, vec3(g_dataPos - g_yvec)).x; <br class="">153: g2.z = texture3D(in_volume, vec3(g_dataPos - g_zvec)).x; <br class="">154: g1 = g1*in_volume_scale.r + in_volume_bias.r; <br class="">155: g2 = g2*in_volume_scale.r + in_volume_bias.r; <br class="">156: g1.x = in_scalarsRange[0] + ( <br class="">157: in_scalarsRange[1] - in_scalarsRange[0]) * g1.x; <br class="">158: g1.y = in_scalarsRange[0] + ( <br class="">159: in_scalarsRange[1] - in_scalarsRange[0]) * g1.y; <br class="">160: g1.z = in_scalarsRange[0] + ( <br class="">161: in_scalarsRange[1] - in_scalarsRange[0]) * g1.z; <br class="">162: g2.x = in_scalarsRange[0] + ( <br class="">163: in_scalarsRange[1] - in_scalarsRange[0]) * g2.x; <br class="">164: g2.y = in_scalarsRange[0] + ( <br class="">165: in_scalarsRange[1] - in_scalarsRange[0]) * g2.y; <br class="">166: g2.z = in_scalarsRange[0] + ( <br class="">167: in_scalarsRange[1] - in_scalarsRange[0]) * g2.z; <br class="">168: <a href="http://g2.xyz/" class="" data-mce-href="http://g2.xyz/">g2.xyz</a> = g1 - <a href="http://g2.xyz/" class="" data-mce-href="http://g2.xyz/">g2.xyz</a>; <br class="">169: g2.x /= g_aspect.x; <br class="">170: g2.y /= g_aspect.y; <br class="">171: g2.z /= g_aspect.z; <br class="">172: float grad_mag = sqrt(g2.x * g2.x + <br class="">173: g2.y * g2.y + <br class="">174: g2.z * g2.z); <br class="">175: if (grad_mag > 0.0) <br class="">176: { <br class="">177: g2.x /= grad_mag; <br class="">178: g2.y /= grad_mag; <br class="">179: g2.z /= grad_mag; <br class="">180: } <br class="">181: else <br class="">182: { <br class="">183: <a href="http://g2.xyz/" class="" data-mce-href="http://g2.xyz/">g2.xyz</a> = vec3(0.0, 0.0, 0.0); <br class="">184: } <br class="">185: grad_mag = grad_mag * 1.0 / (0.25 * (in_scalarsRange[1] - <br class="">186: (in_scalarsRange[0]))); <br class="">187: grad_mag = clamp(grad_mag, 0.0, 1.0); <br class="">188: g2.w = grad_mag; <br class="">189: return g2; <br class="">190: }</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div></div><br class="">_______________________________________________<br class=""> Powered by <a href="http://www.kitware.com/" rel="noreferrer" class="" data-mce-href="http://www.kitware.com/">www.kitware.com</a><br class=""> <br class=""> Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" class="" data-mce-href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br class=""> <br class=""> Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" class="" data-mce-href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a><br class=""> <br class=""> Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" class="" data-mce-href="http://markmail.org/search/?q=vtkusers">http://markmail.org/search/?q=vtkusers</a><br class=""> <br class=""> Follow this link to subscribe/unsubscribe:<br class=""> <a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" class="" data-mce-href="http://public.kitware.com/mailman/listinfo/vtkusers">http://public.kitware.com/mailman/listinfo/vtkusers</a><br class=""> <br class=""></blockquote></div><br class=""><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div class=""><div dir="ltr" class=""><span style="font-family: 'trebuchet ms' , sans-serif;" class="" data-mce-style="font-family: 'trebuchet ms' , sans-serif;"><i class="">| Aashish Chaudhary <br class="">| Technical Leader <br class="">| Kitware Inc. <br class=""></i></span><div class=""><i class=""><span style="font-family: 'trebuchet ms' , sans-serif;" class="" data-mce-style="font-family: 'trebuchet ms' , sans-serif;">| </span><a href="http://www.kitware.com/company/team/chaudhary.html" class="" data-mce-href="http://www.kitware.com/company/team/chaudhary.html">http://www.kitware.com/company/team/chaudhary.html</a></i></div></div></div></div></div></blockquote></div></div></div></div></blockquote></div><br class=""><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div class=""><div dir="ltr" class=""><span style="font-family: 'trebuchet ms' , sans-serif;" class="" data-mce-style="font-family: 'trebuchet ms' , sans-serif;"><i class="">| Aashish Chaudhary <br class="">| Technical Leader <br class="">| Kitware Inc. <br class=""></i></span><div class=""><i class=""><span style="font-family: 'trebuchet ms' , sans-serif;" class="" data-mce-style="font-family: 'trebuchet ms' , sans-serif;">| </span><a href="http://www.kitware.com/company/team/chaudhary.html" class="" data-mce-href="http://www.kitware.com/company/team/chaudhary.html">http://www.kitware.com/company/team/chaudhary.html</a></i></div></div></div></div></div></blockquote></div></div></div></div></blockquote></div><br class=""><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div class="gmail_signature"><div dir="ltr" class=""><span style="font-family: 'trebuchet ms' , sans-serif;" class="" data-mce-style="font-family: 'trebuchet ms' , sans-serif;"><i class="">| Aashish Chaudhary <br class="">| Technical Leader <br class="">| Kitware Inc. <br class=""></i></span><div class=""><i class=""><span style="font-family: 'trebuchet ms' , sans-serif;" class="" data-mce-style="font-family: 'trebuchet ms' , sans-serif;">| </span><a href="http://www.kitware.com/company/team/chaudhary.html" class="" data-mce-href="http://www.kitware.com/company/team/chaudhary.html">http://www.kitware.com/company/team/chaudhary.html</a></i></div></div></div></div></div></blockquote></div></div></div></blockquote></div><br class=""></div></div><div></div></body></html>