Ok I will try to create a simple example that I could send you. and try to see what’s the real problem once and for all.
And thanks kagemaru for talking about nan (not a value) pixels. I didn’t know this word! and if I hover on top of those white pixels I am getting a nan for the blue value. And where I have full white frame all rgb and a are giving nan value. Googling this word also brings me lots of clues. I will dig into those a bit.
I found a nice free plugin calle NANny for after effects to help deal with NAN pixels. When I use it on this comp (on my final output precomp) most of my frame looks a lot better and I have no white frame anymore. BUT the plugin only replace all the nan pixels by a single color that we must choose manually. So if there are too many nan pixels, we still see artifacts in the final image. I will try to apply it instead to the culprit layer.
NaNny
Plug-in for After Effects
by Brendan Bolles
version 0.5
April 6, 2011
Summary
=======
NaNny is an AE plug-in to help you deal with floating point pixel values “NaN” and “inf”. These can cause all kinds of problems with image processing and should be eliminated. NaNny will replace them with the floating point values of your choice.
Usage
=====
If you suspect you have a NaN or inf in your image, apply NaNny to it. (Your project must be in 32-bit mode.) The NaN, inf, and -inf values will be replaced by the values in the sliders. Everything else will remain unchanged.
If you want help locating the offending pixels, you can switch NaNny to Diagnostic mode, which will make a mask with good pixels black and the bad ones white. It will also show a message in the Info palette telling you how many bad pixels it found.
If you want to experiment with this problem, I’ve included the file NaN_inf.exr for you to play with. Try applying a blur to it without NaNny and see what happens. Remember, you have to be in 32-bit mode.
Background
==========
The world of floating place is a strange place, much stranger than the 8- and 16-bit pixel formats After Effects supported prior to version 7. With those, every pixel was in the range 0-255 (0-32768 for 16-bit). You had black and white and everything in between. Easy.
In 32-bit floating point mode, those ranges translate into 0.0-1.0. But then you can also have values of 1.5 or 15.0 or 15000.0. Those are just brighter than white and behave as you’d expect, and are even very useful. No problem there.
But float pixels can also have negative values like -0.5. They will appear black on screen, but will have strange properties, like darkening something when Added to it. Or if you want to brighten them up using Exposure, that will cause them to become even darker (more negative). Weird. Unless you have a good reason, you probably don’t want negative pixels.
Then there are the strangest possible float values, which don’t even look like numbers at all. They are called “NaN” and “inf”.
NaN stands for “Not a Number” and is basically an undefined value. Sort of like the value of a pixel being “pepperoni,” which throws the Hard Light transfer mode for quite a loop. NaN is similar to “undefined” in math. For example dividing zero by zero in math (0/0) is undefined and a computer will typically return NaN as a result. Wikipedia has a good article about this:
NaN - Wikipedia
inf stands for infinity, which you typically get in math if you divide something by zero. So 1/0 would give you inf. Or -1/0 gives -inf. This is maybe not quite as weird as NaN, but still weird.
When a NaN or inf pixel finds it’s way into an operation, the result is usually another NaN or inf. NaN - 1 = NaN. So if you have one little NaN pixel in your image and then blur it, any pixel that sampled the NaN will get corrupted. Like a black hole from which no operation can escape.
After Effects takes measures to prevent inf and NaN from being created, even in cases where mathematically they should. If you have one of them, it probably came from a file rendered in a 3D program. Probably the first thing you should do is write the makers of that renderer an angry e-mail and include a sample project. NaN and inf might make occur in floating point math, but they don’t make any sense appearing in a rendering of the world. It’s a bug and they should fix it.
But until all software everywhere is 100% bug free, we’ll need a way to deal with NaN and inf.
Negative Pixels
===============
NaNny doesn’t do anything about negative pixels, but you’ll probably want to get rid of them if you have any. The easiest way to clamp them in AE is to apply Levels and switch Clip to Output Black to On.
When Levels’ Input Black matches Output Black and Input White matches Output White, it generally doesn’t change any pixels. But turn on clipping and it will clamp to whatever you set. So Levels is a good clamp tool.
Color space transforms are often to blame for the appearance of negative values. If an image comes from a color space with a wide gamut and then you drop it into a more narrow one, you can have some pixels that are super-saturated and one of the channels turns negative. For example, if red is {1.0, 0.0, 0.0}, a super-saturated red might be {1.0, -0.2, -0.2}. If you clamp the negatives in that case, the appearance could actually change, especially if you’re writing out to the wider color space. But if you don’t clamp them, you might get the weird negative behaviors. Tricky.
The best thing to do is avoid this situation. Set your project working space to one wide enough to hold any images you’re working with. Ideally your images will all be in that same color space so no color space transforms are involved at all. (Except of course you want your Working Space to be linear.)
NaN_inf.exr
===========
This is a sample EXR file (16-bit float) containing NaN, inf, and -inf pixels. Some versions of After Effects don’t sample these properly in the Info window unless the offending pixel is all by itself. Each word has a solo pixel floating below it for this purpose but trust me, the words are filled with the pixel values specified. You can play with NaNny’s output values to verify this.