Thursday, January 8, 2015

Super Sampling DRT

Super Sampling: This is a technique to convert jagged edges to smooth surface. This technique is also called anti aliasing. We have jagged edges when we re size the picture of low resolution to higher resolution (i.e you might be able to see smooth surface when resolution is low as soon as you increase the resolution of image it become jagged). Using DRT supersampling technique we remove jagged edges.
ALGORITHM:
We shoot multiple rays from pixels in image plane means we just jitter the position of pixel center for every pixel on image plane.
C++ CODE:
for(int k =0; k<100 data-blogger-escaped-b="" data-blogger-escaped-c="" data-blogger-escaped-du="rand()/float(RAND_MAX+1);//generating" data-blogger-escaped-dv="rand()/float(RAND_MAX+1);//generating" data-blogger-escaped-float="" data-blogger-escaped-in="" data-blogger-escaped-k="" data-blogger-escaped-numbers="" data-blogger-escaped-random="">//L is light vector, i and j are counters over pixels in image plane
pixelCenterCordinate = L + (pixelWidth)*(j+du)*u + (pixelHeight)*(i+dv)*v;
rayDirection = (pixelCenterCordinate - rayStart);
rayDirection.normalize();
pixelColor = shade(rayStart,rayDirection);
pixelColors +=pixelColor;
}
pixelColor[0] = pixelColors[0]/100;
pixelColor[1] = pixelColors[1]/100;
pixelColor[2] = pixelColors[2]/100;
pixelColors.setValue(0,0,0);
// don't forget to reset the color of pixel to black once you complete the iteration for one pixel

No comments:

Post a Comment