message: Getting something realistic rendered to the screen for scivis volumes.
diff: #include "math/sampling.ih"
  #include "render/util.ih"
  +#include "openvkl/openvkl.isph"
  +
  +#define USE_VALUE_SELECTOR 1
  +
  vec4f integrateVolumeInterval(const ScreenSample &sample,
  const VolumeInterval &interval,
  Ray &ray)
  @@ -40,15 +44,48 @@ vec4f integrateVolumeInterval(const ScreenSample &sample,
  if (jitter > 1.f)
  jitter -= 1.f;
  - ray.t0 += jitter;
  -
  foreach_unique(m in model)
  {
  Volume *uniform volume = m->volume;
  TransferFunction *uniform tf = m->transferFunction;
  - while (ray.t0 <= ray.t && alpha < 0.99f) {
  - const float sample = Volume_getSample(volume, ray.org + ray.t0 * ray.dir);
  + uniform VKLIntervalIterator intervalIterator;
  + vklInitIntervalIteratorV(&intervalIterator,
  + volume->vklVolume,
  + (varying vkl_vec3f *)&ray.org,
  + (varying vkl_vec3f *)&ray.dir,
  + (varying vkl_range1f *)&interval.interval,
  + //&tRange,
  +#if USE_VALUE_SELECTOR==1
  + volume->vklValueSelector
  +#else
  + 0
  +#endif
  + );
  +
  + VKLInterval interval;
  + while (vklIterateIntervalV(&intervalIterator, &interval) && alpha < 0.99f) {
  +
  +#if USE_VALUE_SELECTOR != 1
  + if (interval.valueRange.upper <= 0.f)
  + continue;
  +#endif
  +
  + const float nominalSamplingDt = interval.nominalDeltaT / m->samplingRate;
  +
  + // initial sub interval, based on our renderer-defined sampling rate
  + // and the volume's nominal dt
  + box1f subInterval = make_box1f(
  + interval.tRange.lower,
  + min(interval.tRange.lower + nominalSamplingDt, interval.tRange.upper));
  +
  + while (subInterval.upper - subInterval.lower > 0.f && alpha < 0.99f) {
  + ray.t0 = 0.5f * (subInterval.lower + subInterval.upper) + jitter;
  + const float dt = subInterval.upper - subInterval.lower;
  +
  + // Get volume sample
  + vec3f p = ray.org + ray.t0 * ray.dir;
  + const float sample = vklComputeSampleV(volume->vklVolume, (const varying vkl_vec3f *uniform) &p);
  if (!isnan(sample)) {
  vec4f sampleColorOpacity = tf->get(tf, sample);
  @@ -60,13 +97,12 @@ vec4f integrateVolumeInterval(const ScreenSample &sample,
  alpha = alpha + ((1.f - alpha) * clampedOpacity);
  }
  -#if 0
  - volume->stepRay(volume, tf, ray, m->samplingRate);
  -#else
  - ray.t0 += 0.05;
  -#endif
  + // compute next sub interval
  + subInterval.lower = subInterval.upper;
  + subInterval.upper =
  + min(subInterval.lower + nominalSamplingDt, interval.tRange.upper);
  + }
  }
  }
  -
  return make_vec4f(color, alpha);
  }
  