Skip to content

Commit

Permalink
fix for volume gradient shading with zero gradient vector and new saf…
Browse files Browse the repository at this point in the history
…e_normalize().
  • Loading branch information
gregjohnson committed Dec 18, 2015
1 parent 680d045 commit 456d633
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ospray/render/volume/RaycastVolumeRenderer.ispc
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ inline void RaycastVolumeRenderer_computeVolumeSample(RaycastVolumeRenderer *uni

for (uniform uint32 i=0; i<renderer->numLights; i++) {
const LightSample light = renderer->lights[i]->sample(renderer->lights[i], dg, s);
const float cosNL = isnan(gradient.x+gradient.y+gradient.z) ? 1.f : abs(dot(safe_normalize(light.direction), gradient));
const float cosNL = (gradient.x == 0.f && gradient.y == 0.f && gradient.z == 0.f) ?
1.f : abs(dot(safe_normalize(light.direction), gradient));

shadedColor = shadedColor + sampleColor * cosNL * light.radiance;
}
Expand Down

0 comments on commit 456d633

Please sign in to comment.