AverageIPScalarRange

Hi, I’ve been trying to use setAverageIPScalarRange but when ever I try to set the minimum to anything above 0 I find that everything disappears. I am adding

mapper.setAverageIPScalarRange(0.001, 100000000);

to line 39 of the VolumeMapperBlendModes example then I select blendMode average. I wouldn’t expect the whole volume to disappear from a value of 0.001, I would be expecting any values below 0.001 to be ignored in the shader.

Have a misunderstood something here or is this a bug?

Thanks!

Just a quick guess the upper value may be so large that it is causing issues on the low end of the range. Can you try dropping the upper value significantly and see how it behaves?

Sadly not, the default values are -1000000.0, 1000000.0. I think this might be a shader issue. I can’t be sure since the tests I ran brought up some new issues but it looks like vtkVolumeFS.glsl

vec4 averageIPScalarRangeMin = vec4 (
//VTK::AverageIPScalarRangeMin,
//VTK::AverageIPScalarRangeMin,
//VTK::AverageIPScalarRangeMin,
1.0);

if (all(greaterThanEqual(tValue, averageIPScalarRangeMin)))

I think this if statement will always fail since the tValue appears to have a 0 in [1] and [2]. I did find this comment further down which is likely what needs to be implemented to fix this.

// One can control the scalar range by setting the AverageIPScalarRange to disregard scalar values, not in the range of interest, from the average computation.
// Notes:
// - We are comparing all values in the texture to see if any of them
// are outside of the scalar range. In the future we might want to allow
// scalar ranges for each component.
// - We are setting the alpha channel for averageIPScalarRangeMin and
// averageIPScalarRangeMax so that we do not trigger this ‘continue’
// based on the alpha channel comparison.
// - There might be a better way to do this. I’m not sure if there is an
// equivalent of ‘any’ which only operates on RGB, though I suppose
// we could write an ‘anyRGB’ function and see if that is faster.

I submitted this an an issue here AverageIPScalar not working · Issue #1924 · Kitware/vtk-js · GitHub