RenderKit / ospray

An Open, Scalable, Portable, Ray Tracing Based Rendering Engine for High-Fidelity Visualization
http://ospray.org
Apache License 2.0
1.02k stars 186 forks source link

Rendering large amount of transparent meshes with few highlighted opaque ones #385

Open NadirRoGue opened 4 years ago

NadirRoGue commented 4 years ago

For Blue Brain's Brayns we are trying to add a new feature that consist in highlight few specific primitives with opacity = 1 spread across a large amount of primitives with opacity < 1. The goal is to identify specific primitives and be able to spacially locate within a larger group.

The problem we are facing is that, by having a huge amount of transparent primitives, the rays use up all their bounces before reaching the opaque ones.

Is there any approach or suggestion we could put in use?

paulmelis commented 4 years ago

How about rendering the fully-opaque objects in a separate pass that returns depth information (you can use very simple shading as getting per-pixel depth would be the goal). Then use that pass as maxDepthTexture on a second render that includes all objects (both opaque and semi-transparent), while using a very high ray maxDepth value. The latter would need to be relative to the maximum depth complexity you want to show, i.e. number of semi-transparent surfaces seen through a pixel (possibly only the number of semi-transparent surfaces needed in front of the opaque objects). This should give you somewhat reduced render times as camera rays get cut off early, compared to just setting maxDepth very high. But I have no feeling for how much performance increase this could give.

And if you use very diffuse shading in the path tracer rendering you would still get a performance hit by having a high maximum ray depth.

johguenther commented 4 years ago

I agree, two passes (opaque first, then transparent) should give best performance. For the transparent pass best use Embree's filter functions to simply accumulate the transparency, basically just a single ray / bounce is used. This is correct (the order of the accumulation is not guaranteed) if the transparency means only attenuation. Otherwise the potential hits need to be sorted first. Using filter functions to optimize transparency is on our TODO list, so not implemented yet.

There are some choices how to do the two passes: