Jump to content
Hash, Inc. - Animation:Master

Better Anti-Aliasing WITHOUT the wait !!


Guest Greg

Recommended Posts

Hi guys,

 

This is just an application of some fundamental image-processing theory to A:M

 

The attached images where rendered in about the same time, even though one obviously has better anti-aliasing then the other.

 

Contrary to popular belief, anti-aliasing is an objective measurement; NOT subjective. By performing a Histogram of your renders, the number of steps that appears in a histogram determines OBJECTIVELY how well you are anti-aliasing.

 

This histogram analysis is only valid in pure color images (like the given example) and edge boundaries must be sharp (meaning no blurred edges).

 

In A:M when you set your Blur to 0 . . . you are forcing A:M to use true weighted circular area sampling, in contrast to non-weighted (i.e. box filtering) of a pixel.

 

In box filtering, the renderer simply takes an average of the sub-pixel data that is covered by the pixel's boundaries. BTW, this is NOT what nature does in anything that sees light (like your eyes, film, CCD, etc.)

 

In weighted circular sampling, the renderer weights the sub-pixel information that is closer to the center of the pixel, higher then the pixel's boundaries. What that means is if you had something that's 1/4 the width of a pixel and is 100% white, if it was in the middle of the pixel it would have a greater contribution to the intensity of the pixel, then if it was closer to the edges of the pixel. Also in this sampling technique, a pixel is considered to be a circle and NOT a square. This is EXACTLY what nature does in EVERYTHING that sees light (like your eyes, film, CCD, etc. )

 

Finally setting the Gamma to 1.8 (Monitor) forces A:M to consider the TRUE brightness of a pixel. What that means is, most people think that when you set a pixel value to be 50% the resulting pixel will be 1/2 as bright as 100% . . . That is NOT True. Your monitor has a Gamma response curve. If you've used photoshop you probably know a little about this gamma stuff.

 

If all this stuff is Greek to you, just use the settings I mentioned in your renders to see the difference for yourself.

 

Also, if you think this looks good in a still, you should see it in MOTION.

 

take care, and I hope you like this example,

 

Greg Rostami

post-7-1078743419.jpg

Link to comment
Share on other sites

  • Replies 28
  • Created
  • Last Reply

Top Posters In This Topic

I think we need a new forum: "Greg Rostami's Cool Tips."

 

I assume this also applies when using non-multipass? Or is the a-buffer renderer already good enough at antialiasing?

 

Zach

Link to comment
Share on other sites

Well... dang. That's amazing. You ought to post this in the main forum, so those people who only read the mailing list can see it too.

 

Does this work in non-multipass mode as well? (I'm currently rendering an animation, or I'd try it myself.) Maybe these effects should be added to the default choreography setup, so that even the greenest newbie benefits from the technique right out of the box...

Link to comment
Share on other sites

  • Admin

I wish my brain could absorb what you just typed but it's gonna have to sleep on it first. My brain can comprehend the results of your picture though and it responds...

 

Wow... I need to use that technique.

 

Excellent work (as always) Greg!

Link to comment
Share on other sites

Hey Greg, I was wandering what the dither part does?

 

Also, although I am not sure if I am quialified to pick you up on this, isn't box sampling the way to go when you have square pixels? I know that the rods and cones in our eyes are round but pixels are square so should have square sampling. Am I just confused here or what?

 

It has to be said though, there is no doubting the effectiveness of the technique.

Link to comment
Share on other sites

  • Hash Fellow

Looks great!

 

I'm wondering... since this seems to get so much better results and doesn't seem to incur a major time penalty, is there any reason not to make this the default when multi-pass rendering is selected? Or are there drawbacks to this method in common situations?

 

I realize it's a simple "post effect" now, but next time some reviewer does an out-of-the-box comparison of 3D apps, wouldn't we want him to get the best the best possible results?

Link to comment
Share on other sites

I'm wondering... since this seems to get so much better results and doesn't seem to incur a major time penalty, is there any reason not to make this the default when multi-pass rendering is selected? Or are there drawbacks to this method in common situations?

 

