sx3-2.15 reduction of lighting calculations using spherical harmonics

Post on 04-Jan-2016

61 Views

Category:

Documents

10 Downloads

Preview:

Click to see full reader

DESCRIPTION

SX3-2.15 Reduction of Lighting Calculations Using Spherical Harmonics. 조욱래 mech12@nate.com www.cafe.naver.com/shader. Instroduction. Phong Light Model L = Ambient + Attenuation*(Diffuse +Specular) 모든 환경광에 대해 처리하기에는 무리 . 그래서 여기서는 환경광을 두개의 부류로 분리 High Chromatic Light - PowerPoint PPT Presentation

TRANSCRIPT

SX3-2.15Reduction of Lighting

Calculations Using Spherical Harmonics

조욱래mech12@nate.com

www.cafe.naver.com/shader

Instroduction Phong Light Model

L = Ambient + Attenuation*(Diffuse +Specular) 모든 환경광에 대해 처리하기에는 무리 .

그래서 여기서는 환경광을 두개의 부류로 분리

High Chromatic Light 가장 영향이 큰 빛에 대해서만 퐁모델 적용 .

평범한 Light projected onto ENVmap 각 ENV map texel 에 빛의 영향을 반영하는 9 개의 SH Coef

ficient 를 저장

Spherical Harmonics Based Lighting

Irradiance .

Amount of light incident onto a point Computed by intergrating the incoming ligh

t

E : Irradiance ,Function of surface normal n : surface normal w : incoming light direction L(w) : whole environment map light

SH Functoin A set of orthonomal basis function over the sphe

re. 임의의 구면을 유한의 Taylor 급수형태로 분리하여

근사화 하기 위한 수학적 툴 . 여기서는 E 와 L 항을 SH 항으로 표현 하면

l , m : degree of SH

Coefficients Ylm

Polynomial form X,y,z : cartesian coord of the incident vector

E : expressed function of L Theta , pi : spherical coord A : term of dependent on n and w

Alpha : error term p,q : number of term [Ramamoorthi01] 의하면 coeffi 값은 9 개정도만

해도 높은 정밀도의 결과를 얻을수 있다 .

Coefficents

l = 0,1,2 m =

0 -1, 0, 1 -2, -1,0,1,2

게임상의 구현 1st : encode the lighting ENV in SH term.

Static Light ENV Calculated offline distant sun, etc… Static is not mean cannot be rotated.

SH Property is rotationally invriant.

Dnynamic light source Need to encoding real time This mean calculating the Llm terms

게임상의 구현 (2)

2nd : calculating the actual irradiance, E

E depends on theta ,pi (Spherical coord) , and surface normal.

그래서 물체가 렌더링 되는 시점에서 계산되야함 .

The Two Methods

Analytical Lights Spot, point light, etc

빛이 무한대에 위치한다고 가정 . Lighting ENV map 의 일부로 가정 .

각각의 빛은 해당 SH coeffi 를 spatail domain 이나 frequency domain 에서 쉽게 더함으로 해서 적용될수 있다 . Run time

Surface Lights Sky ,pre-rendered ENV map, HDR, non-HDR ma

p, bulb , neon light 전역광에 의한 더 정확한 사실 묘사에 유용 .

Ylm : Nine coefficents L=(0,1,2) and m=(-2,-1,0,1,2)

Llm Light weight of ENV map

L 한지점에서의 빛세기 .

Determining the Lights’ Contribution to the Scene

중요 항 해당 물체 표면의 한 점에 대해 다음을 계산 .

Intensity of light Chromacity of light Distance of light

Chromacity Represents RGB (100,100,100), (125,125,125) ,and (255,0,0)

에서 마지막 값이 제일 chromaticy 량이 높다고 간주한다 .

그 이유는 다음식 때문이다 .

Chromacity factor

C1 = 0.7, C2=0.3 임의로 정한 경험 값이다 .

최종적으로 모든 빛에 대해 Lf 를 구하고 소팅하여 가장 큰 값의 빛에 대해 Full Phong equation 을 계산한다 ( using SH)

Putting It All Together-Code Explanation

SH 를 이용한 빛 계산은 크게 CPU tiime 과 GPU time 으로 분리된다 .

(GPU 의 성능에 크게 영향을 받음 .)

Surface Lights

Compute SH’s coefficients

Analytical Lights

To turn analytical light into SH

ENV map & Cube map (???)

Get 2D coeffi

극좌표 ->2D 좌표

극좌표 ->3D 좌표

Ylm 계산

Integra += samplevalue(xp,yp) * Ylm

Foreach ( 9 coeffi) //l,m

For(every pixel in ENV map)

Get 2D coeffi

2D 좌표 & face ‘n’-> 3D 좌표

Ylm 계산

Integra += samplevalue(xp,yp) * Ylm

Foreach ( 9 coeffi) //l,m

For(pixels in 6 faces of ENV map)

CPU

GPU Color 계산 using normal & coeffi.

Blend this with other incomming colour

& vertex color

장단점 Vertex Program Work

Fast Poor quality in low tessellated

geometry

Fragments Program Work Looks good ( diffuse light per pixel ) Slow

Pros and Cons of SH

Pros 빛의 수가 많아도 성능에 영향이 없다 . 가능한 모든 전역광이 9 개의 값으로 표현 .

Cons 모든 빛 효과를 SH 로 표현할수 없다 . Shadow, radiance transfer , Phong effect

PRT 를 로 해결가능 .

최종분석

ShaderX3-2.15.vsd

Q&A

top related