Tuesday, July 20, 2010

Changes and Dependencies

A couple of days ago somebody sent me a link to an automatic "Siggraph Paper Title Generator" which produced quite convincing scientific-sounding output. The title of this post could easily be mistaken for something programming-related, but it is about something else completely.

I haven't posted since April because the last couple of months were quite crazy. In short, my family just finished relocating through half Canada - from Winnipeg, Manitoba (the city closest to the geometric center of North America) to Vancouver, British Columbia (at the very edge of the continent). This is a quite positive change - no more winter temperatures lower than on the South Pole, no more mosquitos in the summer (considered the "national bird" in Manitoba ;o)) And last but not least, finally some hills, mountains and curves on the roads to make the driver in me happy.

The move itself went ok without any incidents, all our stuff arrived a week later than expected but absolutely preserved (especially the PC and the TV - sigh of relief), and the first thing after ensuring electric power was still on was calling the cable/internet provider to order the Most Important Thing after water and bread. This was on June 28th and I was told that the earliest possible appointment date would be July 11th. TWO WEEKS without Web, Email and Skype? Oh my...

The very next day I replaced my trusty dumb phone with a smart one just to get some form of online access. This gave us at least some email, web services and the ability to chat via text messaging with our parents in Europe, plus the added bonus of GPS turn-by-turn navigation. While this was one of the best purchases considering the situation, it wasn't enough and I finally realized how dependent (read: Addicted!) we have become to the internet.

Two days after arrival I was chatting with a colleague and discovered that another company otherwise known for its wireless services and cute animal commercials had started to provide optical cable in our area. In fact, they even had a brochure sent to the "current occupant" of our apartment, but my selective reading brain totally skipped over the first two letters of the title (which said "TV"!) that also promised phone and internet. So I immediately called the company and asked if we can even get their services, since I knew that some large buildings downtown had preferred partnership with the former cable TV monopolist I already had an appointment with. The answer I received left me nearly speechless. "Looking at our data here, it appears that your building has been pre-wired for out optical cable services, and TV and internet are already pre-paid by the building management for a year!". Oh, and they could come 5 days earlier than the competition (YAY!)

Too good to be true?

The lady on the phone promised to call me half an hour later to confirm my credit check and the appointment for the 6th of July. She never did, so the next day I called again. The person at the other end of the line went through the whole identification process and confirmed the 6th of July appointment. So on the 6th of July I took an hour off from work and went home to be around during the installation... except that nobody showed up. Another phone call later I learned the amazing truth: Computers Hate Me!

I was told that a software bug in the internal system of the company is preventing anyone in the call center from scheduling that appointment (three people so far had attempted to enter it and all got the error which I was told "nobody had seen before"). Being a TD and fighting the good fight with bugs every day, I don't really mind bugs, but I do mind when people don't tell me about them (Funnily enough, the name of the company implies they would "tell us" when something like that happens ;o)). So I was told that the top-dogs of the software team were looking into the problem and would call me as soon as it was fixed. I was even encouraged to call again the next day to check. Of course I did and had my fifth conversation with a fifth person about the whole issue. "Please believe us that we are working on fixing the bug". In all this time, I never received a call back from anyone. Probably because nobody cared personally, or probably because my bill was already paid for a year anyway, so an important stimulus was missing... ;o)

While getting home from work via a slightly different route that day, I realized that the head quarters of the company I was dealing with was literally the NEXT BUILDING to ours! So the next morning I went into the lobby and asked to talk to someone responsible for customer relations. Instead, I got connected with the technical team responsible for that "bug" and was told the bug was fixed and they could finally schedule an appointment. (Until this day I don't know whether this was just good timing or there was never a real bug). Of course, this was on July 9th so the earliest possible opening was for July 16th - over two weeks after my first call...

Being as addicted as I turned out to be, I could not wait 5 more days without internet. So we scheduled the 16th but also left the initial appointment with the other company on the 11th and on that glorious Sunday finally got some cable to scratch that online itch. Four days later we switched to the optical cable with HD, free PVR, 15 Mbps wireless access from all devices and finally felt home... This blog is just a reminder how much our lives have changed in the last decade and how dependent we have become... Now let's hope SkyNet won't take over soon ;o)