I realize it's a simple "post effect" now, but next time some reviewer does an out-of-the-box comparison of 3D apps, wouldn't we want him to get the best the best possible results?

Note that the choice of color in the demo was purposely selected to make the aliasing pop out to the eye. Green beside red will always produce a stong ON-center/OFF-surround response on the retina and make the contrast appear much stronger than it actually is because both colors excite different types of receptors. A thin strip of green surrounded by red wil appear white and a thin strip of red surrounded by green will appear black. This is the same phenomenon as the famous Mach banding and even more exagerated. If you use less chromatically contrasting color, I think you will have much less griefs against the AA result. To see what I mean, zoom on the pictures to 1600%.

 

The demo was not designed to point out deficiencies in the multipass renderer but rather to show what can be done with post effects. By adding a blur pass on this render, it blurs the chromatic contrast edges between the red and green pixels and the eye can respond better. The exact same principle applies to normal AA although in normal situations, this AA artifact would be much less noticeable.

 

This is a very good tip because it can reduce the aliasing artifact considerably without incurring longer render times. In most situations, especially in animation, this would be perfectly suitable. But it produces blurred images and thus, some details could disapear or get considerably faded away.

 

So because of that, making a blurred render the default render would not be a good idea. A hypothetical reviewer might consider the default blurred render not crisp or sharp enough. And in this case, even trying to increase the number of passes would not help for him.

Link to comment
Share on other sites

Hi Guys,

 

Let me answer the questions in the order they came in:

 

 

I assume this also applies when using non-multipass? Or is the a-buffer renderer already good enough at antialiasing?
Zach, both dithering and gamma correction applies to the A-Buffer Renderer. The weighted circular area sampling (Blur=0) only applies to multi-pass rendering where sub-pixel samples of neighboring pixels are more readily available.

 

 

Maybe these effects should be added to the default choreography setup, so that even the greenest newbie benefits from the technique right out of the box...

 

Godfrey, Steve Sappington told me this morning that the default multi-pass render icon should have the Blur=0 setting already applied. If you choose advanced render settings, then you don't get this by default. BTW . . . on the current version, this default feature is not working, but stay tunned . . .

 

 

I was wandering what the dither part does?  Also, although I am not sure if I am quialified to pick you up on this, isn't box sampling the way to go when you have square pixels? I know that the rods and cones in our eyes are round but pixels are square so should have square sampling. Am I just confused here or what?
The dither post effect uses AMs extra bits of precision to apply image dithering on the output 8bit per channel images. Dithering is VERY important in eliminating mach banding artifacts in your renders. If you've used photoshop's gradient tool you know how important that dither flag can be in producing smooth gradients.

 

I'll answer your question about box vs. circular filtering in a sec.

 

 

 

Thanks for the reminder Pleavens.

 

 

Note that the choice of color in the demo was purposely selected to make the aliasing pop out to the eye.
Well actually I chose these colors because purple against green is THE classic example of BAD GAMMA correction. Even if you don't use Blur=0 and only use Gamma=1.8 you will get perfect anti-aliasing of green into purple.

But it produces blurred images and thus, some details could disapear or get considerably faded away.

Actually, weighted circular area sampling produces MORE detail of images in Animation. Here is why:

 

Imagine a small white square that is 1/4 the size of a pixel moving slowly through a pixel. In weighted area sampling as this square moves within the sub-pixel region, it is slowly brightening the neighboring pixels. This fact communicates to the eye that there is this small detail moving within the pixel. That is enhanced spatial resolution.

 

In contrast, in box-filtering as this little white square moves slowly through a pixel, the value of the pixel (and the neighboring pixels) will ALWAYS be the same (1/16 white). There is NO data indicating which direction this little white square is moving within that pixel.

 

