Experimental Cycles light portals

(lukasstockner97) #1


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.

(BeerBaron) #2

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.

(Hadriscus) #3

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

(LordOdin) #4

@lukasstockner97 You are my hero <3

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

(Pitiwazou) #5

This is great !

(tungee) #6

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

(marcoG_ita) #7

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

(tungee) #8

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

(maraCZ) #9

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

(Sanne) #10

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:

(maraCZ) #11

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.

(m9105826) #12

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.

(LordOdin) #13

Light portals 38 seconds


No light portals 39 seconds


And here is a area light just for fun 38 seconds


(cdog) #14

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

(lukasstockner97) #15

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.

(LordOdin) #16

“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


33 Seconds no portals 3 bounces max/min branched pathtracing


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

(Craig Jones) #17

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

(marcoG_ita) #18

@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.

(tungee) #19

How does glossy and Glass materials inteact with this?

(LordOdin) #20

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


50 Seconds portals 3 bounces max/min branched pathtracing