Back on topic (this is a Krakatoa/MAXScript blog after all) - the next shocker is that the year of the 20th birthday of 3D Studio will be the first in 11 years with me missing Siggraph. I wish everyone going a great time and while I am sad we won't be able to show you first hand what we have done to Krakatoa 1.6, I promise we will be very active online once it is released. I am spending a lot of time polishing both the documentation and the UI, and a lot of features are still being tweaked for maximum flexibility.

I hope the next blog will be a lot more interesting.

Sunday, April 18, 2010

How Fast is Fast?

In pretty much every review or comment about Krakatoa, I see something along the lines of "Krakatoa renders really fast". Don't get me wrong, I like reading that, but let's be fair - speed is relative (ask Albert E.) and people don't say this because Krakatoa is actually fast, but because most mesh-based particle rendering solutions for 3ds Max are slower in comparison.

All this good press makes my job harder as I try to push for speed improvements in the development of future Krakatoa versions (you might not know this, but my middle name is "Speeeed!"). We are in the business of selling software to users, and if a single copy of Krakatoa can get the job on time, why buy more? There was even an anecdotal case where an important customer of Krakatoa wanted to buy additional licenses, but before the transaction could be finalized, they told us they got their project finished with the few seats they already had because "Krakatoa renders so fast". Obviously, while a fast product is good for the image of the product, it could be quite detrimental to sales - thankfully, the client still bought those additional licenses so no harm done, but it made us thinking...

What would a company do if its existence depended solely on software sales? Things like limiting the Evaluation version to do a lot less (most of the particle management features of Krakatoa like partitioning, converting particle files between formats, deforming and modifying, importing back into Particle Flow etc. are basically free) or making Krakatoa deliberately slower come to mind. Thankfully, the main reason for Krakatoa's existence is the internal need of our visual effects production for a fast particle renderer. And watching Krakatoa in real-world production proves my point - Krakatoa can be damn slow and we have to do something about it!

So how fast is fast? Some people might answer "real time on the GPU would be good enough". Unfortunately, this is not the right answer. There have been some examples of real time CUDA-accelerated particle rendering in nVidia demos, but this is not where we are going and the reason is the data amounts we deal with. The main objective of Krakatoa is the "fast rendering of vast amounts of particles". In this objective, the second part has higher importance than the first one. With the arrival of 64 bit computing and the increases of installed RAM, our workstations can typically fit around 700 MP (Million Particles, or MegaPoints) in 16 GB of RAM, and we often go there or near. A typical graphics card with 1GB of RAM can handle less than 1/16th of that amount, so we don't care about that approach just yet, although it would be great for fast tests with a fraction of the particle count.

Another thing to keep in mind is that various areas of Krakatoa have different impact on speed - some are as fast as we could make them, some could be made faster, some can become bottlenecks depending on the settings. For example, the loading of particles which also includes the evaluation of materials, maps, deformation modifiers, MagmaFlows and particle culling was sped up in v1.5.0 via multi-threading and is now several times faster than in 1.1.x. The sorting portion has been multi-threaded for years and is probably as fast as it could be. The drawing in the Lighting and the Final Passes of Particle Rendering has remained single-threaded since the first version of Krakatoa and has been measured at around 2 MP/second. Given the increasing number of cores in today's machines, this is an area that could improve a lot! The evaluation and processing of Matte Objects was also sped up in 1.5.0 by simply switching from a raytracer to a rasterizer, but it could also benefit from multi-threading the depth map generation.

Adding a new light adds another sorting pass (already fast) and another drawing pass (not as fast as it could be). The moment you check the Motion Blur option, you ask Krakatoa to draw the Final Pass several times. If the number of samples is 8, Krakatoa has to do 8 times the drawing work and typically scales linearly (it actually takes 8 times longer to draw the particles if you ignore the loading time or render with PCache and LCache enabled). But if you have 8 cores in your workstation and Krakatoa would use them all to speed up the drawing, it would mean that 8 passes motion blur would "cost" as much as one pass right now. Wouldn't that be great?

You betcha! So that's what the next version of Krakatoa will do (and more). And the more particles you throw at it, the better it will scale. On my workstation, the pure drawing speed of 100 million particles comes close to 17.5 MP/second! The generation of a Matte depth map from 100 million polygons, something that is also performed before each motion blur pass, went down from 32 seconds to 4 (8x4=32, you know?). And we are not even half-done yet. Add to that the loading speed up with PRT Volumes already reported in a previous blog and you will see how this new build is shaping up as the fastest Krakatoa you have ever seen. In the same blog I mentioned it might ship as v1.6.0 - that suspicion turned out true and we already started updating the documentation for this upcoming 1.6.0 build which should be expected sometime before Siggraph.