Weighted area sampling is exactly like using bi-cubic interpolation when you down-res an image in Photoshop. Try down-resing an image using both bi-cubic(weighted filter) and bi-linear (box filter) in PS. You will notice that the bi-cubic image might seem a little more blurry then the bi-linear one. But bi-cubic filtering is producing the correct pixel values for a smooth natural look that lacks aliasing artifacts.

 

Here are some links to the above ideas:

http://www.cs.sfu.ca/~torsten/Teaching/Cmp...Alias/#unweight

http://www.cs.sfu.ca/~torsten/Teaching/Cmp...tiAlias/#weight

 

I hope all this tech stuff answers some of your questions.

 

Peace,

Greg Rostami

Link to comment
Share on other sites

Greg,

 

I understand and agree with all your explanation concerning the application of the weighted circular area sampling. Really, I have nothing to add to that. It is a good idea and given the way it is implemented, I would actually recommend it when set to 0.

 

But I disagree on the gamma argument. I'd be very interested in reading a reference which explains why red-green is a good example of gamma misadjustment. If it is a good example of something it is of how the organization of the eye photoreceptors responds to light and color.

 

The eye perceives color through specialized photoreceptors. Some are more receptive to some wavelength.

cones_color_graph2.gif

The chromatic information from the red and green cones are carried to the brain through one channel which actually represents the difference between red and green ( green minus red). There is also a similar combination between blue and yellow. If you use both pure colors side by side, you exite exclusively the red cones on one side and the green cones on the other side. When you excite only one type of cone, in a large region of the retina, lets say the red cones, they will actively inhibit the response of the neighboring green cones. In neurobiology, this is called ON-center/OFF-surround response. This is the natural way to work for all neurons organized as maps. Because the Red and Green are carried as differences and oponent cones are inhibited, green next to red appear much lighter and red next to green appear much darker.

 

This is, of course a very short explanation.

Here is a point form document explaining this.

And here is a more complete explanation (although a scientific one).

 

The main reason why gamma correction reduces the impression of aliasing with red-green is because it reduces the purity of intermediate colors and thus reducing the inhibition phenomenon.

 

Gamma correction is not an absolute cure for bad aliasing because it is monitor dependent. In other words, if you gamma correct an image on one computer and display it on another computer, it will look different. For this reason, unless you are absolutely sure that the image will be viewed exclusively on one single computer, gamma correction should be performed at display time. Not at render time. The traditional example is to gamma correct an image on a Mac and view it on a PC and vice-versa. For this reason, I don't recommend to do gamma adjustment as post processing in A:M unless you know axactly why you are doing it and are looking for some particular effect which Gamma correction kind of simulate. For instance, My monitor is already correctly gamma corrected and when I apply the 1.8 gamma correction as post processing, I actually get worse aliasing.

 

A simple way to determine the current gamma setting of you monitor is this.

Link to comment
Share on other sites

  • Hash Fellow
For instance, My monitor is already correctly gamma corrected and when I apply the 1.8 gamma correction as post processing, I actually get worse aliasing.

 

A simple way to determine the current gamma setting of you monitor is this.

 

When you say your monitor is gamma corrected, is that an actual hardware setting on the monitor or a control panel processing the signal sent to the monitor?

 

My Dell trinitron really doesn't have a hardware gamma setting and the only software gamma manipulation I've found is in Photoshop's gamma setup utility.

 

Monitor setup is something that has always puzzled me. For example, if I follow PS's gamma setup utility I end up with a gamma result of around 2.8 according to the chart above. :o Which is neither the 1.8 we seem to be basing the discussion above on or 2.2 which PS says to be the "Windows standard"

 

Is there a really good article anywhere on setting up a monitor properly for both gamma and color temp? I feel like I'm often applying corrections to negate corrections made somewhere else in the pipeline.

Link to comment
Share on other sites

Wow! There's more brain in this thread than you can shake a stick at.

Where do you guys learn about this stuff? Are there classes, or landmark books? Or just magi that pass their secrets through the ages?

Seriously, it's very interesting. And as a digital artist of some flavor, I feel like I should know how my technical tool operates.

Link to comment
Share on other sites

