Phyically Baed Rendering 실사같은조명효과를위한방법들 네오위즈 CRS 조경준
우리의꿈 Uncharted 3 Naughty Dog
우리의꿈 Cryi 2 - Crytek
우리의꿈 Battlefield 3 DICE
How????
우리의현실...
우리의현실...
우린안될거야아마...
Motivation AAA 급의그래픽을뽑고싶다 1. 값비싼엔진도좋지만 - 엔진에제공하는기능만으로는차별화할수없다 - 자체적으로훌륭한결과를내는경우도많음 (ex. Uncharted 3) - 기왕이면외화도좀줄이고 ( 실은사장님이언리얼안사주셨어요 ) 2. Phyically Baed Rendering - 특정기술을지칭하기보다는전반적인접근방식
Phyically Baed Rendering Volumetric Rendering Equation Rendering Equation 첫째날하나님께서말씀하시기를 Where : urface poition : outward direction : poition in participating media : BRDF : tranmittance 라고하시어빛을창조하셨느니라 dt L T L T L t i t t r r o ), ( ) ( ), ( ), ( ), ( ), ( x x x x x x x x d L f L L i r e ) )(, ( ),, ( ), ( ), ( n x x x x ), ( ), ( ), ( r e L L L x x x x x t ),, ( r f x ), ( t r T x x
Phyically Baed What? - 물리법칙에기반한 Lighting( 조명 ) / Reflectance( 반사 ) Model 을사용 Why? 1. Photorealitic 결과를얻기쉬워짐 2. 다양한조명환경에서도일관된결과를보임 3. 각종 Fake 연산들의필요성이줄어든다. (ex. Half-Lambert) 4. Material Parameter가간결해짐 - 아티스트들의노가다가줄어든다!!!
Rendering Wikipedia 가라사대 1. Rendering이란컴퓨터프로그램을통해모델또는모델들로구성된장면으로부터이미지를생성하는과정이다 ( 중략 ) 2. 가상의조명하에서장면이비교적사실적으로보이려면, Rendering Software는 Rendering Equation을풀어야한다. - 2차방정식근의공식도가물가물한데 - 이미훌륭하신분들이풀어주셨으므로우리는참고만 - Divide And Conquer!!!
준비물 Linear Space Rendering 1. Gamma Correction 2. RGB Space -> Linear Space 변환 HDR + Tone Mapping 1. LDR에서는조명연산누적으로인한결과가 Clamp됨 ( 잘림 ) 2. LDR의 Preciion으로는조명의계조가매끄럽지못함 3. 좋은 Tone Mapping이최종결과물을좌우 Deferred Shading 1. 이후소개될일부효과들에서 Deferred Shading 의 G-Buffer 를필요로함 2. 혹은 Variation (Light Pre-pa Rendering, Inferred Rendering )
Rendering Equation Kajiya, Jame (1986) - 진공상태를가정 Emiive Light ( 자체발광 ) Reflected Light ( 반사광 ) Input Light ( 입력광 ) L ( x, ) L ( x, ) f ( x,, ) L ( x, )( n) d e r i Surface Output Light ( 표면라이팅결과 ) BRDF ( 나중에설명..) BRDF 의 Coine 성분
Rendering Equation Light Flow Irradiance L i Input Light (Indirect) L i L r Reflected Light Light Source Viewer Input Light (Direct) Li Le Emiive Light x Surface Point
Emiive Light Emiive Light ( 자체발광 ) d L f L L i r e ) )(, ( ),, ( ), ( ), ( n x x x x
Emiive Light In Real Life In Game 매우간단하므로패스
Input Light Input Light ( 입력광 ) d L f L L i r e ) )(, ( ),, ( ), ( ), ( n x x x x
Input Light Direct Light 광원에의한직접광 Indirect Light 표면반사, 산란등에의한간접광 1. Global Illumination - Light Map Static( 기존 ), Dynamic(Enlighten, Battlefield 3) - Light Propagation Volume Crytek, 우리의선택 2. Image Baed Lighting (IBL), 우리의선택 - Environment(Cube) Map 이미널리사용되고있음 - Irradiance Environment Map
Indirect Light - Light Propagation Volume Real-time Global Illumination 1. Anton Kaplanyan에의해제안 (Crytek) [2009] 2. CryENGINE 3(Cryi 2) 에적용됨 3. Reflective Shadow Map에기반 - Flux( 광량 ), Normal, Depth로구성 - VPL(Virtual Point Light) 의개념적용 4. Spherical Harmonic 에의한전파 - 2nd Band 까지적용 (4 Coefficient) Spherical Harmonic
Light Propagation Volume Overview Reflective Shadow Map 생성 Flux, Normal, Depth Radiance Injection VPL 이속하는 LPV 에 SH Coefficient 로변경및누적 Radiance Propagation 인접 Cell 로의 Radiance 전파 Scene Lighting G-Buffer 를참조하여 Render Radiance Propagation
Light Propagation Volume Cacaded Light Propagation Volume 1. Cacaded Shadow Map과유사 2. 하나의 LPV로는넓은영역에적용이어려움 - 3차원 Grid이므로 O(N3) 의복잡도 - 근경에는세밀한 LPV를사용 - 원경에는간격이큰 LPV를사용 Cacaded LPV
Without LPV
With LPV
비교
Indirect Light - Irradiance Environment Map Real-Time 에생성된큐브맵을사용 반구면을따라 Convolution 1. Texture Look-up 이너무많음 - ex. 64 짜리큐브맵으로 32 짜리 Irradiance Env. Map 생성 -> 약 1 억 5 천만번이상의샘플링필요 2. Spherical Harmonic 를이용해간소화 - 위의예시가약 22 만 X 상수배정도로감소표면의 Normal 방향을따라 Sampling
Contant Ambient
Irradiance Environment Map
BRDF BRDF ( 나중에설명..) d L f L L i r e ) )(, ( ),, ( ), ( ), ( n x x x x
BRDF Bidirectional Radiance Ditribution Function 표면상의한점에서의입사광대비반사광의양을정의 1. Lambertian 2. Oren-Nayar 3. Phong 4. Blinn-Phong 5. Cook-Torrance 6. Ward 7. Ahikhmin 8. Kajiya-Kay 9. 가장대중적하지만에너지가보존되지않음
Normalized Blinn-Phong Blinn-Phong Model 에에너지보존을고려 1. Specular 계수와상관없이동일한면적 ( 에너지 ) 를표현 - 정규화계수적용 2. 선형식으로근사해서사용가능 다른 Specular 계수 동일한면적
Normalized Blinn-Phong Frenel Term 을고려 1. Schlick 의근사 - 단순한연산으로실제 Frenel 방정식과유사한결과를나타냄 2. Diffue 에도에너지보존을고려 3. 최종결과 다소복잡해보이지만기존의연산결과를수식에대입하기만하면됨기존 Diffue 기존 Specular
Blinn-Phong
Normalized Blinn-Phong
비교
Screen Space Sub-Surface Scattering Why? 1. 사람의눈은피부를구별하는데익숙함 2. BRDF(Bidirectional Radiance Ditribution Function) 으로는피하산란을표현할수없음 3. BSSRDF(Bidirectional Surface Scattering Reflectance Ditribution Function) - Suburface Scattering
Screen Space Sub-Surface Scattering Overview Blur Light Layer 1 Layer 2 Layer 3 Mak Normal Blend X + Final Image Depth Albedo Specular
Without SSSSS
With SSSSS
비교
Volumetric Rendering Equation Rendering Equation 은진공의상태를가정 1. 현실에서의대부분의환경은진공이아님 2. 중간매질에서의산란이고려되어야함 표면 <-> 관측자투과율 매질 <-> 관측자투과율 Input Light ( 입력광 ) L o ( x, ) T ( x, x ) L ( x, ) T ( x, x ) ( x ) L ( x, ) dt r r t t i t Output Light ( 최종라이팅결과 ) Scattering Coefficient ( 파장에영향받음 ) Surface Output Light (Rendering Equation)
Volumetric Rendering Equation 광원의종류에따라구현이달라짐 1. Sun(Directional) Light Atmopheric Scattering 2. Point/Spot Light Single Scattering
Atmopheric Scattering 대기중태양광의산란을고려 1. Rayleigh Scattering 2. Mie Scattering
Rayleigh Scattering 빛의파장보다작은대기입자에의한산란을표현 1. 하늘이푸르게보이는이유 - 파장이짧은파란빛이더많이산란되기때문
Mie Scattering 입자의크기와상관없이산란을표현 1. 하지만연산부하를줄이기위해빛의파장보다큰경우로단순화 - Henyey-Greentein Phae Function - 빛의파장보다작은경우는 Rayleigh가담당
Rayleigh Scattering Only
Rayleigh + Mie Scattering
Single Scattering 대기중일반 Point/Spot 광원의산란을고려 1. 3 가지빛의경로에서의산란이모두고려되어야함 광원 -> 관측자 광원 -> 표면 표면 -> 관측자
Single Scattering Off
Single Scattering On
비교
Putting It All Together Daylight Sample 1. Irradiance Environment Map 2. Global Illumination (LPV) 3. SSAO Night Sample 1. Global Illumination (LPV) 2. Single Scattering 3. Bokeh DOF
Daylight Sample: Direct Light + Contant Ambient
Direct Light + Irradiance Environment Map
Direct Light + Irradiance Environment Map + Indirect Light (LPV)
SSAO 추가
초기이미지
최종이미지
Night Sample: Ambient + Direct Light
Direct Light + Indirect Light (LPV)
Direct Light + Single Scattering
Direct Light + Indirect Light + Single Scattering
Bokeh DOF 추가
Night Sample: Ambient + Direct Light 초기이미지
최종이미지
Concluion 지속적인 GPU 성능증가 1. 남는 GPU 자원을어디에쓸것인가? - 16x SSAA? - 그동안관심이조명의질적인증가보다는양적인증가에편중됨 - 보다정확한조명연산의필요성대두 - Phyically Baed Rendering 2. 아직해결해야할과제들이많이남아있음 - 해외에서는많은논의가이루어지고있음 - 우리도활기차게논의해봅시다 3. 문의하실내용은 atomk@neowizcr.com 으로
Reference Jame T. Kajiya. (1986). The Rendering Equation. Wojciech Jaroz. (2008). Efficient Monte Carlo Method for Light Tranport in Scattering Media. Chapter 4 - Light Tranport in Participating Media. Yohiharu Gotanda. Real-time Phyically Baed Rendering - Baic Theory -. CEDEC 2011. Yohiharu Gotanda, Tatuya Shoji. Real-time Phyically Baed Rendering - Implementation -. CEDEC 2011. Dimitar Lazarov. Phyically Baed Lighting in Call of Duty: Black Op. SIGGRAPH 2011. Carten Dachbacher, Marc Stamminger. (2005). Reflective Shadow Map. Univerity of Erlangen-Nuremberg.
Reference Anton Kaplanyan. Light Propagation Volume in CryEngine 3. SIGGRAPH Coure, 2009. Anton Kaplanyan and Carten Dachbacher. Cacaded Light Propagation Volume for Real-Time Indirect Illumination. 2010. Ravi Ramamoorthi, Pat Hanrahan. An Efficient Repreentation for Irradiance Environment Map. SIGGRAPH 2001. Gary King. Real-Time Computation of Dynamic Irradiance Environment Map. GPU Gem 2 - Chapter 10. Sean O Neil. Accurate Atmopheric Scattering. GPU Gem 2 - Chapter 16. Ralf Stokholm Nielen. Real Time Rendering of Atmopheric Scattering Effect for Flight Simulator.
Reference Carten Wenzel. Real-time Atmopheric Effect in Game. SIGGRAPH 2006. Bo Sun, Ravi Ramamoorthi, Srinivaa G. Narahmhan, Shree K. Nayar. A Practical Analytic Single Scattering Model for Real Time Rendering. George Borhukov and J. P. Lewi. Realitic human face rendering for The Matrix Reloaded". In SIGGRAPH '03: ACM SIGGRAPH 2003 Sketche & Application. Craig Donner and Henrik Wann Jenen. Light diffuion in multi-layered tranlucent material. ACM Tran. Graph. 24,3,1032-1039, 2005. Eugene d'eon and David Luebke. GPU Gem 3, chapter 14, page 293-347. Addion-Weley Publihing, 2007.
Reference Jorge Jimenez, Veronica Sundtedt, and Diego Gutierrez. Screen-pace perceptual rendering of human kin. ACM Tranaction on Applied Perception, 6(4), 2009. Morten S. Mikkelen. Skin Rendering by Peudo-Separable Cro Bilateral Filtering. 2010.
THANK YOU