2008-04-02

Why does my animation flicker?

It seems like alot of folks on the forums are asking this question. Often when using low GI and Final Gather settings, an animation will flicker because the solution is not refined enough. To have a smooth animation you have to crank up your settings high enough to have similar results for each frame. Problem is you will have extremely long render times. This is my attempt at explaining how to create smooth animations with low indirect illumination settings in Max 2008.


common problem with low GI and Final Gather settings


Here's a quick step-by-step, but if you read further I have exhausted each of these steps in detail.

•Turn on Photon Map, use Read/Write File, then render
•Turn on Final Gather, use Read/Write File
•Lower samples to 1/64 - 1/64
•Render active time segment at every 10 frames
•Turn on final gather Read Only (FG Freeze)
•Increase samples to 1 - 16
•Turn on Save File for Render Output
•Render active time segment at every 1 frame


First we calculate the photon map (PM). When calculating the PM it's a good practice to have final gather (FG) off to see the pure PM results. To save your PM click on the [...] button, and if you are rendering on a renderfarm, be sure to save your PM in a location that the farm has access to (your network). Also be sure "Read/Write File" is checked.



Now go ahead and render a single frame. Mental ray will calculate the PM first, save it to the location you specified, then renders your scene. Very important to note: now the second time you render, mental ray will not re-calculate the PM, but rather read the already calculated PM from the file location you specified because you have "Read/Write File" checked. The PM is scene based rather than view/camera based. This means that when the PM is calculated it is calculating the entire scene (much like radiosity). The great thing about the PM, is that once it is calculated, a rendering can be done from any view using that same PM...wonderful for animations!



Now that we have our PM calculated, we're now going to move onto FG. Unlike the PM, FG is view/camera based. This means that when a FG map is calculated the information in the map is only of that viewing angle. So if you wanted to see both sides of an object, you would need at least 2 FG maps. This is very bad news for animations. Because every frame in an animation is different, you would need a new FG map for that frame. But we have a work around for this that I will get to.




For now:
•under FG check "Enable Final Gather"
•for the Preset choose Draft
•under Final Gather Map click on the [...] button, and choose a location to save the FG map.

Be sure "Read/Write File" is checked and "Read Only" is not checked.



Now to get back to our problem of needing different FG maps for every frame. Instead of creating a FG map for every frame, I create a FG map for a range of frames. For example, if my animation is 100 frames long, I will render every 10 frames creating a FG map for only those 10 frames. Then with that combined FG map, will go back and render every frame. Here's how to do this:



Make sure FG Map is checked on. Then in the Renderer tab, lower your samples to 1/64 - 1/64. We are doing this, because we are not concerned with the actual rendering, but just the calculation of the FG map. In the Common tab, change your Time Output to Active Time Segment, and under Every Nth Frame change it to 10.




Now click Render. You will get a warning that pops up telling you that you are rendering a sequence without saving the images to a location. That's ok, because we are just interested in FG at this point. So click Yes. Now the animation will render every 10th frame. Because we have "Read/Write File" checked and do not have "Read Only" checked, every time FG for a frame is calculated it is added to the previous FG map. After all 10 frames render, you now have a single FG map for your animation sequence.



Now go back to Indirect Illumination tab, and under Final Gather Map check "Read Only". Now when you render, it will not add to your already created FG map, but just read the one that it's locating to. Also increase your samples back up to something reasonable (1-16), and change your "Every Nth Frame" back to 1. Also be sure to set your Render Output to save to a file location.

That's it. Click render and enjoy!



Animation using PM and FG from file



Now it will start the rendering right away without calculating any indirect illumination. Even though the solution for PM and FG are low, it's not that noticeable. The noise will be even less noticeable when texture are added. Note: this technique doesn't work well for secondary animation (animation with moving objects or characters).

