Gradient Opacity transfer function range

Hi all,

I’m exploring the gradient opacity transfer function in vtkVolumeProperty. According to this old post, the range of opacity function X axis is data dependent. But in the default shader (obtained by dumping shader file at render time), the look up gradient value is clamped between 0-1:

On the other hand, the default gradient opacity function has range 0-255.

By playing with values, it’s apparent that the gradient upper range is definitely beyond 1, which then makes me wonder why the fragment shader code is not working. Any info is appreciated. Thanks in advance!

1 Like

I am also curious about how we define gradient opacity, it’s not immediately clear how this is set in ParaView.

@cory.quammen @ken-martin Perhaps one of you could weigh in?

The volume mapper takes the range of the gradient opacity into account when creating the texture so that a range of 0-1 can be used. I think the code below does it. Then the volume mapper may have some scale bias uniforms that map the native data range on the GPU to that 0.0 to 1.0 texture range. @sankhesh probably is more familiar with it. Last I knew PV didn’t expose the GO property though it is very useful.

 // Get values according to scale/bias from mapper 256 values are
      // in the table, the scale / bias values control what those 256 values
      // mean.
      float scale = this->Mapper->GetGradientMagnitudeScale(c);
      float bias = this->Mapper->GetGradientMagnitudeBias(c);

      float low = -bias;
      float high = 255 / scale - bias;

      gotf->GetTable(low, high, static_cast<int>(0x100), this->GradientOpacityArray[c]);
1 Like

3D Slicer offers GUI for interactive editing of the gradient transfer function. You can play around with that.

Most often we use it to make glass-like rendering of vasculature. We keep low values (0 to 50…150) at 0.0 and go up to 1.0 with a steep ramp.

To me it looks like that x value of the transfer function is actually the image gradient, in gray level/millimeter (or whatever length unit you use in your world coordinate system).