I am quite excited about these improvements which we haven't even passed to the Beta testers yet as they happened in the last 10 days. All this wouldn't have been possible without our relentless production team which not only pushes Krakatoa to places it has never been to yet, but also constantly bitches about how slow it is! Love you guys! :)

So don't panic, we won't make Krakatoa slower just to sell more network render licenses and Deadline seats to run them, or disable more features so you cannot play with it for free. We understand that a faster Krakatoa is easier to love, and a Krakatoa you love is one you would if not buy yourself, then at least suggest to your employer (the guy with the wallet ;))...

Stay tuned!

Sunday, March 21, 2010

Back To Basics - Krakatoa Best Practices For Fast Iterations.

 This morning I received a PM from a CGTalk member with approximately the following content:

...These days I am studying Krakatoa by myself, it is interesting. Now I can generate particles from FumeFX data. To render Particle Flow, I use 800000 particles, but it is very slow to update PF, takes almost 10 minutes or even more, is it normal? Or did I miss some steps..  My PC is a Dell T5500 workstation, 64bit OS. When PF and Krakatoa work together, how can it be made faster? I can't image using millions of particles...my pc would update PF all day long, haha!
For the more advanced users of Krakatoa out there, the following answers might look like deja-vu from the Online Help's Introductory Tutorials and the Studio Daily Introductory Videos posted back in 2007. But I feel it is something that cannot be repeated often enough, and given that nobody ever reads any Help files (I know I don't), a blog post on a site hosted by Google might be more discoverable...

Here is my answer, slightly expanded.

Well, we cannot speed up PFlow, so we generally try to work around these issues. Here are some things one could do to speed up work.

1. Save the particles to PRT sequence once, then render as often as you want.
PFlow is slow at updating to a specific frame because it is history-dependent and has to calculate all preceding frames. So if you have 200 frames of animation and want to render frame 190, you have to wait for all 190 frames to update. But if you have already updated frame 190, getting frame 191 should be relatively fast, and this is true for the saving process too. So you set Krakatoa to save PRTs to disk and let it run (overnight? ). Once it is done, you have traded off time for disk space. Now you have Gigabytes of particle data on disk, but you can render each frame in about a second without any preroll! The Krakatoa PRT Loader also lets you tweak the timing/speed of the playback, cull particles, deform the particles if they don't match your vision, bend the particles to follow a spline path, deform by a skinned mesh to create particles moved by a character animation, create and modify particle data channels using MagmaFlow, duplicate the particles by cloning the PRT Loader multiple times and so on. It is a whole new particle data workflow you have there...

2. Partitioning.
You can expand the above approach with some partitioning (saving out several smaller PRT sequences with varying random seeds to produce a denser final result). So you could for example reduce the particle count to something you can live with time-wise, for example 50K, 100K or 500K particles, and partition only one PRT sequence to check out if you like the motion. You could also use the ability of the Iterative Mode of Krakatoa to render a frame at a fraction of the resolution while preserving the density to get a representative frame from few particles that gives an idea what the same frame with 10 times more particles could look like.

If it looks good after it has finished saving, you can let the computer run multiple additional partitions with the same settings to produce more and more particles using the same FumeFX sim (and/or PFlow setup). This way you don't have to wait for the whole quantity to be processed at once and make more iterations until you like the general motion, then let a copy of Max running in the background save 10 or 20 or 50 sequences of the same setup with different random seeds to combine into one dense sequence with millions of particles within the PRT Loader.

3. Use all your CPUs/Cores.
PFlow is single-threaded, but your machine might have more CPUs sitting idle. You can open several copies of 3ds Max + Krakatoa on your workstation (thankfully, both the 3ds Max and the Krakatoa licenses support that), load the same scene in each one of them and let each one partition a sub-range of the total range of PRT sequences. For example, if you have 4 cores, you can open 4 copies of 3ds Max and let the first one partition from 1 to 3, the next one from 4 to 6, the third one from 7 to 9 and the last one from 10 to 12. After about the same time it would take a single copy of Max to create 3 partitions you will have 12 and all cores will be used. I have done this with 8 cores and it works great, assuming memory is not an issue. Saving particles through Krakatoa does not load particle data into memory, only 3ds Max, FumeFX and PFlow will use memory, so chances are this won't be an issue.

