Commit 088ff85d authored by Aashish Chaudhary's avatar Aashish Chaudhary Committed by Code Review

Merge topic 'fix_smartvolume_mapper_crashes' into master

7c3dc82c Fixed smart volume mapper level test
d296e253 Fixed smart volume mapper crashes because of gradient opacity
parents 885e4ed6 7c3dc82c
......@@ -64,6 +64,8 @@ vec4 g_eyePosObj;
/// The first value is the size of the data array for clipping
/// planes (origin, normal)
uniform float in_clippingPlanes[49];
uniform float in_scale;
uniform float in_bias;
//////////////////////////////////////////////////////////////////////////////
///
......@@ -103,5 +105,8 @@ void main()
//VTK::Clipping::Exit
//VTK::Shading::Exit
g_fragColor.r = g_fragColor.r * in_scale + in_bias * g_fragColor.a;
g_fragColor.g = g_fragColor.g * in_scale + in_bias * g_fragColor.a;
g_fragColor.b = g_fragColor.b * in_scale + in_bias * g_fragColor.a;
gl_FragColor = g_fragColor;
}
......@@ -2346,6 +2346,12 @@ void vtkOpenGLGPUVolumeRayCastMapper::GPURender(vtkRenderer* ren,
// Updating clipping if enabled
this->Impl->UpdateClipping(ren, vol);
// Finally set the scale and bias for color correction
this->Impl->ShaderProgram->SetUniformf("in_scale",
1.0 / this->FinalColorWindow);
this->Impl->ShaderProgram->SetUniformf("in_bias",
(0.5 - (this->FinalColorLevel/this->FinalColorWindow)));
#ifndef __APPLE__
glBindVertexArray(this->Impl->CubeVAOId);
#endif
......
......@@ -247,15 +247,22 @@ namespace vtkvolume
vtkVolume* vol,
int vtkNotUsed(numberOfComponents))
{
if (vol->GetProperty()->GetShade() &&
!vol->GetProperty()->HasGradientOpacity())
std::string shaderStr;
if (vol->GetProperty()->HasGradientOpacity())
{
return std::string("\
shaderStr += std::string("\
\nuniform sampler1D in_gradientTransferFunc;\
\nfloat computeGradientOpacity(vec4 grad)\
\n {\
\n return 1.0;\
\n }\
\n\
\n return texture1D(in_gradientTransferFunc, grad.w).w;\
\n }"
);
}
if (vol->GetProperty()->GetShade() &&
!vol->GetProperty()->HasGradientOpacity())
{
shaderStr += std::string("\
\nvec4 computeGradient()\
\n {\
\n vec3 g1;\
......@@ -270,17 +277,13 @@ namespace vtkvolume
\n g2.y = texture3D(in_volume, vec3(g_dataPos - yvec)).x;\
\n g2.z = texture3D(in_volume, vec3(g_dataPos - zvec)).x;\
\n return vec4((g1 - g2), -1.0);\
\n }");
\n }"
);
}
else if (vol->GetProperty()->GetShade() &&
vol->GetProperty()->HasGradientOpacity())
{
return std::string("\
\nuniform sampler1D in_gradientTransferFunc;\
\nfloat computeGradientOpacity(vec4 grad)\
\n {\
\n return texture1D(in_gradientTransferFunc, grad.w).w;\
\n }\
shaderStr += std::string("\
\nvec4 computeGradient()\
\n {\
\n vec3 g1;\
......@@ -339,16 +342,19 @@ namespace vtkvolume
\n grad_mag = clamp(grad_mag, 0.0, 1.0);\
\n g2.w = grad_mag;\
\n return g2;\
\n }");
\n }"
);
}
else
{
return std::string("\
\nvec3 computeGradient()\
shaderStr += std::string("\
\nvec4 computeGradient()\
\n {\
\n return vec3(0.0);\
\n return vec4(0.0);\
\n }");
}
return shaderStr;
}
//--------------------------------------------------------------------------
......
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