44 comments:

  1. 5 stars for this trick thx a lot...

    ReplyDelete
  2. Very good subject to write about. I was wondering if you are able to make one for Vray also?

    ReplyDelete
  3. What is "secondary animation"?

    ReplyDelete
  4. my photon map option is greyed out, and i can't ckick the check box. am i missing another option somewhere that allows the photon map to be 'checked.'

    ReplyDelete
  5. If you're talking about the Read/Write checkbox, the photon map check box will be grey until you save a map to a location with the [...] button.

    ReplyDelete
  6. WHOA! Life saver right here. Thanks!

    ReplyDelete
  7. Thank you very much

    I have been difficult with this problem.

    your tip is really perpect.

    I really appreciate you.

    ReplyDelete
  8. thank you very much. excellent tip, but what if in my scene some objetcts are moving or animated?

    ReplyDelete
  9. If you have moving objects, then you will have to render FG for every frame. You can also render just the moving objects and composite them onto the background in post...this process can turn into a tedious one though!

    ReplyDelete
  10. Thanks again Ramy. i`ve rendered the entire sequence saving the FG map for every frame, but the problem is still there, now is like the splotches are following the moving object and not randomly generated as before. When i render any frame individually, the splotches are gone for that specific frame (read/write file OFF).

    greetings from southamerica.

    ReplyDelete
  11. You are getting splotches that are following the moving objects because you are saving the FG map. To avoid this you have to calculate FG for every frame, and not save the FG map. If you render at high enough settings you won't get splotches, but this is very time intensive.

    ReplyDelete
  12. thanks again Ramy! i`ve render my scene (well... part of it) like 12 times with different settings (noise filtering, filter type, jitter on and off...) and now i realize that the flickering was generated by a specific material in my scene, so i`ve changed it to a arch&design and everything worked marvelous rendering without saving the FGmap!!!! i`m so happy.
    thanks again for your time and all your really really helpfull tips and tricks. keep on rocking mental ray!!

    ReplyDelete
  13. So you can't skip the render process. This would bring down render times enormously.

    ReplyDelete
  14. Spot on mate, thanks very much. Just rendered out a photoreal room fly-through and your method sorted all my flicker!

    Matt

    ReplyDelete
  15. youre fantastic! Thanks a lot for this =)

    ReplyDelete
  16. Is anyone getting black marks on some objects?

    ReplyDelete
  17. Yes i am getting black splotches on objects still. Just like Nacho... saving the map is actually creating black marks on objects that did not have them before even though it fixes other ones.... So i am not sure where to go from here... I have managed to tweek the settings of some of my clips so that i dont bother to save the FG map. I dont have GI turned on so i am not making a PM file. For cases where i cant find a solution should i turn off FG and just use GI so that i can build a nice quality PM map?

    ReplyDelete
  18. if you have moving objects in your scene, this technique only partially works. For your moving objects you will have to use this method.

    ReplyDelete
  19. I have no moving objects just a moving camera. Just zooming in on something. My latest version is much better. I replaced a standard material with a A/D material. I thought i had already done that but had imported an object from an old scene i think. Now most of my smoke issues have gone away but my render times have gone through the roof with the A/D mat. Working on trying to fix that now.

    ReplyDelete
  20. What about baking the lighting? You have anything on that, and wouldn't that be easier theoretically?

    ReplyDelete
  21. Actually, this worked well, very well. However I'm having a problem with my walls. They are bumpmapped and as the camera moves down the hall it sparkles. Are these artifacts? Just looks like my walls and ceiling are glistening...My boss wants it out. I'm pretty sure it is a mental ray mat

    ReplyDelete
  22. Fixed it...scintillation I guess it's called. My bump map was too detailed and tiled too small with not enough blur on it. I couldn't get the settings just right so I just changed it from cellular to noise.

    ReplyDelete
  23. my perspective view isnt reflecting any light, and keeps coming out black, and I've already fliped my normals under the modifier list. Does anyone know what else I can do?

    ReplyDelete
  24. Hmm Could you explain the way to do it in 2010... The ui is very different :(

    ReplyDelete
  25. Hey! Thank you for this GREAT tip! It's SO USEFUL!
    I have one small question, how would you determine the amount of frames you skip when you render the FG map (before you freeze it)?
    In this instance you picked 10. But some times this isn't a good number and you can still see flickers. Is there any method to determine that?
    Thank you!

    ReplyDelete
  26. Thx Ramy,

    This architecture student form South africa realy appreciates this! Have a small Q though if you dont mind - after rendering each frame my pc take a helluva long time to "clean up". I think its just because my model is so damn big - at render time with xrefs laod its 29mil faces (yes its a huge building!!) Im rendering on a friends pc with xp64 and 4gb ram - it does push ram usage to the limit and i have conserve memory at 3500.

    Any advice? or am i just screwed!? :)

    Thx for a great blog Ramy.

    ReplyDelete
  27. Thank you very much!!

    ReplyDelete
  28. Thanks! Just what I needed for my exam!!

    ReplyDelete
  29. Really good trick and very helpfull! Thanks!

    ReplyDelete
  30. What if I wanted to animate the sun moving as if i had speeded it up over a eight second period? Really helpful though thanks!

    ReplyDelete
  31. when calculating FG in 2nd step shall i enable GI or not?

    ReplyDelete
  32. Yes, GI should be enabled when calculating FG.

    ReplyDelete
  33. Is it possible to avoid flickering without using GI, but only FG? My scene is too render intensive and when I allow them both ı get an hour per frame in an 8-core machine, I need to somehow only use FG and not get flickering. Any ideas?

    ReplyDelete
  34. Absolutely. You don't have to use GI. Just be sure your FG map is being read from file to avoid the flicker.

    ReplyDelete
  35. Hi Ramy,

    I'm a second year architecture student and would like to shout out THANK YOU SO VERY MUCH for this neat trick.

    Rendering my project already took forever, but to find out that it's flickering after all the rendering has been done?? I was on the verge of giving up and wanted to just submit a flickering animation in a few days time cause rendering the entire thing again with a higher FG quality would be impossible time-wise.

    I was so happy when I stumbled upon this post and even happier when I tried it out and saw how it worked.

    Once again, thanks very much!

    Kind regards,
    Chien.

    ReplyDelete
  36. Hi Ramy,
    thank you very much!
    New version (2012max), new problems with the FG options. Any tricks?
    Best Regards,
    Bartek

    ReplyDelete
  37. SP2 for max2012 should fix this: http://usa.autodesk.com/adsk/servlet/ps/dl/index?siteID=123112&id=2334435&linkID=10381720

    ReplyDelete
  38. Hi Ramy,
    I noticed in your Efficient Interior Lighting with mental ray tutorial you say that you render out your FG map at around 50% of your actualy render size, is this something you could also do for the photon map?

    ReplyDelete
    Replies
    1. FG is based on the camera where as GI is not camera dependent, rather scene dependent. So the size of your render for GI makes no difference.

      Delete
  39. Does this solution require "Project Point From Positions Along Camera Path" to be selected with a number of segments chosen? Or does this solution ultimately do the same thing?

    ReplyDelete
    Replies
    1. This method doesn't require "Project points from Position along camera path". It works with the "best for stills" method.

      if you don't have anything moving in your scene except the camera, they essentially do the same thing.

      Delete
  40. Does this solution require "Project Points From Positions Along Camera Path" to be selected, along with a number of segments? Or does this solution ultimately do the same thing? I'm running on max 2010.

    ReplyDelete
  41. Yeah, I just noticed that after I commented. I looked at your other tutorial that involves moving objects as well, but that process might not be possible with my complex scene.

    I'm really looking for a way to avoid so many map files. My photon maps are running 5mb a frame at 1700 frames... about 9gb of photon maps. Am I wrong to say that I need one for every single frame? There has to be a better process than this b/c the render farms can't accept such big files. And this doesn't even include my fg maps - which are larger.

    ReplyDelete
    Replies
    1. no, you only need 1 photon map for the entire scene. unlike final gather, when the photon map is calculated, it is not based on the camera view, but gets calculated for the entire scene!

      Delete