Monitor calibration is really a tough thing. Gamma calibration is only but one part of it. If you are also relying on your monitor to produce printed outputs, then you also need to control the lighting in your work environment.

 

As for gamma correction, My monitor is a Dell 19" Trinitron which is already quite well gamma corrected. My graphic card have a hardware gamma correction. I have three different gamma corrections saved on it. One is the one I normally use. It is set to 1.05. This gives me an equivalent gamma of 2.2. Then I have another gamma correction which I use when I work on graphics that are designed to be displayed on a Mac. This gamma correction is set to 1.55. And then I have another one, designed to simulate normal uncorrected PC monitors. This one is set to 0.7 but it is empirically set because by definition, an uncorrected PC monitor have an unpredictable gamma.

 

As a comparison, I have another 21' Hitachi Accuvue monitor which is normally so dark that its normal gamma adjustment is 2.6. I have to add a 1.4 correction in order to get a comfortable 2.2. And the colors are not well balanced at all so I use it on a development computer

 

A good place to get information about gamma correction would be http://www.cgsd.com/papers/gamma_intro.html

 

Of course, once you adjusted your monitor, either with a hardware monitor gamma, a videocard gamma or a control pannel gamma corrector such as Adobe Gamma, you should turn OFF the gamma correction in Photoshop.

Link to comment
Share on other sites

I've discussed gamma correction at length with Greg. And we agreed on the fact that gamma correction is a tool. It is not a panacea. It should be used with proper knowledge. Otherwise, it is probably better to not use it at all. At least not during render time.

 

Greg have devised a very clever way to drive the idea of the usefullness of the post processing tools available in A:M. By selecting two opposing colors, the intermediate antialiasing colors slowly shift from one color to neutral gray to the other color. This further enhance the effect of the gamma correction. without gamma correction, the intermediate gray color appear darker than the two saturated colors. In this instance, a gamma correction will considerably attenuate this contrasting effect.

 

We also agreed to pass the information that gamma correction as a post process should be used on a per project basis. The 1.8 correction value is fine for this example but could be too strong for another project with another set of colors.

 

And before deciding on a gamma correction as a post processing step, you should make sure that your own monitor setup is well gamma corrected. Otherwise, you are in a very ill position to judge the actual effect of the gamma correction you are applying.

 

Gamma correction is a monitor thing. You need different gamma correction on different monitors. One problem with gamma correction is that there are no standarsd to agree to. Some computer have well corrected gamma while other don't have any. So let's say I post here an image which I already added a 1.8 gamma correction. If you are lucky and your monitor is already similar to mine, and you do no further gamma correction, then you will be lucky to see the image in all my intended glory. But if you own setups adds another 1.8 gamma correction, then you will see an overly bright image.

 

In an ideal world, everybody should have a well corrected gamma setting. But that is not the case and we cannot predict the setting of those who are going to view the image. If we could all agree on a gamma correction of let's say 1.8, then this would be the standard for everyone. But in the absence of such a standard, a gamma of 1.0 (the default) should be prefered. And any further correction should be done at display time and according to the target display system.

 

To read some of the issues about using gamma corrected images, see

The Sad Story of PNG Gamma “Correction”

Link to comment
Share on other sites

But it produces blurred images and thus, some details could disapear or get considerably faded away.
Actually, weighted circular area sampling produces MORE detail of images in Animation. Here is why:

 

However, it does produce blurred images - that's why it isn't always on. In the case of animation, where motion blur is desirable, the directional nature of this blurring is positive, but static elements will be blurred. Almost all post-processing is image blurring: bloom, film-grain, depth-of-field, lens flares, motion blur, HDRI, etc., etc., etc. People like blur, that's the reason there's so much interest in separating out the render elements (diffuse, specular, mirrors, etc.) - so they can be degraded to varying degrees before recompositing. That's the art.

 

Martin Hash

Link to comment
Share on other sites

Yo Grigor,

 

