Improve ambient occlusion in volume rendering

@LucasGandel I’ve experimented with your code a bit and I think that IntensityScale property is not used optimally. If we use scaling < 1 values then the shadows are just become too weak - almost no shadowing occurs. However, using scaling > 1 values seem useful, as they can increase darkening. But we would not want to darken values that are below the VolumeOpacityThreshold, because that would just make the entire image dark. To solve this, I would propose to scale around the VolumeOpacityThresholdValue.

Currently in your branch (everything gets darker as scaling increases):

"  gl_FragData[0] = vec4(vec3(1.0 - occlusion * " << this->"  gl_FragData[0] = vec4(vec3(1.0 - (occlusion - " << this->VolumeOpacityThreshold << ") * " << this->IntensityScale << "), 1.0); \n"; << "), 1.0); \n";

Proposed (only occluded regions get darker with increased scaling):

"  gl_FragData[0] = vec4(vec3(1.0 - clamp((occlusion - " << this->VolumeOpacityThreshold <<" ) * "<< this->IntensityScale <<", 0.0, 1.0)), 1.0); \n";

The set function of IntensityScale also needs to be changed to allow >1 values (range of 0.0 to about 5.0 should suffice).

I have not looked at the OpacityPremultiplied option yet.

5 Likes