Hybrid Back/Forward path tracing (aka BiDir without MIS)

Discussion related to the Engine functionality, implementations and API.
Post Reply
User avatar
Dade
Developer
Developer
Posts: 3168
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Hybrid Back/Forward path tracing (aka BiDir without MIS)

Post by Dade » Sun Jun 23, 2019 12:42 pm

Introduction

The current implementation of PhotonGI caustic cache has been stretched up to the point to not make any sense. I'm looking for an alternative solution to replace and discard caustic cache altogether. Hybrid Back/Forward path tracing is what I'm thinking to use at the moment.

Hybrid Back/Forward path tracing

Path tracing builds paths from the eye toward the light source. Many years ago it was called also backward ray tracing. Light tracing does the opposite, builds paths from the light source toward the eye and it is really (only) good to render caustics (forward path tracing).

Bidirectional path tracing does both, building many times the same path in different ways and mix the result with MIS (multiple importance sampling). BiDir is slow because of the "building many times the same path" part.

My idea is to trace, alternatively, back and forward paths. The ratio is driven by a user defined parameter. The result works with OpenCL, is extremely fast and is really good to render caustics:

caustic.jpg

Notice the samples/sec. This picture was rendered using a single GPU and the GPU was dedicated to render only eye paths while the CPU was dedicated to render light paths (i.e. caustics).

This is technically bidirectional path tracing done using GPUs but without MIS and with asymmetrical workload. I think this solution is currently used by Iray.

Parameters

You can enable hybrid Back/Forward path tracing with:

Code: Select all

path.hybridbackforward.enable = 1
You control the ratio between eye and light paths with:

Code: Select all

path.hybridbackforward.partition = 0.8
This will trace the 80% of eye paths and a 20% of light paths.

The parameters work for both PATHCPU and PATHOCL (but read below). TILEPATH ignores the parameter because tile rendering can not work with light paths, for obvious reasons.

OpenCL

GPUs can still render only eye paths so when using PATHOCL, the parameters control only the ratio of the CPU work: GPU will always rende only eye paths, CPU will render both.
Most of the times, if not all, it is best to dedicate the GPU to render only eye paths, and the CPU only light paths (i.e. "path.hybridbackforward.partition = 0.0").

Glossy caustics

If this solution replaces caustic cache, I will add the support for glossy caustics too. It currently render only specular caustics like caustic cache.
Support LuxCoreRender project with salts and bounties

User avatar
Sharlybg
Donor
Donor
Posts: 1508
Joined: Mon Dec 04, 2017 10:11 pm
Location: Ivory Coast

Re: Hybrid Back/Forward path tracing (aka BiDir without MIS)

Post by Sharlybg » Sun Jun 23, 2019 1:08 pm

GPUs can still render only eye paths so when using PATHOCL, the parameters control only the ratio of the CPU work: GPU will always rende only eye paths, CPU will render both.
Most of the times, if not all, it is best to dedicate the GPU to render only eye paths, and the CPU only light paths (i.e. "path.hybridbackforward.partition = 0.0").
This seem to be a more natural idea. And les tricky settings. Thanks for the R&D.
Also the possibility to rules the CPU load between caustics and simple path is good idea when considering the fact that there are configuration with monster CPU. And scene where caustics is a bonus.
Support LuxCoreRender project with salts and bounties

Portfolio : https://www.behance.net/DRAVIA

User avatar
lacilaci
Donor
Donor
Posts: 1626
Joined: Fri May 04, 2018 5:16 am

Re: Hybrid Back/Forward path tracing (aka BiDir without MIS)

Post by lacilaci » Sun Jun 23, 2019 1:31 pm

well... this looks really neat.

And if it could also do glossy caustics, we might have a pretty fantastic solution.

I also agree that if caustic cache cannot be improved upon, it should be discarded

I have to ask though, will this render sds?

User avatar
epilectrolytics
Donor
Donor
Posts: 561
Joined: Thu Oct 04, 2018 6:06 am

Re: Hybrid Back/Forward path tracing (aka BiDir without MIS)

Post by epilectrolytics » Sun Jun 23, 2019 2:01 pm

This looks really promising!

Is it unbiased?
Does it do SDS-paths?