So as to compare apples to apples when we are talking about this blur, I would like to see the first rendering with gamma correction applied. Much of the apparent aliasing is coming from the darkening effect between the tiles.

 

Randy

Link to comment
Share on other sites

I just made a series of test. Here is what's happening.

 

I was first mislead by the flashing effect of the selected colors but Grigor pointed me that the darkening effect came from the fact that the two colors are complementary colors. Magenta:(255,0,255) and Green:(0,255,0). So when they are blended half way, it produces 50% gray.

 

I did a similar test in photoshop but with regular ramps with 40x40 pixels squares to eliminate the flashing effect. I found the choice of color interesting and added them to a Gamma stoofer I use for calibrating my monitor gammas (see attached stoofer).

 

The problem with this color selection is that if you place a magenta square over a 50% gray background, the magenta square appears brighter than the background. And if you place a green square over the same 50% gray background, the green square also appears brighter than the background. This is normal because pure colors tends to appear brighter than achromatic tones (the only exception to this is Blue:(0,0,255). And the choice of green vs magenta represent a worst case scenario). But the result is a perceived darkening ot both colors as they shift toward 50% gray.

 

Assuming a monitor already well gamma corrected, further adding a gamma correction of 1.8 indeed corrects the darkening effect in this case of Green-Magenta ramps. But it does not work for Yellow-blue ramps which requires a gamma correction of 1.2 instead, and the Cyan-Red ramps require a gamma correction of 1.6. But applying any of those gamma corrections destroy the regularity of the black-color and color-white ramps.

 

Using the attached stoofer (I know, it is huge), a good quality monitir and the right gamma adjustment. the squares inside the squares in the second column should be almost undistinguishable. Starting with a well corrected moitor, you can test the effect of any further gamma corrections on the other ramps of the stoofer.

 

Grigor have found an interesting case where normal computations for anti-aliasing will not work very well. Fortunately, in real CG scenes, pure colors are rare and this situation should normally not be an issue.

 

PDI seems to have devised a way to handle gamma to linear color space while processing. I read the description but I'm still not convinced.

Gamma_Stoofer.png

Link to comment
Share on other sites

Yo Randy,

 

Your wish is my command.

 

I hope this render also answers the question about using gamma with the A-Buffer renderer. As you can see the A-Buffer renders this image in 2 seconds!!!

 

That's becuase the checkers are actually patches (not the Checkers Material).

 

Long live A:M

 

Greg Rostami

post-7-1078917631.jpg

Link to comment
Share on other sites

AAAAND Since I LOVE shocking people . . .

 

Here is a 256 pass render in 2 minutes 20 seconds. Compare this render to the A-Buffer Render above (2 seconds) and you'll BELIEVE in Gamma correction too . . . .

 

Greg Rostami (aka G (as in original Gangsteh)) ;-)

post-7-1078919040.jpg

Link to comment
Share on other sites

  • Hash Fellow
Using the attached stoofer (I know, it is huge), a good quality monitir and the right gamma adjustment. the squares inside the squares in the second column should be almost undistinguishable.

Although my monitor is adjusted such that I can pretty much see the whole range of the ramps, I couldn't find any gamma setting that would hide the center squares in the center column.

 

This article, Why a new Gamma Chart?, asserts that checkerboard patterns shouldn't be used in gammas charts. Are they off base? Talking of some entirely different issue?

Link to comment
Share on other sites

robcat,

 

This can happen. My 21" monitor have this same problem. That's why I don't use it for any graphics work. It is related to something I think is called "attack" of phosphore and/or the CRT driving circuit. Some monitor, have an overshoot in the raise and fall of the cathode emission, The result is a kind of edge enhancement. When a minitor does that, there is no way to completely hide the center checker pattern. One adjustment I found helped was to reduce the monitor brightness. But mine was already too dim for my taste so I had to crank the brightmess to its max.

 

That is a very interesting article you fond there. I am reading it with great interest.

Link to comment
Share on other sites

I'm just coming back from reading the link previously supplied. That was an entertaining read. The leat we can say is that it shows clearly that opinions are quite diversified when it comes to gamma correction. And it can get quite emotional.

 