4. Render the FumeFX directly.
Krakatoa lets you render every voxel of a FumeFX simulation as a particle. This does not give you the same look as driving PFlow particles through the simulation grid, but for some effects it can be a lot faster.
The drawbacks: The particles don't have velocity so you cannot apply motion blur and you need a very fine-resolution grid to create enough particles, which of course increases the FumeFX simulation time.

Once you have simulated the FumeFX and you like the look, you can just check the ">FumeFX" button in the Krakatoa Main Controls rollout to enable it as source and render away. But you can also use some techniques to increase the particle density. Save the simulation to a  single PRT sequence, load in a PRT Loader, add a High-Frequency Noise Modifier to the stack as outlined in this tutorial on our site, check the ">PRT Loader Modifiers" option in the Partitioning Rollout and partition the resulting particle system multiple times to increase the density by jittering the particles around their original positions. The result might look a bit noisy though, but it is a possibility.

Finally, you could just render the FumeFX as voxels, which generally requires less particles to produce the same density. Usually you would need to set the Krakatoa Voxel size to the same value as the FumeFX grid size.


These are some of the typical approaches to speed up the iterative process of creating good looking particles and rendering them in Krakatoa. It does not apply solely to FumeFX and Particle Flow - you can combine this knowledge in other situations regardless of the original source of the particles.

Please add your comments below with your own Best Practices. I will migrate this to the FAQ someday.

May your cores be always busy!

Sunday, February 21, 2010

And The Answer Is...

42, of course!

When I started this blog, I promised insight into Krakatoa, MAXScript, Life, The Universe and Everything.
Well, there is no better time for that than this year. 4 days ago I turned 42, and for anyone who holds the Hitch Hiker's Guide To The Galaxy dear to his heart, this age sounds quite cool.

Except it probably isn't.

You see, the other day my parents told me they read or saw an interview with James Cameron and he mentioned he was still feeling like an 8 years old. Oh my, I told them, so I am older than The King Of Pandora!? I have always felt like 16, except when I was actually 16 when I felt like 20. Crazy eh?

Anyway, I don't think I will have more answers about Life, the Universe etc., but I can surely talk about the few things that I know about. For example we are beta-testing Krakatoa v1.5.2, so I might mention some things about it.

