message: Fix shadows from (iso)surfaces within volumes
diff: @@ -38,32 +38,17 @@ float lightAlpha(const uniform SciVisRenderer *uniform self,
  uniform int remaining_depth = self->maxDepth;
  while (1) {
  - // Get first intersected volume for each ray and set the ray bounds.
  - float org_t = ray.t;
  - float org_t0 = ray.t0;
  - Volume *volume = SciVisRenderer_intersectVolumes(self, ray, rayOffset);
  - float volumeT = ray.t;
  - float volumeT0 = ray.t0;
  - ray.t = org_t;
  - ray.t0 = org_t0;
  -
  traceRay(model,ray);
  - if (!(volumeT0 <= 0.f || volumeT0 <= ray.t))
  - volume = NULL;
  -
  - if (!volume && ray.geomID < 0) return alpha;
  -
  - float material_opacity = 1.f;
  -
  - if (!volume)
  - {
  + if (ray.geomID >= 0) { // surfaces
  DifferentialGeometry dg;
  postIntersect(model, dg, ray, DG_MATERIALID | DG_TEXCOORD | DG_COLOR);
  uniform SciVisMaterial *scivisMaterial =
  (uniform SciVisMaterial *)dg.material;
  + float material_opacity = 1.f;
  +
  if(scivisMaterial == NULL) {
  material_opacity = dg.color.w;
  } else {
  @@ -75,33 +60,44 @@ float lightAlpha(const uniform SciVisRenderer *uniform self,
  }
  }
  }
  +
  + alpha = alpha * (1.f - material_opacity);
  + if (alpha * weight < ALPHA_THRESHOLD)
  + return alpha;
  }
  - else
  - {
  - ray.t = org_t;
  - ray.t0 = org_t0;
  +
  + // volumes
  + // Get first intersected volume for each ray and set the ray bounds.
  + float org_t = ray.t;
  + float org_t0 = ray.t0;
  + Volume *volume = SciVisRenderer_intersectVolumes(self, ray, rayOffset);
  + float tBegin = max(org_t0, ray.t0);
  + float tEnd = min(org_t, ray.t + self->volumeEpsilon);
  +
  + if (volume && tBegin < tEnd) {
  // print("found volume intersection!\n");
  // Provide ray offset for use with isosurface geometries (this value
  // ignored elsewhere).
  ray.time = -rayOffset * volume->samplingStep;
  - ray.t = volumeT;
  - float tBegin = max(volumeT0,0.f);
  - float tEnd = volumeT+self->volumeEpsilon;
  - foreach_unique (v in volume)
  - {
  - vec4f volumeColor = SciVisRenderer_computeVolumeInterval(self, v, ray, tBegin, tEnd, 0.98f, 1, rayOffset, sampleID, quality);
  + float material_opacity = 1.f;
  + foreach_unique (v in volume) {
  + vec4f volumeColor = SciVisRenderer_computeVolumeInterval(self, v, ray, tBegin, tEnd, 0.98f, true, rayOffset, sampleID, quality);
  material_opacity = volumeColor.w;
  }
  - }
  alpha = alpha * (1.f - material_opacity);
  - if (alpha * weight < ALPHA_THRESHOLD) return alpha;
  + if (alpha * weight < ALPHA_THRESHOLD)
  + return alpha;
  + }
  +
  + if (!volume && ray.geomID < 0)
  + return alpha;
  if (--remaining_depth <= 0)
  return alpha;
  - ray.t0 = ray.t + rayOffset;
  + ray.t0 = org_t + rayOffset;
  ray.t = org_t_max;
  ray.primID = -1;
  ray.geomID = -1;
  