Tuesday, April 24, 2012

Optimizing the portal light.

Traditionally, to simulate the illumination that comes through the window, area lights are placed in the window. This method is enhanced by using portal light which obtains its intensity and color from the environment outside the window.
The portal light helps in a great deal reducing Final Gathering's noise and since it's a light source it can cast shadow.


 
 Here's a scene with a room. I have set up an area lights for each window and a portal light is connected to each light.



 This is the spherical environment texture used for IBL as a primary environment for Mental ray in HDR format. It's a very high resolution texture. ( 6250x3125)
Using the default setting, this is the initial render result.




 
RC   0.3  info :   type                           number   per eye ray
RC   0.3  info :   eye rays                      2446614          1.00
RC   0.3  info :   transparent rays               308765          0.13
RC   0.3  info :   shadow rays                  93660841         38.28
RC   0.3  info : wallclock  0:14:19.38 for rendering
RC   0.3  info : allocated 1463 MB, max resident 1476 MB
It took around 14 min to render. That's quite slow and the Final Gathering was even on.
Let's turn off Lookup Using FG Rays option and render again.



RC   0.3  info :   type                           number   per eye ray
RC   0.3  info :   eye rays                      2610573          1.00
RC   0.3  info :   transparent rays               308765          0.12
RC   0.3  info :   shadow rays                  98771344         37.84
RC   0.3  info :   environment rays            100692186         38.57
RC   0.3  info : wallclock  0:01:43.34 for rendering
RC   0.3  info : allocated 1449 MB, max resident 1462 MB
The render time's reduced dramatically. It only took 1m 43s. So Let's stay away from using Lookup Using FG Rays feature for now.
Now look at the wall on the left portion of the image. You can see very fine grainy noise on the wall.
This is from using shadow threshold of 0.005 which is on by default.
Let's set it to 0 and render again.


The render time's reduced again. It took 1m 35s and visually there's no grainy noise.
Let's try to use a custom environment for the Portal light Instead of using the high-res image with all the small and sharp details.
I scaled down (780x390) and blurred the env texture like below and use it as a custom environment texture.


Be sure to flip the image horizontally since the custom environment node is flipped to the opposite of IBL.
 
Turn on Use Custom Environment and create and connect the new Env.






 
The below is the render result.


 
RC   0.7  info :   type                           number   per eye ray
RC   0.7  info :   eye rays                      1631469          1.00
RC   0.7  info :   transparent rays               308898          0.19
RC   0.7  info :   shadow rays                  84620960         51.87
RC   0.7  info :   environment rays             84620960         51.87
RC   0.3  info : wallclock  0:01:16.66 for rendering
RC   0.3  info : allocated 1473 MB, max resident 1486 MB
Without losing no noticeable quality, now the render time is reduced to 1m 16s.
I think the render time's low enough and now I'll turn on FG and render.
Here's the settings for FG which is moderate.
Accuracy : 128
Point Density : 0.5
Point Interpolation : 40
Secondary Diffuse Bounces : 2


RCFG 0.9  info : depth  #finalgather points
RCFG 0.9  info :   0                  55670
RCFG 0.9  info : ray type                  number
RCFG 0.9  info :   eye                      80909
RCFG 0.9  info :   transparency              1213
RCFG 0.9  info :   shadow                32187748
RCFG 0.9  info :   environment           32187748
RCFG 0.9  info :   finalgather           14031127
RCFG 0.9  info : balancing updated finalgather map (55670 points)
RCFG 0.9  info : wallclock  0:00:56.67 for computing finalgather points
RCFG 0.9  info : allocated 1526 MB, max resident 1734 MB
RC   0.3  info : rendering statistics
RC   0.3  info :   type                           number   per eye ray
RC   0.3  info :   eye rays                      1455672          1.00
RC   0.3  info :   transparent rays               308898          0.21
RC   0.3  info :   shadow rays                  73369984         50.40
RC   0.3  info :   environment rays             73369984         50.40
RC   0.3  info :   fg points interpolated        1146406          0.79
RC   0.3  info : on average 73.51 finalgather points used per interpolation
RC   0.3  info : wallclock  0:02:05.18 for rendering
RC   0.3  info : allocated 1527 MB, max resident 1734 MB

It took 2m 05s. This is a very acceptable result considering the initial render took 14min even without FG.
I turn on Lookup Using FG Rays option now and render again to get the same quality but the render time's reduced by 9 seconds.

RCFG 0.9  info : depth  #finalgather points
RCFG 0.9  info :   0                  55670
RCFG 0.9  info : ray type                  number
RCFG 0.9  info :   eye                      80909
RCFG 0.9  info :   transparency              1213
RCFG 0.9  info :   shadow                32187748
RCFG 0.9  info :   finalgather           14031127
RCFG 0.9  info : balancing updated finalgather map (55670 points)
RCFG 0.9  info : wallclock  0:00:53.93 for computing finalgather points
RCFG 0.9  info : allocated 1528 MB, max resident 1734 MB
RC   0.3  info : rendering statistics
RC   0.3  info :   type                           number   per eye ray
RC   0.3  info :   eye rays                      1455554          1.00
RC   0.3  info :   transparent rays               308898          0.21
RC   0.3  info :   shadow rays                  73362432         50.40
RC   0.3  info :   fg points interpolated        1146288          0.79
RC   0.3  info : on average 73.51 finalgather points used per interpolation
RC   0.3  info : wallclock  0:01:56.23 for rendering
RC   0.3  info : allocated 1528 MB, max resident 1734 MB

From my tests, I found that Mental ray's default IBL environment doesn't work well with the portal light especially when a very high-resolution texture is used.

I strongly recommend using a custom environment for the portal light.





No comments:

Post a Comment