Probably the coolest thing that happened to this version (quite by accident) was the speed up that it provides to PRT Volume particle generation. We were working on something completely different (which won't be in 1.5.2, but I guess you will all get sooner than later) and discovered that our memory management wasn't working as expected. Normally, when loading particles from most sources like PFlow, TP, PRT sequences, Mesh Vertices etc., Krakatoa not only gets the particles, but it gets the actual particle count long before it has loaded a single particle. All these sources are able to tell Krakatoa "I am going to give you N particles" and Krakatoa can collect these numbers and reserve memory for all of them before it starts loading their data. (This is the case in the 64 bit build, in 32 bit half of the time it might not be able to allocate enough to fit them all in... Switch to 64 bit if you haven't yet!)

There are a couple exceptions to this - CSV files do not provide even a hint about the actual particle count of the incoming particles - the only way to find out would be to actually read them all, and since reading text files is slow enough, we just do it once and allocate memory as we go. Currently, the same applies to PRT Volumes. The PRT Volume could theoretically estimate the final count based on the mesh, voxel size etc., but it is a bit complicated with all the Shell options and testing against the mesh volume, so right now it does not report any expected count to Krakatoa.

The result of loading PRT Volumes in v1.5.0 and 1.5.1 was exponential slowdown as the particle count went up. We realized that this was due to many (and slow) memory allocations and decided to allow the user to allocate enough memory for a given amount of particles via some manual controls in these cases where Krakatoa does not know the final count. The result was quite mind-blowing. Creating 50 million particles with a PRT Volume went from 11+ minutes down to 17.5 seconds which is 38 times faster. When I reported this to our boss, he asked jokingly "Why not 40x?". So I tested 100MP and that was 92 times faster, so I guess everybody should be happy now. After closer inspection we realized that the memory allocation logic in the previous versions had some flaws, so we are working on fixing them in hopes to be able to get the same speedup without manual memory allocation controls.



Another quite positive development that has been on my Wishlist for a while is the addition of a Particle Input Stream. This allows anyone with basic MAXScript knowledge to open the render-time particle stream of a PRT Loader or PRT Volume and read particle data from it. For those of us with advanced MAXScript knowlegde, it meant the introduction of the Krakatoa Particle Data Viewer utility which can be used to peek into the particle data of a scene object. It lets you select a range of data to display, filter that data by any combination of search criteria, even filter by the value of the Selection channel which could be set by a KCM, thus allowing for filtering by arbitrary MagmaFlow logic! Finally, selecting one or more rows in the editor will highlight the corresponding particles in the viewport!

In MagmaFlow, we added Quaternion operators, the missing and quite important Natural Logarithm operator and fixed some bugs in the handling of nested BlackOps. Flows will now save a material library with any maps used by TextureMap Input nodes and will load them back when loading the flow. TextureMap Inputs can now show a preview of the selected map inside the MagmaFlow command panel. Connections to scene object will be restored when loading the flow if a scene object with the same name exists. Object references using the $ path syntax inside Script Input nodes are now supported for interactive updates. We have some more quite sexy operators in the works, but they might have to wait for the next major release, so I will stop here.
Related to KCMs, we are introducing two new MacroScripts - one for saving a modifier stack to disk, one for loading it from disk. This lets you create a whole bunch of related (or not so related) KCMs on an object, save them to disk together with any other modifiers found on the stack like deformers, Krakatoa Skin Wrap etc, then select one or more objects in the same or in a completely different scene and apply the same modifiers to them.

For the few people using the Presets and History dialog (according to our surveys, most users are confused by it, but I am unsure how to improve it, so I am open to suggestions!), we added two vertical icon strips for faster browsing of records by image. You can now just scroll the image strips and load presets or browse thumbnails, saved preview images or settings much more intuitively.

If you read my blogs, you probably remember my rant about how people don't use the MacroScripts with those colorful incons we provided? Well, we not only replaced the icons with slightly better ones, we also added a Krakatoa menu to the Main Menu bar of 3ds Max (which can be turned off in Preferences) so you can now access all tools and settings from there without having to customize a toolbar.

Initially, we wanted v1.5.2 to be a pure bug fix release, so we squashed a whole lot of bugs - you can read their obituaries here. At this point, we are in the same situation as with 1.5.0 which could have been called 2.0.0 without any problem - 1.5.2 could easily be called 1.6.0 since it brings quite a few new features too.

As mentioned, Krakatoa 1.5.2 is currently in Beta. If you have a commercial license and you want to test it but have no access to the Beta forum, let us know. If you don't have a license, you will have to wait a few more weeks...

Sunday, January 3, 2010

A Krakatoa Year In Retrospection

Here we are, finally in 2010 - we had 3ds Max 2010 for almost a year now so I am quite used to the number already. The past 2009 was a Good Year for Krakatoa customers (at least I hope so) due to the release of v1.5 and all that came with it.
Our company worked under the name Frantic Films VFX on a movie hopefully nobody saw, on another one under the name Prime Focus VFX that many people saw, on a third one that nearly every teenage girl saw and on the movie everybody seems to have seen at least three times since it just made a billion today. And all four of them used Krakatoa in their production. There was a fifth movie that had tons of Krakatoa in it, but it is still not released so I cannot talk about it, and after Avatar it is difficult to be excited about other movies anyway :)

So the beginning of the year found us developing Dragonball:Evolution and G.I.Joe at the same time, the former handled mostly in Winnipeg with animation done in Vancouver, and the latter done mostly in L.A. with animation coming from Vancouver and some effects done in Winnipeg. From RnD point of view, the two movies had some parallels - in DB:E, we had to grow objects using particles, in G.I.Joe we had to destroy them. While the actual implementation of the effects in production ended up quite different, the research process showed that the two tasks can be seen as complementary.
For example, some early tests called for the building of an exo-skeleton from particles drawn from the environments (dust, rocks etc.). Now if you try to use PFlow's Find Target to land particles on a moving surface, it is not impossible, but quite hard to control correctly. Whereas Thinking Particles uses an approach where the user control over a moving particle is gradually stripped away, forcing the particle to go to an exact location, PFlow just uses forces to try to get there even if the point is constantly escaping. If you look at the history of special effects in movies, shooting the action in reverse and playing it backwards has been one of the earliest and most amazing tricks of cinema. With the ability of the Krakatoa PRT Loader to easily control the flow of time using the Playback Graph parameter, simulating the EMISSION of particles from a surface together with complex forces and playing back the resulting PRT sequence to produce the build up of particles on the surface is quite easy. Try it out some time!

The production of the Nanomite effects for G.I.Joe involved two companies (Prime Focus VFX and Digital Domain) using vastly different rendering approaches to create the same look. In the end, particle (point) rendering and voxel rendering looked quite similar - at that point in time, production was locked to a build of Krakatoa that did not have Voxel Rendering yet, and I guess we wouldn't have used it even if it worked already. Assuming that a cloud of metal-eating miniature robots would produce some reflections, we added Environment Reflection Mapping support to Krakatoa, but ended up not using it for the movie. So the end users of the 1.5 commercial release benefited from this development. For a while, there was also support for Anisotropic Specular Highlights in the beta builds, but it just wasn't done right and we decided to pull it out of the shipping product. It might return someday in a better shape. If you haven't seen the "Particles In The Zoo" video by Matthias Müller, you should go watch it now - he used the Environment Reflections ability of Krakatoa to great effect, especially on the "scales" objects.

Then we had the real blockbusters - Twilight:New Moon and of course AVATAR. (I think Blogger.com should add support for the Papyrus font so we can write the name as JC intended) ;)

