appleseed icon indicating copy to clipboard operation
appleseed copied to clipboard

Shadow catcher proof or concept

Open usakhelo opened this issue 4 years ago • 0 comments

Hi, This is the proof of concept of shadow catcher feature. This code relies on specific object naming, just to show how the feature might work. There's no special shader or any other way to mark an object as a shadow catcher except specific name, which is "Box001_sc_inst" instance name.

How it basically works is it gathers two additional values from all light sampling functions - one is the light value before transmission parameter is applied, and another is the light value after tranmission but and without object's material contribution. Having these two values allows us to calculate shadow "intensity" and affect alpha channel accordingly. Also shadow catcher object is shaded with environment color multiplied by shadow value.

I tried to replicate Ospray approach: https://github.com/ospray/ospray/blob/7c01f46bb9ee9f7ebcb95e116bffd39d23f5a2f3/ospray/render/pathtracer/ShadowCatcher.ispc#L80

PR contains test scene and some images in /sandbox/tests/shadow_catcher/ folder. The most recent scene is test_shadow_catcher.appleseed, it contains reflective and refractive materials. To see the box object in a normal way just rename the instance to something else. Only one lighting engine is modified and it's Path Tracing lighting engine and PathVisitorNextEventEstimation visitor.

I'm not sure how to dedicate an object to be a shadow catcher. Easiest way would be to have a boolean value on the instance level. Also I'm not sure about the cleanness of the approach. You might think it looks like a hack and I would agree. Please share your ideas.

Thanks for review, Sergo.

usakhelo avatar May 23 '20 21:05 usakhelo