My monitor gamma was set with the help of the stoofer I had prepared. The idea is not only to have inside squares disapear in the second column but also to visually get nice regular tone ramps in each of the strips of the stoofer.

 

When I used the gamma strips provided by Norman Koren, I could not see any distinctive differences. According to his chart, my monitor was set with a gamma of 2.1 which is fine. So I would say that his chart is OK for calibrating. It seems that this type of chart would work better with some monitors. This was not the case with my monitor but it might be for yours.

 

As I said, I read with great interest and amusement the dispute between Charles Poynton and Timo Autiokari. I think that when reading those arguments, one thing should be kept in mind: these peoples are photographers. They work with devices which are already performing gamma adjustment on the pixels and then they process their photographs with the intention of printing them first. Their issues with Gamma correction are slightly different than for a 3D CG artist.

 

I will not comment on their arguments. I will simply say that my own experience corresponds to what Timo Autiokari shows on his web site and the mathematical model of Gamma correction perfectly supports his observations. Apart from this, I will state how I chose to work:

 

I choose to work and produce non-gamma corrected image files. If I need to apply a gamma correction, I do it later, when all the other post processing steps have been performed. The reason I choose to work this way are based on my experience which can be recapped in a few facts:

 

- Gamma correction is a monitor thing. If it wasn't for the monitors which we use to display our images, we wouldn't be discussing this Gamma thing. So gamma correction should ideally be applied at display time and the ammount of gamma correction to apply should be determined from the particular monitor proofile which is used to display the file.

 

- Gamma correction applies a power factor to the linear transfer curve of the color channels. This means that the transfer curve in not linear anymore. This implies that for dark channel values, the multiplying factor is much higher than for bright channel values. So for colors which are a composed of low values on some channel and high values on some other channel, any color mixing operation will produce undesirable hue shift because the channels components are not all processed with the same multiplying factor.

 

- 3D renderer work with non gamma corrected values. When luminosity is computed at a given pixel, it is in linear light space. When a renderer adds 2 different illumination values, the result is directly predictable. I want the result to reflect as precisely as possible the raw solution of the renderer. As stated above, I can always gamma correct them afterward if I ever find a need for it.

 

- A good gamma correction in some particular color scheme instances will not necessarily be as good with other color combination. There is no hard rules for gamma correction.

 

- I might decide to gamma correct an image for artistic purposes because it gives me a result which better suits my artistic intent. I might decide to do that with the same spirit that I could decide to increase the contrast, or shift the general hue, or tone down the saturation, or add a sepia tint. But I will not gamma correct a image otherwise. In particular, I will not gamma correct an image simply based on the particular hardware characteristics I am rendering on and with some particular issues.

 

As a last advice, I would add: Even "experts" don't agree on this gamma correction issue. So if you don't fully understand the implication of gamma correcting an image, I suggest you should avoid it. At least, wait at the very last step of your production before applying any gamma correction.

Link to comment
Share on other sites

A last update. I just read Charles Poynton FAQ about Gamma. Here is a quote that I thought is of interest to us, 3D CG users:

 

21. Should I do image processing operations on linear or nonlinear image data?

 

If you wish to simulate the physical world, linear-light coding is necessary. For example, if you want to produce a numerical simulation of a lens performing a Fourier transform, you should use linear coding. If you want to compare your model with the transformed image captured from a real lens by a video camera, you will have to "remove" the nonlinear gamma correction that was imposed by the camera, to convert the image data back into its linear-light representation.

 

IMO, this concurr exactly with the different demonstrations from Timo Autiokari.

Link to comment
Share on other sites

Guest jandals

This is an excellent thread, and I'll read through it several times to get the most out of it.

 

But I mostly wanted to point out the humor of Greg being listed as a "Newbie." I know It's based on number-of-posts, but I still think it's funny.

 

Thanks again for posting, Greg (G...). Awesome stuff!

 

Rhett

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...