For the New Moon movie, Prime Focus employed Krakatoa for the "apparition effect", as well as for the foam on the wave that hits Bella. Both effects can be seen in the official trailer (at 1:10 and 1:03 respectively). Not being a teenage girl, I haven't seen the movie yet, but will probably rent it on Blu-Ray when it comes out. In the look development / RnD phase, I also tried to use Krakatoa's new Voxel Rendering for the "diamond skin" effect, but we ended up using an alternative approach based on V-Ray. The Krakatoa effect looked quite promising though and I am sure the knowledge gathered from those tests will end up somewhere else.

Strangely enough, my involvement with Avatar was mostly unrelated to Krakatoa - like with G.I.Joe, I worked on pipeline tools to speed up the production workflow. For G.I.Joe, we used a prototype of an assembly system where all assets were separated and combined only at render time, without using an actual MAX file to hold the scene. The scene was assembled on the fly for editing or rendering, then the changes were saved back to new versions of the asset files in their original locations on the network, and any change to an asset would propagate automatically throughout the sequence. No XRefs involved!
In the case of Avatar, James Cameron insisted on absolute continuity of the animation sequences shown on the 3D screens in the Bio Lab and the Ops center. So we ended up developing a database application (called SAGI = Screen Art Graphic Interface) that would keep track of shot lengths and what is seen on which screen. The 2D artists working on the screen graphics could use a User Interface to this database to enter their latest versions and request a 3D rendering of all screens affected by their entry. The SAGI application would write a control file and "drop" it into a folder monitored by the other part of the system called ASAR (short for Automatic Screen Art Rendering). ASAR was written in MAXScript and was running on a Deadline Slave as a never ending MAXScript job, checking the drop folder for SAGI request files periodically. When it would find a file, it would process it by loading the 3D assets, applying the right timing of the right textures for the Left and Right eye and submitting all necessary passes as new Deadline jobs. This made a human error in the assembly and rendering phase impossible and allowed 2D artists to trigger 3D rendering jobs without any knowledge of 3ds Max or Deadline. But most importantly, it allowed us to change the length of shots and preserve the visual continuity of the screen contents between shots without much human intervention. (You can read the official Press Release here).
That does not mean that Krakatoa wasn't involved in the making of the movie. It helped give the "holotable" terrain its distinctive LIDAR look and was seen on the "false color images" screens showing the energy flow at the Tree Of Souls. (seen below before and after)

Apropos LIDAR - about a year before I joined the company, some shots for X-Men 2 also involved a "holotable" graphics display. It is amazing how these kinds of jobs come around again and again (along with crystal growth and particle disintegration).


Another curious fact about X-Men 2 and Avatar - the former happens to be the movie with the highest Tomatometer rating Frantic/Prime Focus has ever worked on. The latter appears to be the one with the highest financial success. Reading Box Office Mojo daily makes me feel great, especially after all the online negativity before its release.

Outside of the world of VFX, the past year was marked by some of the best concerts in my life, led by the Winnipeg performance of Leonard Cohen, followed not-so-closely by AC/DC and KISS and farther behind by Metallica. (the above sentence should give you an idea of the approximate range of my musical taste). The year also included the worst concert I have been to, unfortunately by an artist I generally love, thus the disappointment was even bigger, but I won't discuss this further. It also saw my AI favorite losing the title despite performances like this, this and this (yes, I am a Glambert!) but producing an amazing album and getting to do this.

