Showing posts with label final gather. Show all posts
Showing posts with label final gather. Show all posts

Wednesday, May 2, 2012

Do not scale the camera!


There are cases where you shouldn't scale the camera, otherwise you will get artifacts or poor performance.

Case 1:  When you use a mia_env_blur node  to provide with a blurry reflection to a mia material.


This is a highly reflective metal material. I use the mia_envBlur to apply the blurry reflection like the following.

  
And then I scale up the camera by 5 times.


You'll get this pinching point like artifact.
This time, I will scale the camera down by 5 times ( 0.2 ).


Another weird artifact.
So, don't scale up or down your camera when you use mia_envBlur for blurry reflections.
It doesn't matter how much. As soon as you begin changing the scale it will go bad.



Case2:  When you use Optimize for Animations FG mode with View option on.



This time, I use the FG to create this.


I use Optimize for Animation mode with View option on. It gives me a fairly even FG point distribution like below.


So far, so good. But if I scale up the camera, let's say by 10 times.
The FG brightness diminishes by around that much like below.



This has to do with the fact that the View mode uses the camera space to deal with FG points and density. You can compensate the brightness by scaling up the Min/Max pixel value by the same scaling factor that's applied to the camera.

That being said, I'd rather not use a scaled camera.
 

Bent normal to simulate indirect illumination(plus diffuse convolution).


Using the final gathering for animated objects demands very high settings and could take a very long rendering time. This high settings are usually for preventing flickering or swimming pixels in the image.
If there's a flicker free solution, one can feel free to use the final gathering for animation.
Bent normal can produce a one-bounce final gathering like result easily, even though it takes some preparation.





Fist, I used the final gathering using the following 2k environment map to get this result.



This is a 3-bounce FG result. 
I assigned a white mia_material on the left one. I will use bent normal env as an indirect illumination input for the right one.

Here's the bent normal env connection which will be used as an indirect illumination input.



The bent normal env node's attributes.


The amb occlusion node feeds the Bent Normals attribute of the bent normal env node.




 For the environment texture for the lookup_spherical node, you need a convolution-applied version of the environment texture that was used for the final gathering.


This small thumbnail-like image is what I used as an input environment for the bent normal env node.
It can be really small like this since it doesn't require any detail. It's just to simulate a fully diffusive illumination.

Here's the other mia_material for the object on the right.
I connect the output of the bent normal env node to the Ambient Light Color attribute.



 Now, this mia material shader has an incoming illumination which is attenuated by the build-in AO.



This is the render result. The left one is illuminated by FG and the right one is the simulated indirect illumination that comes from the bent normal environment.( I turned off the Final Gather Cast and Receive render flag for the object on the right to prevent it from getting the double indirect illumination.)


They look almost the same. This method can be a good alternative to the FG. It's flicker-free.
With a textured shading, it's almost impossible to tell which is which.



Saturday, April 28, 2012

How to save a final gather map file for each frame


When you use the final gathering for animation, you'd probably have to refresh final gather map and rebuild it from scratch at every frame unless it's a camera fly-thru only animation.
In that case, you'd have to use very high settings for the final gathering and each frame would take a good amount of rendering time. What if you have re-render the entire sequence for some reason.
All the final gather maps that you previously calculated has been over-written and only the final gather map for the last frame remains. What a waste.
So, I'll show you a simple way to save all the final gather maps that are created during the rendering.

 
You can access and control the final gather map's name by the attribute called
"miDefaultOptions.finalGatherFilename"

You can simply set this attribute to a file name of your choice using setAttr command like below.
The filename goes between the parenthesis. 


setAttr -type "string" miDefaultOptions.finalGatherFilename ("FGmap_save."+`currentTime -q`+".fgmap");

Here, my scene file name is" FGmap_save.mb", so I typed "FGmap_save.".
You can use your scene file name or any name.
Each fgmap name will be unique by quoting the current frame number using `currentTime -q` command and appending that to the file name.


This one-line script goes to Pre render frame MEL slot under Render Options  in Common tab.


This mel script will be executed before every render begins at each frame.
Now you can find that for every test render,  the Primary Final Gather File name updates for the current frame.

Now render your sequence with FG rebuild option ON and your FGmaps will be saved for each and every frame. 

When you need to re-render any frames or the entire sequence, just switch the Rebuild option to Freeze and render again. The renderer will locate the corresponding saved FGmap for each frame.




This can be a big time saver especially when you find that you need to adjust the Point Interpolation attribute only after the sequence is once rendered.



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.