Experimental Cycles light portals

Hi!

Today, I tried out to implement light portals in Cycles, and it worked out really cool!

For those who don’t know about light portals (like me two days ago :evilgrin:): Essentially, they are guides placed in indoor scenes that help the renderer to “find” environment lighting. For a forward path tracer like Cycles, they are only useful for environment light, not for sunlight (that needs bidirectional transport, as in Lux).

A quick example here:
An example scene, just diffuse materials, lit by a single-color background light, 16 samples: http://www.pasteall.org/pic/83488
The same scene, just with two portals in the wall gaps: http://www.pasteall.org/pic/83487
And for reference, an equal-time comparison (no portals, same rendertime as the image with portals): http://www.pasteall.org/pic/83489

It also works well with HDRI maps, not just with a single-colored background:
Same scene, now with an environment texture: http://www.pasteall.org/pic/83496
Same scene, with Multiple Importance sampling enabled (so, essentially the best you can get with “regular” Cycles):http://www.pasteall.org/pic/83497
Same scene, now with both MIS and light portals: http://www.pasteall.org/pic/83498
Same scene, only Portals now, no MIS: http://www.pasteall.org/pic/83499
And, of course also an equal-time comparison (no portals or MIS): http://www.pasteall.org/pic/83500

You can get a build for testing here (Win64): https://dl.orangedox.com/CqmcYSd7e5XyAL2Sfr/Blender_2.73_Win64_MSVC12_AS6_TM3_P1_CUDA.zip

To add a portal, add an area lamp that covers a light entry and check “is portal” in the lamp settings. Other types of lamps won’t work. This setting also makes Cycles ignore the lamp for rendering, so the rest of the settings is actually completely useless if portal is activated. That’s only a temporary solution, I’m not so sure how to improve this.
As for the placing: You don’t need to cover every single entry, but uncovered ones will still contribute noise. Also, one bigger portal is better that tons of small ones. Too many portals can produce a significant slowdown.

So, if you’re interested, try it out! Please post feedback, bugs, problems etc. here, I need it to create a “perfect” version for review :wink:

PS: If you’re interested in technical details, the sampling uses the area-preserving code for area lamps that was introduced in 2.73, which produces significantly better quality than the regular uniform surface sampling. That’s the main reason for using area lamps ATM.

Great job, that’s an extremely useful feature for many scenes. I hope we can see it in trunk soon.

Looks like there’s an artifact when the portal is close to a surface (division by zero somewhere?):



(this scene only has a grey environment, no other lights)

This setting also makes Cycles ignore the lamp for rendering, so the rest of the settings is actually completely useless if portal is activated. That’s only a temporary solution, I’m not so sure how to improve this.

You can just no draw the rest of the settings in that case, that’s how Blender usually deals with it. (Objects have tons of redundant type-specific information anyway). However, it would be best if there was just a “Portal” light type.

That’s great. It’s like a user-defined MIS. Could be implemented as a shader maybe ? “Portal BSDF”.

@lukasstockner97 You are my hero <3

Also CUDA doesnt work on GTX 970 (IDK if Cuda is supposed to work at all lol)

This is great !

Great Lukas!
This one could be a very handy new feature to cycles!

Great! Can’t wait to get home and test it!
Thanks a lot for your efforts, you’d be a great addition to cycles official developers team

Any Patch Lukas? Or a Mac Build?! Please:D

On my GTX 560 CUDA works, but on the GTX 970 it gives an error.

I’d also like a patch if possible, would love to test. I’m on Linux. Images looks very interesting, thanks for your work! :slight_smile:

After very quick testing it looks quite impressive. The speed/noise seems to be almost same as when using plane as an emiter but it’s much easier to setup more believable light with the portals. The only limitation is the use of area lamps - It would be much better if we could use meshes as portals. Imagine circle walls with openings - it would be difficult to cover the shape easily with rectangular lamps.
The only strange behaviour that I noticed is that when I add a Sun lamp into scene, while using the portal, the ambient light gets noticeably darker…
I hope I will manage to do some more serious test later.

As far as I know, portals have to be rectangular. At least to not cause a huge hit to render time tracing against tri primitives. Tracing against an analytical primitive like a plane is many times faster.

Light portals 38 seconds

http://theorysend.com/uploads/cd9c6ac943bad20d23b161ceb2db8afa13dfc7a6

No light portals 39 seconds


http://theorysend.com/uploads/dd2b75261635843a849b741d26d63fe7f2f4dd9d

And here is a area light just for fun 38 seconds


http://theorysend.com/uploads/b11c31866ca40c02e6fdb83c4dc1e3ed3a73f208

Great work. I hope to see this in master ASAP. :slight_smile:

Oops, I forgot to build the sm_52 kernel, that’s why the GTX9xx won’t work. Just go to 2.73/scripts/addons/cycles/lib , copy the sm_50 files and rename them to sm_52.

Patch is here, but as I said, it’s quite experimental and stuff will probably change in the future: http://www.pasteall.org/56581. Just run “git am <file>” and it should build.

Regarding portal meshes: In theory, it’s possible. In practise, however, not so much. As m9105826 already said, multiple primitives cause a huge slowdown. Covering a circular hole in a square portal will most likely be way faster. My favourite option is to add a portal object, in theory, it could support multiple shapes like squares, rectangles, circles, ellipses, polygons etc.

As for the two problems (sunlamp and close-up artifacts): Thanks for the report, I’ll have a look.

“Oops, I forgot to build the sm_52 kernel, that’s why the GTX9xx won’t work. Just go to 2.73/scripts/addons/cycles/lib , copy the sm_50 files and rename them to sm_52.”

I came here just to say that exact thing xD your fast :stuck_out_tongue:
Anyways more tests now with GPU

33 Seconds with portals 3 bounces max/min branched pathtracing

http://theorysend.com/uploads/de06ad2083d340ef97af523d68ca3eb657b099be

33 Seconds no portals 3 bounces max/min branched pathtracing

http://theorysend.com/uploads/11974acc8189e4dc95a466be6c198f39588a79fc

I have been noticing a lot (1 or 2) of random unexplainable fireflies with the portals though could that be the ol cycles casting light though geo trick you see when moving your camera in to an objects that has no lights on the inside but bright lights on the outside

That is interesting results, LordOdin, I imagine that coul dsimplify lighting for animation in a big way - have you tested anything with textures yet?

@LordOdin great results.

I’m noticing same as maraCZ, when there are other lamps in the scene (sun or even spot inside the “interior”) there is a difference in overall light. Haven’t images yet, will post when i can.

Also with Sun it seems the improvement given by portal alone is almost cancelled. Needs more testing, nothing sure atm.

How does glossy and Glass materials inteact with this?

Here is a pretty hard scene for pathtracing which the light portals were actually worse

The light is coming through transparent material which may be causing this

50 Seconds no portals 3 bounces max/min branched pathtracing

http://theorysend.com/uploads/a75978c26c943967f724fb99c098ef430570a9eb

50 Seconds portals 3 bounces max/min branched pathtracing

http://theorysend.com/uploads/25f7a68943a6fc519f13a49fe714655fc4a04072