|
|
Anti-aliasing |
|
A rendering algorithm that checks only a single ray per screen pixel leads to very jagged images -
this can be easily seen in the original rendering of the "crown" image (click to enlarge):
One way to overcome this is to check multiple rays for each pixel and then average out the results (independently for each pixel).
With single rays per pixel, the ray goes through the middle of that pixel.
When checking multiple rays, those need to be distributed throughout the pixel.
One way of doing that is to have a regular n x m grid;
for instance, with 3x2 anti-aliasing we'd check rays going through the following points inside of our screen pixels:
So, when we apply 2x2 and 4x4 anti-aliasing to the "crown" image, we get much better quality output images:
Obviously, the time to finish the rendering will now be much longer now; with this simple, brute-force algorithm,
we basically multiply the time of single ray per pixel rendering by the size of the anti-aliasing box;
so, 4x4 will be 16 times slower...
So then, what are the best numbers for this oversampling?
On the one hand, we want good quality images; on the other hand, rendering times should be acceptable...
Well, for quick preview-type rendering, anti-aliasing can obviously be set to 1x1
(actually, even more "blocky" images would do for previewing: 1 ray per, say, 3x3 pixels).
But when generating final pictures, 3x3 sampling is definitely better (2x2 is also better, but still, 3x3 produces noticeably better images).
For fun, the image below shows the effects of anti-aliasing on a part of the "crown" image with different dimension of the sampling box:
But all of this will depend on the image; for instance fractal rendering needs higher oversampling rates,
but if there are textures that already are anti-aliased, then lower level anti-aliasing can work quite well.
And the sources to the above - in a C++Builder project - can be found
here.
Top
|
Comments |
#1
Łukasz
wrote on
2016-08-04 12:23:21
|
Witaj,
Szukam sposobu narysowania obrazu 3d. Tak na prawde nie potrzebuję na razie kolorów, cieni ani nawet luster. (nie wiem czy uzywasz Ruby, jesli łatwiej) Potrzebuje po prostu trójkątów i opisu obserwatora. Czy taki program, który by rysowal ekran i powiedzmy każdą figurę na inny kolor byłby bardzo trudny?
|
|
Top |
|
Top
|
|
|