Just before the end of the year, me and my wife got to see Chaplin's movie "City Lights" with music peformed live by the Winnipeg Symphony Orchestra. Despite being in black and white and having an almost square aspect ratio, it was possibly the second best movie experience I had this year, right behind Avatar (which was in color, wide screen and 3D, of course)...

So on to a new year with lots of changes for me on the horizon and hopefully with more amazing music and a 2.0 version of Krakatoa on the market!

Happy New Year everyone!

Saturday, November 21, 2009

"Grainy, like a Krakatoa render..."

As you could imagine, I spend a little time googling "krakatoa particles" and "krakatoa render" about once a week to find out what people are doing with it and what they are talking about on various forums.
A couple of weeks ago I discovered the following (rather old) thread on the SideEffects forums related to a Houdini rendering which was described, as the title of this blog says, as "pretty grainy, like a Krakatoa render".
I guess this is a good cause for a new blog.

I must say the actual animation shown in the thread wasn't that grainy, but I am more concerned about the public image of Krakatoa. I suspect the assumption that Krakatoa has a particular look is caused by the huge amount of animations on YouTube that simply have the wrong settings.

Of course, in some cases Krakatoa is being used to produce sand or pieces of solid objects flying around. In such cases making each particle distinguishable as a dot can be desirable. In fact, the Nanomites in G.I.Joe were also rather grainy, but it was the look that was requested.

When using Krakatoa to create effects like Ink in Water or Wispy Smoke though, the rule of thumb is - if you can see a particle as a particle, your Density is too high! The main idea behind Krakatoa (even before it was called Krakatoa) was to take several hundred million particles and draw them together into the image buffer with very low density per particle to accumulate a SMOOTH final result - in the movie "Stay" where our particle rendering was first used (inspired by Doc. Baily's Spore rendering), the effect looked like glowing plasma. In the movie Cursed, we actually used FLOOD to drive millions of particles through a simulation and rendered them in the same renderer to get the Wispy Smoke seen in this PDF.

The recent "Ink" animation created by weareflink for the CCTV shows a pretty good use of Krakatoa simulating ink in water without being able to distinguish single particles. Also, the Vilnius SPA animation by DekoLT is a great example of high density but enough particles to create solid-looking clouds.

Another factor that can cause a lot of grain in the rendering esp. of solid-looking clouds is the Light Pass Density. As you probably know, Krakatoa lets you decouple the density of particles as seen by the lights from the density used by the camera to draw the particles. High density in the Lighting Pass with very high particle counts can produce self-shadowing of particles at the very surface of the cloud because the outer-most layer of particles would "eat up" all the light and the very next particle layer below them would appear very dark as opposed to the very bright lit ones. This can produce not only grain but even very undesired moire effects.

Reducing the Light Density a bit and letting more light penetrate the volume (also resulting in a sweet sub-surface scattering effect) usually solves this problem.


So please, if you are rendering in Krakatoa, make sure you crank up the particle count AND lower the Density until you get a smooth result, then play with the balance of the Lighting Pass vs. Final Pass Density to get the correct amount of light penetration and pixel coverage...


EDIT: You can find some illustrations on this new documentation page.

Have a smooth rendering! ;)

Sunday, October 25, 2009

Krakatoa 1.5 - Confusing Changes For The Better

Once again, while most of this is already covered in the online documentation, I feel that spelling it out for the few people reading my blog might be a Very Good Idea. I will probably have to update the FAQ or just link to this Blog or something like that.

First, the default lights handling.
When designing Krakatoa 1.0.0, we discovered that particle rendering with default scene lights never looked good. This was mainly because the default mode for default lights in Max is a "headlight" right behind the camera, which does not produce very good looking shadows. The alternative mode is two lights which works even worse with volumetric rendering, and requires one more light sorting/attenuation map generation pass...
So we made the decision back then to render particles as self-illuminated if no actual light node was detected in the scene. As result, one could just create some particles, hit render and get an idea where the particles were. On top of that, it worked great with Additive Mode where lighting was usually not desired (although Additive Mode + Lighting was somewhat supported).