The caustic cache just became usable again with periodic permutation.
This is an approach with lots of potential but probably too high a cost of precious development time.
I understand if dealing with it has become dreadful.
Also it is difficult to set up for the user.

Can't wait to test the new build! :mrgreen:
MBPro 15" 16GB i7-4850HQ GT750M, MacOS 10.13.6 & Win10Pro PC 16GB Ryzen 2700X, 2 x RTX 2070

provisory
Posts: 224
Joined: Wed Aug 01, 2018 4:26 pm

Re: Hybrid Back/Forward path tracing (aka BiDir without MIS)

Post by provisory » Sun Jun 23, 2019 2:59 pm

Yes!
I think, this will be the Solution!

provisory
Posts: 224
Joined: Wed Aug 01, 2018 4:26 pm

Re: Hybrid Back/Forward path tracing (aka BiDir without MIS)

Post by provisory » Sun Jun 23, 2019 3:17 pm

epilectrolytics wrote:
Sun Jun 23, 2019 2:01 pm
Is it unbiased?
Does it do SDS-paths?
LightCPU can do SDS-paths, and unbiased (if I'm not mistaken), so I think it should be too.
Actually what I don't understand, is why this hybrid path tracing can't do glossy caustics out of the box, when LightCPU can?

User avatar
Dade
Developer
Developer
Posts: 3168
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: Hybrid Back/Forward path tracing (aka BiDir without MIS)

Post by Dade » Sun Jun 23, 2019 3:46 pm

epilectrolytics wrote:
Sun Jun 23, 2019 2:01 pm
Is it unbiased?
Yes.
epilectrolytics wrote:
Sun Jun 23, 2019 2:01 pm
Does it do SDS-paths?
It is like BiDir, it can only if the light is intersectable (i.e. it is directly visible, like an area light, not like a point light, etc.). But if the area light is very small, it may be not very good at rendering SDS paths (again, like BiDir).
Support LuxCoreRender project with salts and bounties

User avatar
Dade
Developer
Developer
Posts: 3168
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: Hybrid Back/Forward path tracing (aka BiDir without MIS)

Post by Dade » Sun Jun 23, 2019 3:51 pm

provisory wrote:
Sun Jun 23, 2019 3:17 pm
Actually what I don't understand, is why this hybrid path tracing can't do glossy caustics out of the box, when LightCPU can?
Because there is a static fixed partition of tasks: specular caustics are rendered by light paths and glossy caustics are rendered by eye paths. You can literally do 2 sperate renderings, one with "path.hybridbackforward.partition = 1.0" and one "path.hybridbackforward.partition = 0.0", merge the two images and get the correct result. There is no task overlaps like in normal BiDir.

It is about modifying the code so light paths will take care of glossy caustics too (and eye paths will not).
Support LuxCoreRender project with salts and bounties

User avatar
epilectrolytics
Donor
Donor
Posts: 561
Joined: Thu Oct 04, 2018 6:06 am

Re: Hybrid Back/Forward path tracing (aka BiDir without MIS)

Post by epilectrolytics » Sun Jun 23, 2019 4:15 pm

Holy shit this thing is fast!!
Wallpaper scene is nearly clean in two minutes, probably OIDN ready in one!
Including dispersion!
Screenshot.jpg
But (nearly) no SDS-paths is a problem for me, especially since we now have a solution for this since three days with periodic caustic cache.
I understand that no more development should be invested into caustic cache and this is fine with me but please let's keep this on board until there is another solution to the SDS problem.

In Blender Cycles render tab there is an option to choose between supported and experimental feature set.
Can we use this in Luxcore to hide the caustic cache from the user instead of discarding it?
MBPro 15" 16GB i7-4850HQ GT750M, MacOS 10.13.6 & Win10Pro PC 16GB Ryzen 2700X, 2 x RTX 2070

User avatar
B.Y.O.B.
Developer
Developer
Posts: 2971
Joined: Mon Dec 04, 2017 10:08 pm
Location: Germany
Contact:

Re: Hybrid Back/Forward path tracing (aka BiDir without MIS)

Post by B.Y.O.B. » Sun Jun 23, 2019 4:21 pm

Cool stuff!
One question: does it make sense to use this for CPU-only rendering, or will Bidir still win there?
Support LuxCoreRender project with salts and bounties

Post Reply