Saturday, May 8, 2010

Signal processing with post-filtering in RenderMan (1)

3D Rendering algorithms에 대해 깊숙히 들어가다 보면 renderer 성격과 상관없이 어디에서나 만나게 되는 것중에 하나가 이 signal processing과 연관된 anti-aliasing이 아닐까 한다. 넓게 보면 2D, 3D를 떠난 모든 raster computer graphics 전반에 걸쳐 있을 뿐만 아니라 3D CG rendering 과정은 물론이고 연관된 여러 illumination algorithms에 있어 중요한 부분이 아닐 수가 없다. 더나가 이런 signal processing에서 파생된 spherical hamonics 원리를 이용한 여러 illumination 효과까지, 그 이해의 필요성은 말 할 것도 없을 것이다.

Rasterization, 즉 The process of generating an image from a model in raster-space로 간단하게 Rendering in 3D computer graphics을 정의 할 수 있 듯이 결국 original signal with vector information in 3d space을 raster-space로 perspective projection 시키는 point sampling의 최종 목적지, 즉 the intensity of the image at some X-Y coordinate point within the pixel로 가면서 aliasing은 늘 따라 다니는 동반자가 될 수 뿐이 없게 되지만 우리 눈이 capture 할 수 없는 영역 밖으로 그 aliasing을 minimalize 시키므로 극복해 나갈 수 있게 되는 것이다. 그 중 오늘은 signal processing과 연관해서 point sampling 후 이어지는 post-filtering에 중점을 두어 얘기를 시작 하도록 하겠다.

먼저 일반적인 rendering in 3D CG에서 signal precessing을 전체적으로 크게 보면 아래와 같을 것이다.

original signal -> pre-filtering -> point sampling -> post-filtering -> final pixel.

Original signal을 sampling and reconstructing을 통해 aliasing 없이 최종 pixel에 도달하게 만들어야 하는데 있어 가장 중요한 목적은 low frequency signal은 손실 없이 그리고 aliasing의 주범인 high frequency signal을 aliasing and detail lose 사이에서 가장 적절하게 capture하여 pixel로 reconstructing을 하는데 있다고 볼 수 있겠다.

Nyquist frequency theory (It has to be sampled at more than twice the frequency of the original signal.)에 의해 A pixel안에 다수의 samples(surper-sampling, sub-sampling 혹은 multi-sampling이라고도 함)을 capture하게 되는데 이는 up sampling으로써 high frequency data까지 capture가 가능하게 되지만 여러 aliasing errors을 피하기 위해 다시 역으로 low pass filtering을 통해 down sampling 하게 하므로 그 capture 해온 high frequency data에서 생기는 aliasing을 막는 동시에 lower frequency data는 잃지 않게 하면서 amplitude(color) reproduce를 해야한다. 그래서 rendering에서는 weighted average of samples from both inside and outside the area covered by the pixel 로 post-filtering을 해주게 되어 final pixel를 얻게 되는 것이다.

여기서 위의 up sample된  sub-samples를 filter weighting function을 거쳐 가게 하는데 있어 이런  signal(data) 다루기 편한 상태로 만들어야 하는게 우선시 되겠다. signal은 읽혀지는 방식에 따라 time domain(CGI에서는 observing signals in sptial domain, like as pixels on a screen)과 frequency domain이 존재 하는데 대부분의 신호 처리는 연산량과 편리함을 위하여 fourier transform(fft)을 통하여 time(or spatial) domain을 frequency domain으로 변환 혹은 inverse Fourier transform 후 계산을 하게 된다.

Fourier theory states, that a periodic signal can be seen as a sum of sine waves with different ferquencies, amplitudes, and phases. More important is to understand that some operations are much easier to do in the frequency domain than in spatial domain, and vice versa.

즉, time(spatial) domain은 가로축이 time(space)이고 frequency domain은 가로축이 주파수가 되는데 (세로축은 amplitude(color)) 따라서 spatial domain에서는 time(space)에 따라 신호가 어떻게 변하는지를 볼수 있고 frequency domain에서는 이 신호에 각각의 주파수 성분들이 얼마나 많이 들어 있는지를 볼 수 있게 된다.

이는 filtering 시 그 signal은 frequency domain 안에서 쉽게 higher frequency data를 없앨수 있지만 time(sparial) domain에서는 그리 쉽지가 않다. 그래서 filter weighting function(weighted average of the signal in the area of the pixel)는 Fourier transform 통해 frequency domain로 전환후 적용을 하게 되는 것이다. Frequency domain에서 가장 이상적인 filter의 모습은 step 형태가 되겠는데 이는 간단하게 higher frequency signals을 lower frequency data의 손실 없이 제어를 하게 되겠다.

To perform the filtering, we need to calculate the distance from the center of the pixel being filtered, to each sample point location, and use that to get a sample weight. The data for that sample is then accumulated using the weight. When the samples have all been processed in this way, the result is divided by the total weights of all samples that contributed and this will be the final data stored on the pixel, and passed onto the exposure stage. 

다음 글에는 RenderMan과 직접적으로 연관해서 post-filtering에 대해서 한번 살펴 보도록 하겠다.                    
계속.....

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home