When the Krakatoa version which ended up being released as 1.5.0 (it was initially developed as 1.2.0 and nearly shipped as 2.0.0 due to the amount of features added, but that's another story) added support for an Emission channel and an Absorption channel in addition to the Color (Scattering) channel, we had to revise this design decision. In short, having a per-particle Emission channel meant that it would be a Very Bad Idea to render particles as fully self-illuminated when no lights are found in the scene. At the same time, rendering Default Lighting was still as unusable as it was two years earlier - we looked into it again and finally decided to bite the bullet and render particles as not illuminated if there are no explicit lights in the scene.

What does this mean? In short, if you open a Krakatoa 1.1.x scene without scene lights in Krakatoa 1.5.x or just start a new Max scene, add some particles and hit render, you get... nothing. Or so it seems. Looking at the Alpha channel, the particles are there (and the log / progress dialog show that they are actually being loaded and processed). It is just that self-illumination is not applied implicitly, no scene lighting is applied either and you end up with black particles on black background (changing the background color to a brighter color shows that, too).

As you can imagine, this is one of the main problems new users of 1.5.x encounter and report on the forums and in support emails. The possible solutions are
  • Check >Override Emission and >Use checkbuttons in the Global Render Values rollout (or alternatively check >Use Emission and >Override Emission in the Main Controls rollout). The default Emission Override color is set to white, so your particles will render as white by default.
  • You can also add a Map to the Color Override in the Global Render Values if you want more interesting results.
  • If you want to emulate somewhat the Krakatoa 1.1.x behavior where each particle renders the Color as Self-Illumination, you could also add a Global Channels Override KCM and set it to Color Input>Emission Output, then check ">Use Emission" without enabling the >Emission Override option - this will copy the Color of the particle into its Emission channel. PRT Loaders and PRT Volumes will render in their actual color.
  • Alternatively, adding a Vertex Color Map to the Emission Override slot will render the Color channel and put it into the Emission channel, but this approach is generally slower compared to using a Global KCM.
  • You could of course also create a Light in the scene to illuminate the particles, but this will cause longer render times due to the illumination pass when rendering in Particle Mode.
While I admit that this seems like a step backwards, the ability to specify Emission per particle means more flexibility (as we will see later). Flipping two checkboxes or creating a light shouldn't be a big price to pay...

The second large change made to the main controls of Krakatoa was the replacement of the big >USE LIGHTING button with a much smaller >Ignore Scene Lights button. We wanted the lighting mode to be the default state of the UI and the underlying renderer, not a special mode one would have to activate. In light of (pun intended) the above discussion about emission and default / scene lights, this was the only logical way to go. On top of that, the >Ignore Scene Lights option does not switch the renderer into a different mode, it simply assumes any existing scene lights are actually turned off. (you could do that with the Light Lister, but it would be a PITA). At a certain point in the development, that option was nearly removed from the system, but it was deemed necessary to quickly produce Self-Illuminated particles using the Emission channel without taking scene lights into account.

And here we come to the third major change - Additve Rendering in Krakatoa v1.1.x used to be a distinct rendering state as opposed to Volumetric Rendering. But Krakatoa v1.5.0 implemented the full volumetric shading equation with Scattering (Color), Absorption and Emission terms, making it possible to control how much color is scattered into the eye, how much is absorbed from each color component as light passes through the particles and how much light is emitted by the particles. Additive rendering is simply fully Emissive rendering lacking Scattering and Absorption, which means that now we can define PER PARTICLE whether it should be rendered volumetrically or additively (or somewhere in between).
You can find more info here.

Knowing that our users will still want to be able to render particles additively without much clicking around the UI (Krakatoa has been doing additive rendering long before it even had that name, since around 2004), we decided to add a special option called  >Force Additive Mode. What this option does is this: it copies the Color channel into the Emission channel, while setting both Color and Absorption to black. Thus, particles do not absorb light, do not scatter any light into the eye, they just emit light and accumulate into the pixels as desired. To illustrate what is going on, the >Use Emission and >Use Absorption options are getting grayed out in that mode. In this case, scene lights are also ignored completely even if >Ignore Scene Lights is not checked - particles with black Color and Absorption would produce no lighting effects at all, while wasting time sorting for attenuation map drawing that would not be used anyway...

As you can see, we wanted to make Krakatoa a lot more flexible by providing per-particle channels for the main shading values, but this required some changes to be made to both the default behavior of the renderer and to the controls in its User Interface.


Understanding the processes going on inside the renderer and the logic behind these changes should help you master the new version and lose your old habits built in the less advanced environment of Krakatoa 1.1.x.

I have the feeling I will continue this post in the near future with some more notes on feature and UI changes, so stay tuned!...