Page MenuHome

Cycles: bake transparent shadows for hair
ClosedPublic

Authored by Brecht Van Lommel (brecht) on Oct 15 2021, 4:44 PM.

Details

Summary

These transparent shadows can be expansive to evaluate. Especially on the
GPU they can lead to poor occupancy when only some pixels require many kernel
launches to trace and evaluate many layers of transparency.

Baked transparency allows tracing a single ray in many cases by accumulating
the throughput directly in the intersection program without recording hits
or evaluating shaders. Transparency is baked at curve vertices and
interpolated, for most shaders this will look practically the same as actual
shader evaluation.

Fixes T91428

Diff Detail

Repository
rB Blender

Event Timeline

Brecht Van Lommel (brecht) requested review of this revision.Oct 15 2021, 4:44 PM
Brecht Van Lommel (brecht) created this revision.

In my testing, basically scenes without transparent hair are not impact by this. I have not rerun the benchmarks yet after a bugfix, but basically what I got:

  • Spring: 73% reduction in render time compared to master. When using 128x128 tiles, it's about 3x faster than 2.93, so that fixes the regression.
  • Koro: 24% render time reduction compared to master.
  • Victor: 21% render time reduction compared to master.

It looks good to me. I ran the test and got the following:

97% tests passed, 4 tests failed out of 125

Total Test time (real) = 114.93 sec

The following tests FAILED:

	  3 - script_load_addons (Failed)
	  4 - script_load_modules (Failed)
	 37 - export_ply_vertices (Failed)

100 - geo_node_geometry_test_join_geometry_suzanne_cube (Failed)

These seem to fail on master also I don't think your code should affect these though but I thought I'd mention it just in case. The only thing I am worried about it the use of the extra Optix parameters as they are limited, I use them to pass the ray in the offsetting removal as I need to pass extra information.

intern/cycles/kernel/bvh/bvh.h
398–404

These are running out fast :-(

This revision is now accepted and ready to land.Oct 18 2021, 10:03 AM

Code looks fine and tests are passing. Some minor comments about unused arguments.

The failing tests is because arcanist forces the submodules to an older revision :( So you'd need to make update after arc patch, remove the bin folder and run make install again.

intern/cycles/render/hair.cpp
523
581
Brecht Van Lommel (brecht) planned changes to this revision.Oct 18 2021, 5:09 PM

The only thing I am worried about it the use of the extra Optix parameters as they are limited, I use them to pass the ray in the offsetting removal as I need to pass extra information.

I can avoid using the extra parameter. Either by adding a ShadowIntersection struct that contains both the throughput and intersections array, or by passing in an IntegratorState in the payload so we can write directly to the throughput and intersection array. Probably the latter is most efficient.

Rebase on shadow path decoupling, avoid extra OptiX payload.

This revision is now accepted and ready to land.Oct 18 2021, 8:15 PM

Here's benchmark results from the various patches in this stack.

For the spring scene it seems both optimizations help, so there's a pretty big speedup.

And without the spring tests so you can properly see the times for the other scenes: