SlideShare ist ein Scribd-Unternehmen logo
1 von 37
Lighting In Screen Space
(Light Pre-Pass)

이민웅
차례


많은 광원을 그리는 방법들





Light Pre-Pass 소개
Light Pre-Pass 구현방법






Deferred Shading

GBuffer
Light Buffer

정리
질문
많은 광원을 그리는 방법들


Deferred Shading / Rendering




Z Pre Pass Rendering




John D. Carmack II, Doom3

Light Pre Pass




Saito & Takahashi 1990

Wolfgang Engel 2008

Inferred Lighting


SIGGRAPH2009 Scott Kircher,Alan Lawrance
Z Pre Pass Rendering





존카멕이 처음 개발
Doom3 적용
Depth만을 가지고 Light계산
Deferred Shading
굉장히 배치가 간단해지고, 엔진에서 관리가 쉽다



일반적인 그림자 테크닉들과 통합이 쉽다





라이팅을 위한 계산이 “완전한” O(1) 복잡도를 가진다.





오브젝트의 개수와 상관없다
Lighting 계산의 부하가 Scene의 복잡도에 독립적이다.

수많은 작은 동적 라이팅 사용이 가능하다

Killzone 2’s G-Buffer Layout (courtesy of Michal Valient)
Deferred Shading


MRT를 이용한 랜더링 (Shader 3.0)

Normals

Specular

Albedo /
Shadow

Depth Buffer
Motion Vec

Deferred
Lighting
Forward
Rendering
Deferred Shading 단점



투명 객체를 처리 못함
G-Buffer안에 Material Property들을 저장






G-Buffer의 공간은 매우 제한적 (최대 4장)

모든 Material들에 대해서 아주 유사한 Lighting 공식
이 사용되는 것을 요구
RenderTarget 4장사용으로 메모리양이 큼
Forward Rendering처럼 frame buffer에 직접 렌더링
할 때 자동으로 받는 하드웨어anti-aliasing이 불가능
Light Pre Pass
Light Pre-Pass


MRT의 지원이 없어도 구현이 가능




기본적으로 2Pass로 랜더링을 이용하기 때문에 하드
웨어 MSAA를 지원




반투명 오브젝트는 2Pass 때 랜더링

Render Target는 한장만 사용




Shader 2.0 환경에서 구현가능 (크게 의미는 없음)

Deferred Shading 과 비교할때 메모리양이 적음

Material 구현에 관하여 더 유연성를 제공


2Pass 때 처리
Light Pre-Pass

1Pass
Normals

Depth Buffer

투명 객체

Light Buffer

Forward
Rendering

Forward
Rendering
2Pass
Light Pre-Pass 단점


Deferred Shading 의 경우, 랜더는 최저 1회로 끝






MRT를 사용해 G-Buffer 에 랜더

Light Pre-Pass 는 기본적으로 2Pass 랜더
여러 개의 light에 대해서 specular 항을 계산할 때의
문제점 (GameDev.net)


Specular값을 텍스쳐 한장으로 담아야 하기 때문에…
Light Pre-Pass 적용 사례

S.T.A.L.K.E.R: Clear Skies
Light Pre-Pass 적용 사례

BlurTM in-game screenshot
Light Pre-Pass 적용 사례

UnchartedTM in-game screenshot
Light Pre Pass 구현 방법
G Buffer (1Pass)



Depth + Normal 추출
NORMAL압축하여 뽑음







Normal 압축함으로 퀄리티 향상도 할 수 있음
RG : normal
B : Depth
A : Alpha Test

A16FR16FG16FB16 포멧 사용
G Buffer (1Pass)
Gbuffer_VS
{
float4 position = float4( vertex.position , 1.0f );
Out.PosClip
= mul(position, WORLDVIEWPROJ);
Out.PosView
= mul(position, WORLDVIEW);
float3 N
= vertex.normal;
float3 T = vertex.tangent.xyz;
float3 B = cross(N,T) * vertex.tangent.w;
Out.TangentToView1 = mul( T, (float3x3)WORLDVIEW );
Out.TangentToView2 = mul( B, (float3x3)WORLDVIEW );
Out.TangentToView3 = mul( N, (float3x3)WORLDVIEW );
}
G Buffer (1Pass)
Gbuffer_PS
{
float4 texcolor
float depth

= tex2D( diffuseSampler , Input.TexCoords.xy );
= Input.PosView.z / CAMERAFAR;

float3 tangentSpaceNormal.xyz = tex2D( bumpSampler, Input.TexCoords.xy ).xyz * 2 - 1;
float3x3 mtxRot;
mtxRot[0] = normalize( Input.TangentToView1 );
mtxRot[1] = normalize( Input.TangentToView2 );
mtxRot[2] = normalize( Input.TangentToView3 );
tangentSpaceNormal = normalize( mul( tangentSpaceNormal, mtxRot ) );
float4 packColor = PackDepthNormal(depth, tangentSpaceNormal);
packColor.a = texcolor.a;
return packColor;
}
Compact Normal Storage


store X&Y, reconstruct Z
half4 encode (half3 n, float3 view)
{
return half4(n.xy*0.5+0.5,0,0);
}
half3 decode (half2 enc, float3 view)
{
half3 n;
n.xy = enc*2-1;
n.z = sqrt(1-dot(n.xy, n.xy));
return n;
}

Compact Normal Storage for small G-Buffers http://aras-p.info/texts/CompactNormalStorage.html
Compact Normal Storage


Spheremap Transform
half2 encode (half3 n, float3 view)
{
half f = sqrt(8*n.z+8);
return n.xy / f + 0.5;
}
half3 decode (half4 enc, float3 view)
{
half2 fenc = enc*4-2;
half f = dot(fenc,fenc);
half g = sqrt(1-f/4);
half3 n;
n.xy = fenc*g;
n.z = 1-f/2; return n;
}

Compact Normal Storage for small G-Buffers http://aras-p.info/texts/CompactNormalStorage.html
Gbuffer(Depth)
Gbuffer(Normal)
Light Buffer Pass




Screen Space에서 Gbuffer을 이용하여 Light를 계산
Light계산시 Light방향을 ViewSpace로 변환하여 계산
Depth로 위치를 뽑아서 Speculer을 계산





Point Light도 계산함

그림자도 Light계산시 같이 할 수 있음
A16FR16FG16FB16F 포멧으로 설정
Light buffer layout
R : LightColor.r * N.L * Att
G : LightColor.g * N.L * Att
B : LightColor.b * N.L * Att
A : R.V^n * N.L * Att (Speculer)
Light Buffer Pass


라이트버퍼 계산시 머트리얼 계산법



미리 계산해 놓으면 2Pass 때 빠르게 랜더링 할수 있
음


머트리얼을 미리 계산할시 랜더타겟 한장이 더 필요
Light Buffer Pass

Speculer Color 있음

Speculer Color 없음

CryEngine 3
깊이 버퍼로부터 위치 계산
•
•

픽셀의 실제 위치를 얻어낼 시 depth buffer를 이용하여 만듬
픽셀의 카메라 스페이스 상 위치를 얻어오는 일반적인 방법은
Inverse Projection matrix를 곱해주는 것
 Depth 저장시 WVP 변환 결과의 z/w값을 기입 하는 것이 아니고
WV 변환 결과의 Z만 저장 하여 Linear한 것으로 만들어 줌








floating 포맷이 아니라면 Zfar로 나누면 될 듯
좌상,우상,좌하,우하의 far clip 방향 ray

VS에 프러스텀의 정보를 넘겨줌

PS에서는 해당 좌표에 받은 ray(보간 되어 옴)정보를 기반으로
깊이와 곱하여 최종 위치를 구함
SSAO , Motion blur(depth based), DOF

FrustumCorner = Vector3(0,0,Far)
FrustumCorner.y = tan( FOV / 2 ) * Far
FrustumCorner.x = FrustumCorner.y * Aspect
Light Buffer Pass
pos_vs {
Out.Position = Input.Position;
Out.TexCoords = Input.TexCoords.xy;
Out.View = float3(FRUSTUMCORNER.x * Input.Position.x,
FRUSTUMCORNER.y * Input.Position.y, FRUSTUMCORNER.z);
}

directional_ps {
float fvDepth;
float3 fvViewSpaceNormal;
UnpackDepthNormal( normalDepthSampler , In.TexCoords, fvDepth, fvViewSpaceNormal );
float3
fvViewSpacePos = fvDepth * In.View;

float diffuseLight = saturate( dot( fvViewSpaceNormal, DIRLIGHT) + AMBIENT;
float3
eyeVec
= -normalize( fvViewSpacePos );
float3
halfVec
= normalize( eyeVec + DIRLIGHT );
float
specular
= pow( saturate( dot( fvViewSpaceNormal, halfVec) SHININESS )
return float4(diffuseLight , specular * NdotL);
}
Light Buffer( Light )
Light Buffer( Speculer )
라이트의 퀄리티를 높혀보자(팁?)


Ambient Cube ( Valve‟s )






구현이 매우 간단함
적은 계산량으로 간접 조명을 보여줄 수 있음
각 점마다 6개의 irradiance 값을 미리 계산해서 배치
 디자이너가 Cube의 6개 색을 미리 지정
주인공 캐릭터들은 가장 가까운 점을 얻어와서
간접조명(indirect illumination)으로 사용
Shading in Valve's Source Engine 참조

float3 AmbientLight( const float3 worldNormal )
{
float3 nSquared = worldNormal * worldNormal;
int3 isNegative = ( worldNormal < 0.0 );
float3 linearColor;
linearColor = nSquared.x * cAmbientCube[isNegative.x] +
nSquared.y * cAmbientCube[isNegative.y+2] +
nSquared.z * cAmbientCube[isNegative.z+4];
return linearColor;
}
Light Buffer( Light + AmbientCube)
Light Buffer( Light )

Ambient Cube 사용

Ambient만 사용
2Pass


Pass때 미리 찍어둔 ZBuffer를 이용하여 ZCull(EalryZ)
을 사용하여 랜더



z-culling은 깊이에 기반하여 미리 픽셀을 배제하는 것
Render depth only, 1Pass




Render with full shaders, 2Pass





Early-Z (and Z-Cull)
ZWRITEENABLE = FALSE, ZFUNC = EQUAL

Diffuse와 누적된 라이트텍스쳐를 계산




ZWRITEENABLE = TRUE, ZFUNC = LESSEQUAL

Diffuse * LightBuffer

투명 객체 랜더
Light Pre Pass 정리


Gbuffer Pass ( 1Pass )




Light Pass




Accumulate Light Info

2Pass




불투명 객체들에 대해서, view normal과 view depth 를 저
장

Diffuse * LightBuffer

투명 객체 랜더링
Light-Pre-Pass Final
정리
수많은 동적 라이팅을 화면상의 오브젝트의 개수와 관
계없이 상수시간에 처리가 가능함
이론상 무한개의 동적 라이팅 사용 가능
어두운 실내나, 어두운 배경에 실시간 라이팅이 많은 경
우 최적의 해결 방법
현재의 그래픽 카드에서는 당연히 지원됨유명 상용 엔
진에서는 기본적으로 지원됨
직접 구현 해도, 개념이 어렵지 않고, 관리가 쉬움
셀프 셰도우등 그림자 기법이 용이함
포스트 프로세싱(DOF, SSAO, HDR등)을 사용시













G-Buffer 재사용 가능함

콘솔게임은 이미 많은 게임들이 사용되고 있음.
References
[Hargreaves] Shawn Hargreaves, “Deferred Shading”, http://www.talula.demon.co.uk/DeferredShading.pdf
[Lobanchikov] Igor A. Lobanchikov, “ GSC Game World„s S.T.A.L.K.E.R : Clear Sky – a showcase for Direct3D 10.0/1”,
http://developer.amd.com/gpu_assets/01GDC09AD3DDStalkerClearSky210309.ppt
[Mittring] Martin Mittring, “A bit more Deferred – Cry Engine 3”, http://www.slideshare.net/guest11b095/a-bit-more-deferred-cryengine3
[Lee] Mark Lee, “Resistance 2 Prelighting”, http://www.insomniacgames.com/tech/articles/0409/files/GDC09_Lee_Prelighting.pdf
[Lengyel] Eric Lengyel, “Advanced Light and Shadow Culling Methods”, http://www.terathon.com/lengyel/#slides
[Placeres] Frank Puig Placeres, “Overcoming Deferred Shading Drawbacks,” pp. 115 – 130, ShaderX5
[Shishkovtsov] Oles Shishkovtsov, “Making some use out of hardware multisampling”; http://olesrants.blogspot.com/2008/08/making-some-use-out-of-hardware.html
[Swoboda] Matt Swoboda, “Deferred Lighting and Post Processing on PLAYSTATION®3, http://research.scee.net/presentations
[Tovey] Steven J. Tovey, Stephen McAuley, “Parallelized Light Pre-Pass Rendering with
the Cell Broadband EngineTM”, to appear in GPU Pro
[Thibieroz04] Nick Thibieroz, “Deferred Shading with Multiple-Render-Targets,” pp. 251 – 269, ShaderX2
[Thibieroz] Nick Thibieroz, “Deferred Shading with Multisampling Anti-Aliasing in DirectX 10” , ShaderX7
[Valient] Michael Valient, “Deferred Rendering in Killzone 2,” www.guerillagames.com/publications/dr_kz2_rsx_dev07.pdf
[Wolfgang Engel] Wolfgang Engel, Light Pre-Pass Deferred Lighting: Latest Development- August 3rd, 2009
[김대일] 웹젠 Rendering C9 kgc2009
[이창희] Kasa Light-Pre-Pass 2009-07-04

[박민근] 네이버 초중급 게임 개발자 스터디 [데브루키] Deferred Shading (지연 세이딩)
[오즈라엘님 블로그] http://ozlael.egloos.com/2374651
[오즈라엘님 블로그] http://ozlael.egloos.com/2876211
Z-culling http://codevania.springnote.com/pages/3936893.xhtml
Compact Normal Storage for small G-Buffers http://aras-p.info/texts/CompactNormalStorage.html

Weitere ähnliche Inhalte

Was ist angesagt?

[GPU Gems3] Chapter 28. Practical Post Process Depth Of Field
[GPU Gems3] Chapter 28. Practical Post Process Depth Of Field[GPU Gems3] Chapter 28. Practical Post Process Depth Of Field
[GPU Gems3] Chapter 28. Practical Post Process Depth Of Field종빈 오
 
Game Visual Art Technologies
Game Visual Art TechnologiesGame Visual Art Technologies
Game Visual Art TechnologiesSangYun Yi
 
[Ndc11 박민근] deferred shading
[Ndc11 박민근] deferred shading[Ndc11 박민근] deferred shading
[Ndc11 박민근] deferred shadingMinGeun Park
 
[KGC2014] 울프나이츠 엔진 프로그래밍 기록
[KGC2014] 울프나이츠 엔진 프로그래밍 기록 [KGC2014] 울프나이츠 엔진 프로그래밍 기록
[KGC2014] 울프나이츠 엔진 프로그래밍 기록 JiUng Choi
 
Ndc2010 전형규 마비노기2 캐릭터 렌더링 기술
Ndc2010 전형규   마비노기2 캐릭터 렌더링 기술Ndc2010 전형규   마비노기2 캐릭터 렌더링 기술
Ndc2010 전형규 마비노기2 캐릭터 렌더링 기술henjeon
 
Ndc17 - 차세대 게임이펙트를 위해 알야아할 기법들
Ndc17 - 차세대 게임이펙트를 위해 알야아할 기법들Ndc17 - 차세대 게임이펙트를 위해 알야아할 기법들
Ndc17 - 차세대 게임이펙트를 위해 알야아할 기법들Dae Hyek KIM
 
구세대 엔진 신데렐라 만들기 최종본 유트브2
구세대 엔진 신데렐라 만들기 최종본 유트브2구세대 엔진 신데렐라 만들기 최종본 유트브2
구세대 엔진 신데렐라 만들기 최종본 유트브2Kyoung Seok(경석) Ko(고)
 
[0107 박민근] 쉽게 배우는 hdr과 톤맵핑
[0107 박민근] 쉽게 배우는 hdr과 톤맵핑[0107 박민근] 쉽게 배우는 hdr과 톤맵핑
[0107 박민근] 쉽게 배우는 hdr과 톤맵핑MinGeun Park
 
[14.10.21] Far Cry and DX9 번역(shaderstudy)
[14.10.21] Far Cry and DX9 번역(shaderstudy)[14.10.21] Far Cry and DX9 번역(shaderstudy)
[14.10.21] Far Cry and DX9 번역(shaderstudy)해강
 
[Kgc2012] deferred forward 이창희
[Kgc2012] deferred forward 이창희[Kgc2012] deferred forward 이창희
[Kgc2012] deferred forward 이창희changehee lee
 
[Ndc12] 누구나 알기쉬운 hdr과 톤맵핑 박민근
[Ndc12] 누구나 알기쉬운 hdr과 톤맵핑 박민근[Ndc12] 누구나 알기쉬운 hdr과 톤맵핑 박민근
[Ndc12] 누구나 알기쉬운 hdr과 톤맵핑 박민근MinGeun Park
 
제노블레이도 2 ray marching을사용한 구름 표현
제노블레이도 2 ray marching을사용한 구름 표현제노블레이도 2 ray marching을사용한 구름 표현
제노블레이도 2 ray marching을사용한 구름 표현민웅 이
 
09_motionblur
09_motionblur09_motionblur
09_motionblurnoerror
 
[0312 조진현] good bye dx9
[0312 조진현] good bye dx9[0312 조진현] good bye dx9
[0312 조진현] good bye dx9진현 조
 
Implements Cascaded Shadow Maps with using Texture Array
Implements Cascaded Shadow Maps with using Texture ArrayImplements Cascaded Shadow Maps with using Texture Array
Implements Cascaded Shadow Maps with using Texture ArrayYEONG-CHEON YOU
 
유니티 게임 그래픽스 아트 개발 사례 분석
유니티 게임 그래픽스 아트 개발 사례 분석유니티 게임 그래픽스 아트 개발 사례 분석
유니티 게임 그래픽스 아트 개발 사례 분석SangYun Yi
 
NDC2016 프로젝트 A1의 AAA급 캐릭터 렌더링 기술
NDC2016 프로젝트 A1의 AAA급 캐릭터 렌더링 기술NDC2016 프로젝트 A1의 AAA급 캐릭터 렌더링 기술
NDC2016 프로젝트 A1의 AAA급 캐릭터 렌더링 기술Ki Hyunwoo
 
[박민근] 3 d렌더링 옵티마이징_2
[박민근] 3 d렌더링 옵티마이징_2[박민근] 3 d렌더링 옵티마이징_2
[박민근] 3 d렌더링 옵티마이징_2MinGeun Park
 
Display color와 Digital texture format의 이해
Display color와 Digital texture format의 이해Display color와 Digital texture format의 이해
Display color와 Digital texture format의 이해SangYun Yi
 

Was ist angesagt? (20)

[GPU Gems3] Chapter 28. Practical Post Process Depth Of Field
[GPU Gems3] Chapter 28. Practical Post Process Depth Of Field[GPU Gems3] Chapter 28. Practical Post Process Depth Of Field
[GPU Gems3] Chapter 28. Practical Post Process Depth Of Field
 
Game Visual Art Technologies
Game Visual Art TechnologiesGame Visual Art Technologies
Game Visual Art Technologies
 
[Ndc11 박민근] deferred shading
[Ndc11 박민근] deferred shading[Ndc11 박민근] deferred shading
[Ndc11 박민근] deferred shading
 
[KGC2014] 울프나이츠 엔진 프로그래밍 기록
[KGC2014] 울프나이츠 엔진 프로그래밍 기록 [KGC2014] 울프나이츠 엔진 프로그래밍 기록
[KGC2014] 울프나이츠 엔진 프로그래밍 기록
 
Ndc2010 전형규 마비노기2 캐릭터 렌더링 기술
Ndc2010 전형규   마비노기2 캐릭터 렌더링 기술Ndc2010 전형규   마비노기2 캐릭터 렌더링 기술
Ndc2010 전형규 마비노기2 캐릭터 렌더링 기술
 
Ndc17 - 차세대 게임이펙트를 위해 알야아할 기법들
Ndc17 - 차세대 게임이펙트를 위해 알야아할 기법들Ndc17 - 차세대 게임이펙트를 위해 알야아할 기법들
Ndc17 - 차세대 게임이펙트를 위해 알야아할 기법들
 
구세대 엔진 신데렐라 만들기 최종본 유트브2
구세대 엔진 신데렐라 만들기 최종본 유트브2구세대 엔진 신데렐라 만들기 최종본 유트브2
구세대 엔진 신데렐라 만들기 최종본 유트브2
 
[0107 박민근] 쉽게 배우는 hdr과 톤맵핑
[0107 박민근] 쉽게 배우는 hdr과 톤맵핑[0107 박민근] 쉽게 배우는 hdr과 톤맵핑
[0107 박민근] 쉽게 배우는 hdr과 톤맵핑
 
[14.10.21] Far Cry and DX9 번역(shaderstudy)
[14.10.21] Far Cry and DX9 번역(shaderstudy)[14.10.21] Far Cry and DX9 번역(shaderstudy)
[14.10.21] Far Cry and DX9 번역(shaderstudy)
 
[Kgc2012] deferred forward 이창희
[Kgc2012] deferred forward 이창희[Kgc2012] deferred forward 이창희
[Kgc2012] deferred forward 이창희
 
[Ndc12] 누구나 알기쉬운 hdr과 톤맵핑 박민근
[Ndc12] 누구나 알기쉬운 hdr과 톤맵핑 박민근[Ndc12] 누구나 알기쉬운 hdr과 톤맵핑 박민근
[Ndc12] 누구나 알기쉬운 hdr과 톤맵핑 박민근
 
제노블레이도 2 ray marching을사용한 구름 표현
제노블레이도 2 ray marching을사용한 구름 표현제노블레이도 2 ray marching을사용한 구름 표현
제노블레이도 2 ray marching을사용한 구름 표현
 
09_motionblur
09_motionblur09_motionblur
09_motionblur
 
[0312 조진현] good bye dx9
[0312 조진현] good bye dx9[0312 조진현] good bye dx9
[0312 조진현] good bye dx9
 
Implements Cascaded Shadow Maps with using Texture Array
Implements Cascaded Shadow Maps with using Texture ArrayImplements Cascaded Shadow Maps with using Texture Array
Implements Cascaded Shadow Maps with using Texture Array
 
유니티 게임 그래픽스 아트 개발 사례 분석
유니티 게임 그래픽스 아트 개발 사례 분석유니티 게임 그래픽스 아트 개발 사례 분석
유니티 게임 그래픽스 아트 개발 사례 분석
 
NDC2016 프로젝트 A1의 AAA급 캐릭터 렌더링 기술
NDC2016 프로젝트 A1의 AAA급 캐릭터 렌더링 기술NDC2016 프로젝트 A1의 AAA급 캐릭터 렌더링 기술
NDC2016 프로젝트 A1의 AAA급 캐릭터 렌더링 기술
 
Modern gpu optimize
Modern gpu optimizeModern gpu optimize
Modern gpu optimize
 
[박민근] 3 d렌더링 옵티마이징_2
[박민근] 3 d렌더링 옵티마이징_2[박민근] 3 d렌더링 옵티마이징_2
[박민근] 3 d렌더링 옵티마이징_2
 
Display color와 Digital texture format의 이해
Display color와 Digital texture format의 이해Display color와 Digital texture format의 이해
Display color와 Digital texture format의 이해
 

Andere mochten auch

자동 동적 3차원 입체시각
자동 동적 3차원 입체시각자동 동적 3차원 입체시각
자동 동적 3차원 입체시각민웅 이
 
Gamma and linear color-space
Gamma and linear color-spaceGamma and linear color-space
Gamma and linear color-space민웅 이
 
크게, 아름답게,빠르게, 일관되게 만들기: Just Cause 2 개발에서 배운 교훈들 (GPU Pro)
크게, 아름답게,빠르게, 일관되게 만들기: Just Cause 2 개발에서 배운 교훈들 (GPU Pro)크게, 아름답게,빠르게, 일관되게 만들기: Just Cause 2 개발에서 배운 교훈들 (GPU Pro)
크게, 아름답게,빠르게, 일관되게 만들기: Just Cause 2 개발에서 배운 교훈들 (GPU Pro)민웅 이
 
2nd ignite masan 이그나이트마산 09 설미정_ 기부, 기발함과 발칙함사이
2nd ignite masan   이그나이트마산 09 설미정_ 기부, 기발함과 발칙함사이2nd ignite masan   이그나이트마산 09 설미정_ 기부, 기발함과 발칙함사이
2nd ignite masan 이그나이트마산 09 설미정_ 기부, 기발함과 발칙함사이Ignite Masan
 
스크래치와 역사
스크래치와 역사스크래치와 역사
스크래치와 역사Seung Joon Choi
 
기본 회전 공식
기본 회전 공식 기본 회전 공식
기본 회전 공식 cancan21st
 
[0611 박민근] 신입 게임 개발자가 알아야 할 것들
[0611 박민근] 신입 게임 개발자가 알아야 할 것들[0611 박민근] 신입 게임 개발자가 알아야 할 것들
[0611 박민근] 신입 게임 개발자가 알아야 할 것들MinGeun Park
 
Data Structure - 1st Study
Data Structure - 1st StudyData Structure - 1st Study
Data Structure - 1st StudyChris Ohk
 
GPG Study 4.3 카메라 제어기법
GPG Study 4.3 카메라 제어기법GPG Study 4.3 카메라 제어기법
GPG Study 4.3 카메라 제어기법연우 김
 
使用管理科業務報告 1102
使用管理科業務報告 1102使用管理科業務報告 1102
使用管理科業務報告 1102gongwujugongwuju
 
What the Bible Says About Profanity
What the Bible Says About ProfanityWhat the Bible Says About Profanity
What the Bible Says About ProfanitySwordSharp Studios
 
100.8.17養護科科務報告
100.8.17養護科科務報告100.8.17養護科科務報告
100.8.17養護科科務報告gongwujugongwuju
 
不違背職務行賄罪簡介100.08.26
不違背職務行賄罪簡介100.08.26不違背職務行賄罪簡介100.08.26
不違背職務行賄罪簡介100.08.26gongwujugongwuju
 
第24局局務會議紀錄
第24局局務會議紀錄第24局局務會議紀錄
第24局局務會議紀錄gongwujugongwuju
 
100.11.23養護科科務報告
100.11.23養護科科務報告100.11.23養護科科務報告
100.11.23養護科科務報告gongwujugongwuju
 

Andere mochten auch (20)

자동 동적 3차원 입체시각
자동 동적 3차원 입체시각자동 동적 3차원 입체시각
자동 동적 3차원 입체시각
 
Gamma and linear color-space
Gamma and linear color-spaceGamma and linear color-space
Gamma and linear color-space
 
크게, 아름답게,빠르게, 일관되게 만들기: Just Cause 2 개발에서 배운 교훈들 (GPU Pro)
크게, 아름답게,빠르게, 일관되게 만들기: Just Cause 2 개발에서 배운 교훈들 (GPU Pro)크게, 아름답게,빠르게, 일관되게 만들기: Just Cause 2 개발에서 배운 교훈들 (GPU Pro)
크게, 아름답게,빠르게, 일관되게 만들기: Just Cause 2 개발에서 배운 교훈들 (GPU Pro)
 
Inferred lighting
Inferred lightingInferred lighting
Inferred lighting
 
Id142 plan
Id142 planId142 plan
Id142 plan
 
2nd ignite masan 이그나이트마산 09 설미정_ 기부, 기발함과 발칙함사이
2nd ignite masan   이그나이트마산 09 설미정_ 기부, 기발함과 발칙함사이2nd ignite masan   이그나이트마산 09 설미정_ 기부, 기발함과 발칙함사이
2nd ignite masan 이그나이트마산 09 설미정_ 기부, 기발함과 발칙함사이
 
스크래치와 역사
스크래치와 역사스크래치와 역사
스크래치와 역사
 
Shader Driven
Shader DrivenShader Driven
Shader Driven
 
Mesh slice 1
Mesh slice 1Mesh slice 1
Mesh slice 1
 
기본 회전 공식
기본 회전 공식 기본 회전 공식
기본 회전 공식
 
[0611 박민근] 신입 게임 개발자가 알아야 할 것들
[0611 박민근] 신입 게임 개발자가 알아야 할 것들[0611 박민근] 신입 게임 개발자가 알아야 할 것들
[0611 박민근] 신입 게임 개발자가 알아야 할 것들
 
Data Structure - 1st Study
Data Structure - 1st StudyData Structure - 1st Study
Data Structure - 1st Study
 
GPG Study 4.3 카메라 제어기법
GPG Study 4.3 카메라 제어기법GPG Study 4.3 카메라 제어기법
GPG Study 4.3 카메라 제어기법
 
使用管理科業務報告 1102
使用管理科業務報告 1102使用管理科業務報告 1102
使用管理科業務報告 1102
 
What the Bible Says About Profanity
What the Bible Says About ProfanityWhat the Bible Says About Profanity
What the Bible Says About Profanity
 
1001005科務報告
1001005科務報告1001005科務報告
1001005科務報告
 
100.8.17養護科科務報告
100.8.17養護科科務報告100.8.17養護科科務報告
100.8.17養護科科務報告
 
不違背職務行賄罪簡介100.08.26
不違背職務行賄罪簡介100.08.26不違背職務行賄罪簡介100.08.26
不違背職務行賄罪簡介100.08.26
 
第24局局務會議紀錄
第24局局務會議紀錄第24局局務會議紀錄
第24局局務會議紀錄
 
100.11.23養護科科務報告
100.11.23養護科科務報告100.11.23養護科科務報告
100.11.23養護科科務報告
 

Ähnlich wie Light in screen_space(Light Pre Pass)

D2 Depth of field
D2 Depth of fieldD2 Depth of field
D2 Depth of fieldYoupyo Choi
 
NDC11_슈퍼클래스
NDC11_슈퍼클래스NDC11_슈퍼클래스
NDC11_슈퍼클래스noerror
 
SGL : 소프트웨어 3D 렌더링 엔진
SGL : 소프트웨어 3D 렌더링 엔진SGL : 소프트웨어 3D 렌더링 엔진
SGL : 소프트웨어 3D 렌더링 엔진SUNGCHEOL KIM
 
Reflective Shadow Maps
Reflective Shadow MapsReflective Shadow Maps
Reflective Shadow MapsBongseok Cho
 
[ShaderX5] 4.4 Edge Masking and Per-Texel Depth Extent Propagation For Comput...
[ShaderX5] 4.4 Edge Masking and Per-Texel Depth Extent Propagation For Comput...[ShaderX5] 4.4 Edge Masking and Per-Texel Depth Extent Propagation For Comput...
[ShaderX5] 4.4 Edge Masking and Per-Texel Depth Extent Propagation For Comput...종빈 오
 
Screen space reflection
Screen space reflectionScreen space reflection
Screen space reflectionBongseok Cho
 
[shaderx6] 3.7 Robust Order-Independent Transparency via Reverse Depth Peelin...
[shaderx6] 3.7 Robust Order-Independent Transparency via Reverse Depth Peelin...[shaderx6] 3.7 Robust Order-Independent Transparency via Reverse Depth Peelin...
[shaderx6] 3.7 Robust Order-Independent Transparency via Reverse Depth Peelin...종빈 오
 
Pathfinding 관련 GPG스터디 발표
Pathfinding 관련 GPG스터디 발표Pathfinding 관련 GPG스터디 발표
Pathfinding 관련 GPG스터디 발표Frank Junghyun Kim
 
Modern gpu optimize blog
Modern gpu optimize blogModern gpu optimize blog
Modern gpu optimize blogozlael ozlael
 
헤테로지니어스 컴퓨팅 : CPU 에서 GPU 로 옮겨가기
헤테로지니어스 컴퓨팅 :  CPU 에서 GPU 로 옮겨가기헤테로지니어스 컴퓨팅 :  CPU 에서 GPU 로 옮겨가기
헤테로지니어스 컴퓨팅 : CPU 에서 GPU 로 옮겨가기zupet
 
KCGS11_실시간 피사계 심도 렌더링 개선 기법
KCGS11_실시간 피사계 심도 렌더링 개선 기법KCGS11_실시간 피사계 심도 렌더링 개선 기법
KCGS11_실시간 피사계 심도 렌더링 개선 기법noerror
 
[IGC2018] 퍼니파우 최재영 - 감성을 위한 개발요소
[IGC2018] 퍼니파우 최재영 - 감성을 위한 개발요소[IGC2018] 퍼니파우 최재영 - 감성을 위한 개발요소
[IGC2018] 퍼니파우 최재영 - 감성을 위한 개발요소강 민우
 
Rendering realistic Ice objects
Rendering realistic Ice objectsRendering realistic Ice objects
Rendering realistic Ice objectsyong gyun im
 
NDC11_김성익_슈퍼클래스
NDC11_김성익_슈퍼클래스NDC11_김성익_슈퍼클래스
NDC11_김성익_슈퍼클래스Sungik Kim
 

Ähnlich wie Light in screen_space(Light Pre Pass) (18)

D2 Depth of field
D2 Depth of fieldD2 Depth of field
D2 Depth of field
 
D2 Rain (1/2)
D2 Rain (1/2)D2 Rain (1/2)
D2 Rain (1/2)
 
NDC11_슈퍼클래스
NDC11_슈퍼클래스NDC11_슈퍼클래스
NDC11_슈퍼클래스
 
SGL : 소프트웨어 3D 렌더링 엔진
SGL : 소프트웨어 3D 렌더링 엔진SGL : 소프트웨어 3D 렌더링 엔진
SGL : 소프트웨어 3D 렌더링 엔진
 
Reflective Shadow Maps
Reflective Shadow MapsReflective Shadow Maps
Reflective Shadow Maps
 
[ShaderX5] 4.4 Edge Masking and Per-Texel Depth Extent Propagation For Comput...
[ShaderX5] 4.4 Edge Masking and Per-Texel Depth Extent Propagation For Comput...[ShaderX5] 4.4 Edge Masking and Per-Texel Depth Extent Propagation For Comput...
[ShaderX5] 4.4 Edge Masking and Per-Texel Depth Extent Propagation For Comput...
 
D2 Rain (2/2)
D2 Rain (2/2)D2 Rain (2/2)
D2 Rain (2/2)
 
Screen space reflection
Screen space reflectionScreen space reflection
Screen space reflection
 
[shaderx6] 3.7 Robust Order-Independent Transparency via Reverse Depth Peelin...
[shaderx6] 3.7 Robust Order-Independent Transparency via Reverse Depth Peelin...[shaderx6] 3.7 Robust Order-Independent Transparency via Reverse Depth Peelin...
[shaderx6] 3.7 Robust Order-Independent Transparency via Reverse Depth Peelin...
 
Pathfinding 관련 GPG스터디 발표
Pathfinding 관련 GPG스터디 발표Pathfinding 관련 GPG스터디 발표
Pathfinding 관련 GPG스터디 발표
 
Modern gpu optimize blog
Modern gpu optimize blogModern gpu optimize blog
Modern gpu optimize blog
 
Volumetric Fog
Volumetric FogVolumetric Fog
Volumetric Fog
 
3D Graphics 101
3D Graphics 1013D Graphics 101
3D Graphics 101
 
헤테로지니어스 컴퓨팅 : CPU 에서 GPU 로 옮겨가기
헤테로지니어스 컴퓨팅 :  CPU 에서 GPU 로 옮겨가기헤테로지니어스 컴퓨팅 :  CPU 에서 GPU 로 옮겨가기
헤테로지니어스 컴퓨팅 : CPU 에서 GPU 로 옮겨가기
 
KCGS11_실시간 피사계 심도 렌더링 개선 기법
KCGS11_실시간 피사계 심도 렌더링 개선 기법KCGS11_실시간 피사계 심도 렌더링 개선 기법
KCGS11_실시간 피사계 심도 렌더링 개선 기법
 
[IGC2018] 퍼니파우 최재영 - 감성을 위한 개발요소
[IGC2018] 퍼니파우 최재영 - 감성을 위한 개발요소[IGC2018] 퍼니파우 최재영 - 감성을 위한 개발요소
[IGC2018] 퍼니파우 최재영 - 감성을 위한 개발요소
 
Rendering realistic Ice objects
Rendering realistic Ice objectsRendering realistic Ice objects
Rendering realistic Ice objects
 
NDC11_김성익_슈퍼클래스
NDC11_김성익_슈퍼클래스NDC11_김성익_슈퍼클래스
NDC11_김성익_슈퍼클래스
 

Mehr von 민웅 이

Siggraph15 A Novel Sampling Algorithm for Fast and Stable Real-Time Volume Re...
Siggraph15 A Novel Sampling Algorithm for Fast and Stable Real-Time Volume Re...Siggraph15 A Novel Sampling Algorithm for Fast and Stable Real-Time Volume Re...
Siggraph15 A Novel Sampling Algorithm for Fast and Stable Real-Time Volume Re...민웅 이
 
PowerVR Low Level GLSL Optimisation
PowerVR Low Level GLSL Optimisation PowerVR Low Level GLSL Optimisation
PowerVR Low Level GLSL Optimisation 민웅 이
 
Compute shader DX11
Compute shader DX11Compute shader DX11
Compute shader DX11민웅 이
 
「스퀘어 에닉스 오픈 컨퍼런스 2012」「Agni's Philosophy」비하인드 스토리
「스퀘어 에닉스 오픈 컨퍼런스 2012」「Agni's Philosophy」비하인드 스토리「스퀘어 에닉스 오픈 컨퍼런스 2012」「Agni's Philosophy」비하인드 스토리
「스퀘어 에닉스 오픈 컨퍼런스 2012」「Agni's Philosophy」비하인드 스토리민웅 이
 
Valient killzone ps4 lighting
Valient killzone ps4 lightingValient killzone ps4 lighting
Valient killzone ps4 lighting민웅 이
 
Microfacet brdf
Microfacet brdfMicrofacet brdf
Microfacet brdf민웅 이
 
니시카와젠지의 3 d게임 팬을 위한「gravity daze」그래픽스 강좌
니시카와젠지의 3 d게임 팬을 위한「gravity daze」그래픽스 강좌니시카와젠지의 3 d게임 팬을 위한「gravity daze」그래픽스 강좌
니시카와젠지의 3 d게임 팬을 위한「gravity daze」그래픽스 강좌민웅 이
 
Wrapped diffuse
Wrapped diffuseWrapped diffuse
Wrapped diffuse민웅 이
 
3D Engine Tools with C++/CLR
3D Engine Tools with C++/CLR3D Engine Tools with C++/CLR
3D Engine Tools with C++/CLR민웅 이
 
Cheap realisticskinshading kor
Cheap realisticskinshading korCheap realisticskinshading kor
Cheap realisticskinshading kor민웅 이
 
Deferred decal
Deferred decalDeferred decal
Deferred decal민웅 이
 

Mehr von 민웅 이 (12)

Siggraph15 A Novel Sampling Algorithm for Fast and Stable Real-Time Volume Re...
Siggraph15 A Novel Sampling Algorithm for Fast and Stable Real-Time Volume Re...Siggraph15 A Novel Sampling Algorithm for Fast and Stable Real-Time Volume Re...
Siggraph15 A Novel Sampling Algorithm for Fast and Stable Real-Time Volume Re...
 
PowerVR Low Level GLSL Optimisation
PowerVR Low Level GLSL Optimisation PowerVR Low Level GLSL Optimisation
PowerVR Low Level GLSL Optimisation
 
Compute shader DX11
Compute shader DX11Compute shader DX11
Compute shader DX11
 
「스퀘어 에닉스 오픈 컨퍼런스 2012」「Agni's Philosophy」비하인드 스토리
「스퀘어 에닉스 오픈 컨퍼런스 2012」「Agni's Philosophy」비하인드 스토리「스퀘어 에닉스 오픈 컨퍼런스 2012」「Agni's Philosophy」비하인드 스토리
「스퀘어 에닉스 오픈 컨퍼런스 2012」「Agni's Philosophy」비하인드 스토리
 
Valient killzone ps4 lighting
Valient killzone ps4 lightingValient killzone ps4 lighting
Valient killzone ps4 lighting
 
Microfacet brdf
Microfacet brdfMicrofacet brdf
Microfacet brdf
 
니시카와젠지의 3 d게임 팬을 위한「gravity daze」그래픽스 강좌
니시카와젠지의 3 d게임 팬을 위한「gravity daze」그래픽스 강좌니시카와젠지의 3 d게임 팬을 위한「gravity daze」그래픽스 강좌
니시카와젠지의 3 d게임 팬을 위한「gravity daze」그래픽스 강좌
 
Wrapped diffuse
Wrapped diffuseWrapped diffuse
Wrapped diffuse
 
3D Engine Tools with C++/CLR
3D Engine Tools with C++/CLR3D Engine Tools with C++/CLR
3D Engine Tools with C++/CLR
 
Cheap realisticskinshading kor
Cheap realisticskinshading korCheap realisticskinshading kor
Cheap realisticskinshading kor
 
Ceh
CehCeh
Ceh
 
Deferred decal
Deferred decalDeferred decal
Deferred decal
 

Light in screen_space(Light Pre Pass)

  • 1. Lighting In Screen Space (Light Pre-Pass) 이민웅
  • 2. 차례  많은 광원을 그리는 방법들    Light Pre-Pass 소개 Light Pre-Pass 구현방법     Deferred Shading GBuffer Light Buffer 정리 질문
  • 3. 많은 광원을 그리는 방법들  Deferred Shading / Rendering   Z Pre Pass Rendering   John D. Carmack II, Doom3 Light Pre Pass   Saito & Takahashi 1990 Wolfgang Engel 2008 Inferred Lighting  SIGGRAPH2009 Scott Kircher,Alan Lawrance
  • 4. Z Pre Pass Rendering    존카멕이 처음 개발 Doom3 적용 Depth만을 가지고 Light계산
  • 5. Deferred Shading 굉장히 배치가 간단해지고, 엔진에서 관리가 쉽다  일반적인 그림자 테크닉들과 통합이 쉽다   라이팅을 위한 계산이 “완전한” O(1) 복잡도를 가진다.    오브젝트의 개수와 상관없다 Lighting 계산의 부하가 Scene의 복잡도에 독립적이다. 수많은 작은 동적 라이팅 사용이 가능하다 Killzone 2’s G-Buffer Layout (courtesy of Michal Valient)
  • 6. Deferred Shading  MRT를 이용한 랜더링 (Shader 3.0) Normals Specular Albedo / Shadow Depth Buffer Motion Vec Deferred Lighting Forward Rendering
  • 7. Deferred Shading 단점   투명 객체를 처리 못함 G-Buffer안에 Material Property들을 저장     G-Buffer의 공간은 매우 제한적 (최대 4장) 모든 Material들에 대해서 아주 유사한 Lighting 공식 이 사용되는 것을 요구 RenderTarget 4장사용으로 메모리양이 큼 Forward Rendering처럼 frame buffer에 직접 렌더링 할 때 자동으로 받는 하드웨어anti-aliasing이 불가능
  • 9. Light Pre-Pass  MRT의 지원이 없어도 구현이 가능   기본적으로 2Pass로 랜더링을 이용하기 때문에 하드 웨어 MSAA를 지원   반투명 오브젝트는 2Pass 때 랜더링 Render Target는 한장만 사용   Shader 2.0 환경에서 구현가능 (크게 의미는 없음) Deferred Shading 과 비교할때 메모리양이 적음 Material 구현에 관하여 더 유연성를 제공  2Pass 때 처리
  • 10. Light Pre-Pass 1Pass Normals Depth Buffer 투명 객체 Light Buffer Forward Rendering Forward Rendering 2Pass
  • 11. Light Pre-Pass 단점  Deferred Shading 의 경우, 랜더는 최저 1회로 끝    MRT를 사용해 G-Buffer 에 랜더 Light Pre-Pass 는 기본적으로 2Pass 랜더 여러 개의 light에 대해서 specular 항을 계산할 때의 문제점 (GameDev.net)  Specular값을 텍스쳐 한장으로 담아야 하기 때문에…
  • 12. Light Pre-Pass 적용 사례 S.T.A.L.K.E.R: Clear Skies
  • 13. Light Pre-Pass 적용 사례 BlurTM in-game screenshot
  • 14. Light Pre-Pass 적용 사례 UnchartedTM in-game screenshot
  • 15. Light Pre Pass 구현 방법
  • 16. G Buffer (1Pass)   Depth + Normal 추출 NORMAL압축하여 뽑음      Normal 압축함으로 퀄리티 향상도 할 수 있음 RG : normal B : Depth A : Alpha Test A16FR16FG16FB16 포멧 사용
  • 17. G Buffer (1Pass) Gbuffer_VS { float4 position = float4( vertex.position , 1.0f ); Out.PosClip = mul(position, WORLDVIEWPROJ); Out.PosView = mul(position, WORLDVIEW); float3 N = vertex.normal; float3 T = vertex.tangent.xyz; float3 B = cross(N,T) * vertex.tangent.w; Out.TangentToView1 = mul( T, (float3x3)WORLDVIEW ); Out.TangentToView2 = mul( B, (float3x3)WORLDVIEW ); Out.TangentToView3 = mul( N, (float3x3)WORLDVIEW ); }
  • 18. G Buffer (1Pass) Gbuffer_PS { float4 texcolor float depth = tex2D( diffuseSampler , Input.TexCoords.xy ); = Input.PosView.z / CAMERAFAR; float3 tangentSpaceNormal.xyz = tex2D( bumpSampler, Input.TexCoords.xy ).xyz * 2 - 1; float3x3 mtxRot; mtxRot[0] = normalize( Input.TangentToView1 ); mtxRot[1] = normalize( Input.TangentToView2 ); mtxRot[2] = normalize( Input.TangentToView3 ); tangentSpaceNormal = normalize( mul( tangentSpaceNormal, mtxRot ) ); float4 packColor = PackDepthNormal(depth, tangentSpaceNormal); packColor.a = texcolor.a; return packColor; }
  • 19. Compact Normal Storage  store X&Y, reconstruct Z half4 encode (half3 n, float3 view) { return half4(n.xy*0.5+0.5,0,0); } half3 decode (half2 enc, float3 view) { half3 n; n.xy = enc*2-1; n.z = sqrt(1-dot(n.xy, n.xy)); return n; } Compact Normal Storage for small G-Buffers http://aras-p.info/texts/CompactNormalStorage.html
  • 20. Compact Normal Storage  Spheremap Transform half2 encode (half3 n, float3 view) { half f = sqrt(8*n.z+8); return n.xy / f + 0.5; } half3 decode (half4 enc, float3 view) { half2 fenc = enc*4-2; half f = dot(fenc,fenc); half g = sqrt(1-f/4); half3 n; n.xy = fenc*g; n.z = 1-f/2; return n; } Compact Normal Storage for small G-Buffers http://aras-p.info/texts/CompactNormalStorage.html
  • 23. Light Buffer Pass    Screen Space에서 Gbuffer을 이용하여 Light를 계산 Light계산시 Light방향을 ViewSpace로 변환하여 계산 Depth로 위치를 뽑아서 Speculer을 계산    Point Light도 계산함 그림자도 Light계산시 같이 할 수 있음 A16FR16FG16FB16F 포멧으로 설정 Light buffer layout R : LightColor.r * N.L * Att G : LightColor.g * N.L * Att B : LightColor.b * N.L * Att A : R.V^n * N.L * Att (Speculer)
  • 24. Light Buffer Pass  라이트버퍼 계산시 머트리얼 계산법  미리 계산해 놓으면 2Pass 때 빠르게 랜더링 할수 있 음  머트리얼을 미리 계산할시 랜더타겟 한장이 더 필요
  • 25. Light Buffer Pass Speculer Color 있음 Speculer Color 없음 CryEngine 3
  • 26. 깊이 버퍼로부터 위치 계산 • • 픽셀의 실제 위치를 얻어낼 시 depth buffer를 이용하여 만듬 픽셀의 카메라 스페이스 상 위치를 얻어오는 일반적인 방법은 Inverse Projection matrix를 곱해주는 것  Depth 저장시 WVP 변환 결과의 z/w값을 기입 하는 것이 아니고 WV 변환 결과의 Z만 저장 하여 Linear한 것으로 만들어 줌      floating 포맷이 아니라면 Zfar로 나누면 될 듯 좌상,우상,좌하,우하의 far clip 방향 ray VS에 프러스텀의 정보를 넘겨줌 PS에서는 해당 좌표에 받은 ray(보간 되어 옴)정보를 기반으로 깊이와 곱하여 최종 위치를 구함 SSAO , Motion blur(depth based), DOF FrustumCorner = Vector3(0,0,Far) FrustumCorner.y = tan( FOV / 2 ) * Far FrustumCorner.x = FrustumCorner.y * Aspect
  • 27. Light Buffer Pass pos_vs { Out.Position = Input.Position; Out.TexCoords = Input.TexCoords.xy; Out.View = float3(FRUSTUMCORNER.x * Input.Position.x, FRUSTUMCORNER.y * Input.Position.y, FRUSTUMCORNER.z); } directional_ps { float fvDepth; float3 fvViewSpaceNormal; UnpackDepthNormal( normalDepthSampler , In.TexCoords, fvDepth, fvViewSpaceNormal ); float3 fvViewSpacePos = fvDepth * In.View; float diffuseLight = saturate( dot( fvViewSpaceNormal, DIRLIGHT) + AMBIENT; float3 eyeVec = -normalize( fvViewSpacePos ); float3 halfVec = normalize( eyeVec + DIRLIGHT ); float specular = pow( saturate( dot( fvViewSpaceNormal, halfVec) SHININESS ) return float4(diffuseLight , specular * NdotL); }
  • 30. 라이트의 퀄리티를 높혀보자(팁?)  Ambient Cube ( Valve‟s )      구현이 매우 간단함 적은 계산량으로 간접 조명을 보여줄 수 있음 각 점마다 6개의 irradiance 값을 미리 계산해서 배치  디자이너가 Cube의 6개 색을 미리 지정 주인공 캐릭터들은 가장 가까운 점을 얻어와서 간접조명(indirect illumination)으로 사용 Shading in Valve's Source Engine 참조 float3 AmbientLight( const float3 worldNormal ) { float3 nSquared = worldNormal * worldNormal; int3 isNegative = ( worldNormal < 0.0 ); float3 linearColor; linearColor = nSquared.x * cAmbientCube[isNegative.x] + nSquared.y * cAmbientCube[isNegative.y+2] + nSquared.z * cAmbientCube[isNegative.z+4]; return linearColor; }
  • 31. Light Buffer( Light + AmbientCube)
  • 32. Light Buffer( Light ) Ambient Cube 사용 Ambient만 사용
  • 33. 2Pass  Pass때 미리 찍어둔 ZBuffer를 이용하여 ZCull(EalryZ) 을 사용하여 랜더   z-culling은 깊이에 기반하여 미리 픽셀을 배제하는 것 Render depth only, 1Pass   Render with full shaders, 2Pass    Early-Z (and Z-Cull) ZWRITEENABLE = FALSE, ZFUNC = EQUAL Diffuse와 누적된 라이트텍스쳐를 계산   ZWRITEENABLE = TRUE, ZFUNC = LESSEQUAL Diffuse * LightBuffer 투명 객체 랜더
  • 34. Light Pre Pass 정리  Gbuffer Pass ( 1Pass )   Light Pass   Accumulate Light Info 2Pass   불투명 객체들에 대해서, view normal과 view depth 를 저 장 Diffuse * LightBuffer 투명 객체 랜더링
  • 36. 정리 수많은 동적 라이팅을 화면상의 오브젝트의 개수와 관 계없이 상수시간에 처리가 가능함 이론상 무한개의 동적 라이팅 사용 가능 어두운 실내나, 어두운 배경에 실시간 라이팅이 많은 경 우 최적의 해결 방법 현재의 그래픽 카드에서는 당연히 지원됨유명 상용 엔 진에서는 기본적으로 지원됨 직접 구현 해도, 개념이 어렵지 않고, 관리가 쉬움 셀프 셰도우등 그림자 기법이 용이함 포스트 프로세싱(DOF, SSAO, HDR등)을 사용시          G-Buffer 재사용 가능함 콘솔게임은 이미 많은 게임들이 사용되고 있음.
  • 37. References [Hargreaves] Shawn Hargreaves, “Deferred Shading”, http://www.talula.demon.co.uk/DeferredShading.pdf [Lobanchikov] Igor A. Lobanchikov, “ GSC Game World„s S.T.A.L.K.E.R : Clear Sky – a showcase for Direct3D 10.0/1”, http://developer.amd.com/gpu_assets/01GDC09AD3DDStalkerClearSky210309.ppt [Mittring] Martin Mittring, “A bit more Deferred – Cry Engine 3”, http://www.slideshare.net/guest11b095/a-bit-more-deferred-cryengine3 [Lee] Mark Lee, “Resistance 2 Prelighting”, http://www.insomniacgames.com/tech/articles/0409/files/GDC09_Lee_Prelighting.pdf [Lengyel] Eric Lengyel, “Advanced Light and Shadow Culling Methods”, http://www.terathon.com/lengyel/#slides [Placeres] Frank Puig Placeres, “Overcoming Deferred Shading Drawbacks,” pp. 115 – 130, ShaderX5 [Shishkovtsov] Oles Shishkovtsov, “Making some use out of hardware multisampling”; http://olesrants.blogspot.com/2008/08/making-some-use-out-of-hardware.html [Swoboda] Matt Swoboda, “Deferred Lighting and Post Processing on PLAYSTATION®3, http://research.scee.net/presentations [Tovey] Steven J. Tovey, Stephen McAuley, “Parallelized Light Pre-Pass Rendering with the Cell Broadband EngineTM”, to appear in GPU Pro [Thibieroz04] Nick Thibieroz, “Deferred Shading with Multiple-Render-Targets,” pp. 251 – 269, ShaderX2 [Thibieroz] Nick Thibieroz, “Deferred Shading with Multisampling Anti-Aliasing in DirectX 10” , ShaderX7 [Valient] Michael Valient, “Deferred Rendering in Killzone 2,” www.guerillagames.com/publications/dr_kz2_rsx_dev07.pdf [Wolfgang Engel] Wolfgang Engel, Light Pre-Pass Deferred Lighting: Latest Development- August 3rd, 2009 [김대일] 웹젠 Rendering C9 kgc2009 [이창희] Kasa Light-Pre-Pass 2009-07-04 [박민근] 네이버 초중급 게임 개발자 스터디 [데브루키] Deferred Shading (지연 세이딩) [오즈라엘님 블로그] http://ozlael.egloos.com/2374651 [오즈라엘님 블로그] http://ozlael.egloos.com/2876211 Z-culling http://codevania.springnote.com/pages/3936893.xhtml Compact Normal Storage for small G-Buffers http://aras-p.info/texts/CompactNormalStorage.html