SlideShare a Scribd company logo
1 of 10
Wrapped Diffuse
이민웅
Shader Study
Wrapped Diffuse
• 팀 포트리스 2에서 사용
• subsurface scattering, area light source,
더 부드러운 reflectance 를 표현하기 위해
서 Hemisphere(반구)를 감싸는 셰이딩 모
델

Lambert

Wrapped Diffuse
Wrapped Diffuse
• HarfLambert 공식과 비슷함
– W=1이면, Half Lambert 공식

• Half Lambert와 유사하게 투과되는 느낌을
표현하는데 많이 사용
– 피부, 나뭇잎, 파티클 라이팅에 주로 사용
기본 Lambert Diffuse 공식
float diffuse = max(0, dot(normal, lightdirection));
기본 HalfLambert Diffuse 공식
float halflambert_term = dot(normal, lightdirection) * 0.5f + 0.5f
Wrapped Diffuse 공식
float diffuse = saturate((dot(normal, lightdirection) + OFFSET) / (1.0+OFFSET ));
Wrapped Diffuse

Wrapped SH 자세한 내용
http://blog.selfshadow.com/2011/12/31/righting-wrap-part-1/
http://blog.selfshadow.com/2012/01/07/righting-wrap-part-2/

Wrap Shading
www.iro.umontreal.ca/~derek/files/jgt_wrap.pdf
Wrapped Diffuse
• 팀 포트리스 방식
– Wrapped Function은 Half Lambert를 이용해서,
1D Wrapped Diffuse Texture에서 값을 얻어오
는것
– GPU Gems 16. Real-Time Approximation to
Subsurface Scattering
• Wrap Lighting 계산 내용을 미리 Texture로 저장하
여 사용함
WarpTex
Lambert

Half Lambert

Warping Function

Squared Half Lambert (Not used)

illuminance( P, n, PI)
{
Ln = normalize(L);
halflambert += .5*(Ln.nf)+.5;
float chl = clamp(halflambert,0.01,1);
accumulateMapColor = texture(warp,chl,0)*2;
hlsw_clrlght += Cl*accumulateMapColor;
}
diffusecolor = albedocolor * (Ka + hlsw_clrlght);

Light Color

Ambient

Albedo

Ka : ambient
Cl : LightColor

http://www.sfdm.scad.edu/faculty/mkesson/vsfx419/wip/spring11/eric_kurzmack/toon.html
Specular Fresnel

Mixed Specular

Primary Specularity

Rim Fresnel

Upward Ambient Rim
Final Mix

http://www.sfdm.scad.edu/faculty/mkesson/vsfx419/wip/spring11/eric_kurzmack/toon.html

Rim Specular
Code
Specular Fresnel
vector i= normalize(-I);
float fres=spline((nf.i),1,1,1,.95,.6,.6);
Primary Specularity
illuminance( P, n, PI/2)
{
Ln = normalize(L);
vector R = reflect(-Ln,nf);
ridot += clamp(max(0,(R.i)),.01,.99);
phngspec += (1-fres)*pow(ridot,specE);
}

Mixed Specular
illuminance( P, n, PI/2)
{
Ln = normalize(L);
vector R = reflect(-Ln,nf);
vector R2 = reflect(Ln,nf);
ridot += clamp(max(0,(R.i)),.01,.99);
ridot2 += clamp(max(0,(R2.i)),.01,.99);
phngspec += (1-fres)*pow(ridot,specE);
phngrim += rimfres*pow(ridot2,Krim);
phngmix += Cl*Ks*(max(phngrim,phngspec)*2);
}
speccolor = phngmix;

Rim Fresnel
vector i= normalize(-I);
float rimfres=pow((1-(nf.i)),2);
vector i= normalize(-I);

Upward Ambient Rim
float upward = clamp((nf.vector(0,1,0)),0,1);
float uprim= upward*rimfres*Kr*(Ka*5);

Rim Specular
illuminance( P, n, PI/2)
{
Ln = normalize(L);
vector R2 = reflect(Ln,nf);
ridot2 += clamp(max(0,(R2.i)),.01,.99);
phngrim += rimfres*pow(ridot2,Krim);
}

Final Mix
Ci = Oi*(diffusecolor+speccolor+uprim);
Q&A
참고자료
• Wrap Shading :
http://www.iro.umontreal.ca/~derek/publication8.html
• Energy-Conserving Wrapped Diffuse
• Wrapped Diffuse와 팀포트리스 셰이딩 :
http://cagetu.egloos.com/5621806
• 팀포트리스 셰이딩 따라해보기 :
http://cagetu.egloos.com/4212681
• Energy Conservation in Games :
http://www.rorydriscoll.com/2009/01/25/energyconservation-in-games/
• http://www.gamedevforever.com/150
• http://cagetu.egloos.com/5621806

More Related Content

What's hot

Ndc2010 전형규 마비노기2 캐릭터 렌더링 기술
Ndc2010 전형규   마비노기2 캐릭터 렌더링 기술Ndc2010 전형규   마비노기2 캐릭터 렌더링 기술
Ndc2010 전형규 마비노기2 캐릭터 렌더링 기술
henjeon
 
Brdf기반 사전정의 스킨 셰이더
Brdf기반 사전정의 스킨 셰이더Brdf기반 사전정의 스킨 셰이더
Brdf기반 사전정의 스킨 셰이더
동석 김
 
07_PhysX 강체물리 입문
07_PhysX 강체물리 입문07_PhysX 강체물리 입문
07_PhysX 강체물리 입문
noerror
 
Hierachical z Map Occlusion Culling
Hierachical z Map Occlusion CullingHierachical z Map Occlusion Culling
Hierachical z Map Occlusion Culling
YEONG-CHEON YOU
 
김혁, <드래곤 하운드>의 PBR과 레이트레이싱 렌더링 기법, NDC2019
김혁, <드래곤 하운드>의 PBR과 레이트레이싱 렌더링 기법, NDC2019김혁, <드래곤 하운드>의 PBR과 레이트레이싱 렌더링 기법, NDC2019
김혁, <드래곤 하운드>의 PBR과 레이트레이싱 렌더링 기법, NDC2019
devCAT Studio, NEXON
 
Penner pre-integrated skin rendering (siggraph 2011 advances in real-time r...
Penner   pre-integrated skin rendering (siggraph 2011 advances in real-time r...Penner   pre-integrated skin rendering (siggraph 2011 advances in real-time r...
Penner pre-integrated skin rendering (siggraph 2011 advances in real-time r...
JP Lee
 
[1023 박민수] 깊이_버퍼_그림자_1
[1023 박민수] 깊이_버퍼_그림자_1[1023 박민수] 깊이_버퍼_그림자_1
[1023 박민수] 깊이_버퍼_그림자_1
MoonLightMS
 
[Ndc12] 누구나 알기쉬운 hdr과 톤맵핑 박민근
[Ndc12] 누구나 알기쉬운 hdr과 톤맵핑 박민근[Ndc12] 누구나 알기쉬운 hdr과 톤맵핑 박민근
[Ndc12] 누구나 알기쉬운 hdr과 톤맵핑 박민근
MinGeun Park
 

What's hot (20)

아티스트에게 사랑받는 3DS Max 우버쉐이더
아티스트에게 사랑받는 3DS Max 우버쉐이더아티스트에게 사랑받는 3DS Max 우버쉐이더
아티스트에게 사랑받는 3DS Max 우버쉐이더
 
물리 기반 셰이더의 허와 실:물리기반 셰이더를 가르쳐 봤습니다 공개용
물리 기반 셰이더의 허와 실:물리기반 셰이더를 가르쳐 봤습니다  공개용물리 기반 셰이더의 허와 실:물리기반 셰이더를 가르쳐 봤습니다  공개용
물리 기반 셰이더의 허와 실:물리기반 셰이더를 가르쳐 봤습니다 공개용
 
Ndc2010 전형규 마비노기2 캐릭터 렌더링 기술
Ndc2010 전형규   마비노기2 캐릭터 렌더링 기술Ndc2010 전형규   마비노기2 캐릭터 렌더링 기술
Ndc2010 전형규 마비노기2 캐릭터 렌더링 기술
 
카툰 렌더링
카툰 렌더링카툰 렌더링
카툰 렌더링
 
Ssao
SsaoSsao
Ssao
 
스크린 스페이스 데칼에 대해 자세히 알아보자(워햄머 40,000: 스페이스 마린)
스크린 스페이스 데칼에 대해 자세히 알아보자(워햄머 40,000: 스페이스 마린)스크린 스페이스 데칼에 대해 자세히 알아보자(워햄머 40,000: 스페이스 마린)
스크린 스페이스 데칼에 대해 자세히 알아보자(워햄머 40,000: 스페이스 마린)
 
Brdf기반 사전정의 스킨 셰이더
Brdf기반 사전정의 스킨 셰이더Brdf기반 사전정의 스킨 셰이더
Brdf기반 사전정의 스킨 셰이더
 
[NDC19] 모바일에서 사용가능한 유니티 커스텀 섭스턴스 PBR 셰이더 만들기
[NDC19] 모바일에서 사용가능한 유니티 커스텀 섭스턴스 PBR 셰이더 만들기[NDC19] 모바일에서 사용가능한 유니티 커스텀 섭스턴스 PBR 셰이더 만들기
[NDC19] 모바일에서 사용가능한 유니티 커스텀 섭스턴스 PBR 셰이더 만들기
 
2009-2016 기본기(손맵)의 중요성
2009-2016 기본기(손맵)의 중요성2009-2016 기본기(손맵)의 중요성
2009-2016 기본기(손맵)의 중요성
 
A Scalable Real-Time Many-Shadowed-Light Rendering System
A Scalable Real-Time Many-Shadowed-Light Rendering SystemA Scalable Real-Time Many-Shadowed-Light Rendering System
A Scalable Real-Time Many-Shadowed-Light Rendering System
 
감마가 어디감마
감마가 어디감마감마가 어디감마
감마가 어디감마
 
모바일 게임 최적화
모바일 게임 최적화 모바일 게임 최적화
모바일 게임 최적화
 
07_PhysX 강체물리 입문
07_PhysX 강체물리 입문07_PhysX 강체물리 입문
07_PhysX 강체물리 입문
 
Hierachical z Map Occlusion Culling
Hierachical z Map Occlusion CullingHierachical z Map Occlusion Culling
Hierachical z Map Occlusion Culling
 
김혁, <드래곤 하운드>의 PBR과 레이트레이싱 렌더링 기법, NDC2019
김혁, <드래곤 하운드>의 PBR과 레이트레이싱 렌더링 기법, NDC2019김혁, <드래곤 하운드>의 PBR과 레이트레이싱 렌더링 기법, NDC2019
김혁, <드래곤 하운드>의 PBR과 레이트레이싱 렌더링 기법, NDC2019
 
Penner pre-integrated skin rendering (siggraph 2011 advances in real-time r...
Penner   pre-integrated skin rendering (siggraph 2011 advances in real-time r...Penner   pre-integrated skin rendering (siggraph 2011 advances in real-time r...
Penner pre-integrated skin rendering (siggraph 2011 advances in real-time r...
 
D2 Hdr
D2 HdrD2 Hdr
D2 Hdr
 
[1023 박민수] 깊이_버퍼_그림자_1
[1023 박민수] 깊이_버퍼_그림자_1[1023 박민수] 깊이_버퍼_그림자_1
[1023 박민수] 깊이_버퍼_그림자_1
 
Calibrating Lighting and Materials in Far Cry 3
Calibrating Lighting and Materials in Far Cry 3Calibrating Lighting and Materials in Far Cry 3
Calibrating Lighting and Materials in Far Cry 3
 
[Ndc12] 누구나 알기쉬운 hdr과 톤맵핑 박민근
[Ndc12] 누구나 알기쉬운 hdr과 톤맵핑 박민근[Ndc12] 누구나 알기쉬운 hdr과 톤맵핑 박민근
[Ndc12] 누구나 알기쉬운 hdr과 톤맵핑 박민근
 

Viewers also liked

параллельная загрузка Java script и css файлов без прерывания
параллельная загрузка Java script и css файлов без прерыванияпараллельная загрузка Java script и css файлов без прерывания
параллельная загрузка Java script и css файлов без прерывания
Alexey Vidanov
 
Internet decency legislation
Internet decency legislationInternet decency legislation
Internet decency legislation
Tgarmon34
 
Advert Pitch
Advert PitchAdvert Pitch
Advert Pitch
jbier
 
A오즈 트위터 캐릭터소개 0701
A오즈 트위터 캐릭터소개 0701A오즈 트위터 캐릭터소개 0701
A오즈 트위터 캐릭터소개 0701
애니파크
 
Value proposition for social media marketing
Value proposition for social media marketingValue proposition for social media marketing
Value proposition for social media marketing
Pavan Krishnaa Mulpur
 

Viewers also liked (20)

International education program_guide_201164284 (3)
International education program_guide_201164284 (3)International education program_guide_201164284 (3)
International education program_guide_201164284 (3)
 
Reviscopa núm.26 Escola Jaume Balmes
Reviscopa núm.26  Escola Jaume BalmesReviscopa núm.26  Escola Jaume Balmes
Reviscopa núm.26 Escola Jaume Balmes
 
параллельная загрузка Java script и css файлов без прерывания
параллельная загрузка Java script и css файлов без прерыванияпараллельная загрузка Java script и css файлов без прерывания
параллельная загрузка Java script и css файлов без прерывания
 
NTU & NTUST Tangible Interaction Design Project Proposal Final
NTU & NTUST Tangible Interaction Design Project Proposal FinalNTU & NTUST Tangible Interaction Design Project Proposal Final
NTU & NTUST Tangible Interaction Design Project Proposal Final
 
Internet decency legislation
Internet decency legislationInternet decency legislation
Internet decency legislation
 
Human Computer Interaction Presentation
Human Computer Interaction PresentationHuman Computer Interaction Presentation
Human Computer Interaction Presentation
 
Reviscopa Núm.13
Reviscopa Núm.13Reviscopa Núm.13
Reviscopa Núm.13
 
Linkedin Company Page Guide
Linkedin Company Page GuideLinkedin Company Page Guide
Linkedin Company Page Guide
 
Reviscopa núm.21 Escola Jaume Balmes
Reviscopa núm.21  Escola Jaume BalmesReviscopa núm.21  Escola Jaume Balmes
Reviscopa núm.21 Escola Jaume Balmes
 
Info 1 teorica color
Info 1   teorica colorInfo 1   teorica color
Info 1 teorica color
 
NTU & NTUST Tangible Interaction Design Project Proposal 3
NTU & NTUST Tangible Interaction Design Project Proposal 3NTU & NTUST Tangible Interaction Design Project Proposal 3
NTU & NTUST Tangible Interaction Design Project Proposal 3
 
Advert Pitch
Advert PitchAdvert Pitch
Advert Pitch
 
A오즈 트위터 캐릭터소개 0701
A오즈 트위터 캐릭터소개 0701A오즈 트위터 캐릭터소개 0701
A오즈 트위터 캐릭터소개 0701
 
Why does God allow Bad things to happen to Good people?
Why does God allow Bad things to happen to Good people?Why does God allow Bad things to happen to Good people?
Why does God allow Bad things to happen to Good people?
 
Deloitte Private Club/Aamplify Archetypes Presentation
Deloitte Private Club/Aamplify Archetypes PresentationDeloitte Private Club/Aamplify Archetypes Presentation
Deloitte Private Club/Aamplify Archetypes Presentation
 
Value proposition for social media marketing
Value proposition for social media marketingValue proposition for social media marketing
Value proposition for social media marketing
 
Can You Lose Your Salvation?
Can You Lose Your Salvation?Can You Lose Your Salvation?
Can You Lose Your Salvation?
 
Spiritual WARfare vs Spiritual WELfare
Spiritual WARfare vs Spiritual WELfareSpiritual WARfare vs Spiritual WELfare
Spiritual WARfare vs Spiritual WELfare
 
#magneticarchetypes
#magneticarchetypes#magneticarchetypes
#magneticarchetypes
 
Pull Test Presentation
Pull Test PresentationPull Test Presentation
Pull Test Presentation
 

More from 민웅 이

니시카와젠지의 3 d 게임 팬을 위한 ps4
니시카와젠지의 3 d 게임 팬을 위한 ps4니시카와젠지의 3 d 게임 팬을 위한 ps4
니시카와젠지의 3 d 게임 팬을 위한 ps4
민웅 이
 
Microfacet brdf
Microfacet brdfMicrofacet brdf
Microfacet brdf
민웅 이
 
니시카와젠지의 3 d게임 팬을 위한「gravity daze」그래픽스 강좌
니시카와젠지의 3 d게임 팬을 위한「gravity daze」그래픽스 강좌니시카와젠지의 3 d게임 팬을 위한「gravity daze」그래픽스 강좌
니시카와젠지의 3 d게임 팬을 위한「gravity daze」그래픽스 강좌
민웅 이
 

More from 민웅 이 (17)

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
 
제노블레이도 2 ray marching을사용한 구름 표현
제노블레이도 2 ray marching을사용한 구름 표현제노블레이도 2 ray marching을사용한 구름 표현
제노블레이도 2 ray marching을사용한 구름 표현
 
자동 동적 3차원 입체시각
자동 동적 3차원 입체시각자동 동적 3차원 입체시각
자동 동적 3차원 입체시각
 
Post processing in_color
Post processing in_colorPost processing in_color
Post processing in_color
 
「스퀘어 에닉스 오픈 컨퍼런스 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
 
크게, 아름답게,빠르게, 일관되게 만들기: Just Cause 2 개발에서 배운 교훈들 (GPU Pro)
크게, 아름답게,빠르게, 일관되게 만들기: Just Cause 2 개발에서 배운 교훈들 (GPU Pro)크게, 아름답게,빠르게, 일관되게 만들기: Just Cause 2 개발에서 배운 교훈들 (GPU Pro)
크게, 아름답게,빠르게, 일관되게 만들기: Just Cause 2 개발에서 배운 교훈들 (GPU Pro)
 
니시카와젠지의 3 d 게임 팬을 위한 ps4
니시카와젠지의 3 d 게임 팬을 위한 ps4니시카와젠지의 3 d 게임 팬을 위한 ps4
니시카와젠지의 3 d 게임 팬을 위한 ps4
 
Microfacet brdf
Microfacet brdfMicrofacet brdf
Microfacet brdf
 
니시카와젠지의 3 d게임 팬을 위한「gravity daze」그래픽스 강좌
니시카와젠지의 3 d게임 팬을 위한「gravity daze」그래픽스 강좌니시카와젠지의 3 d게임 팬을 위한「gravity daze」그래픽스 강좌
니시카와젠지의 3 d게임 팬을 위한「gravity daze」그래픽스 강좌
 
3D Engine Tools with C++/CLR
3D Engine Tools with C++/CLR3D Engine Tools with C++/CLR
3D Engine Tools with C++/CLR
 
Light in screen_space(Light Pre Pass)
Light in screen_space(Light Pre Pass)Light in screen_space(Light Pre Pass)
Light in screen_space(Light Pre Pass)
 
Gamma and linear color-space
Gamma and linear color-spaceGamma and linear color-space
Gamma and linear color-space
 
Cheap realisticskinshading kor
Cheap realisticskinshading korCheap realisticskinshading kor
Cheap realisticskinshading kor
 
Ceh
CehCeh
Ceh
 
Deferred decal
Deferred decalDeferred decal
Deferred decal
 

Wrapped diffuse

  • 2. Wrapped Diffuse • 팀 포트리스 2에서 사용 • subsurface scattering, area light source, 더 부드러운 reflectance 를 표현하기 위해 서 Hemisphere(반구)를 감싸는 셰이딩 모 델 Lambert Wrapped Diffuse
  • 3. Wrapped Diffuse • HarfLambert 공식과 비슷함 – W=1이면, Half Lambert 공식 • Half Lambert와 유사하게 투과되는 느낌을 표현하는데 많이 사용 – 피부, 나뭇잎, 파티클 라이팅에 주로 사용 기본 Lambert Diffuse 공식 float diffuse = max(0, dot(normal, lightdirection)); 기본 HalfLambert Diffuse 공식 float halflambert_term = dot(normal, lightdirection) * 0.5f + 0.5f Wrapped Diffuse 공식 float diffuse = saturate((dot(normal, lightdirection) + OFFSET) / (1.0+OFFSET ));
  • 4. Wrapped Diffuse Wrapped SH 자세한 내용 http://blog.selfshadow.com/2011/12/31/righting-wrap-part-1/ http://blog.selfshadow.com/2012/01/07/righting-wrap-part-2/ Wrap Shading www.iro.umontreal.ca/~derek/files/jgt_wrap.pdf
  • 5. Wrapped Diffuse • 팀 포트리스 방식 – Wrapped Function은 Half Lambert를 이용해서, 1D Wrapped Diffuse Texture에서 값을 얻어오 는것 – GPU Gems 16. Real-Time Approximation to Subsurface Scattering • Wrap Lighting 계산 내용을 미리 Texture로 저장하 여 사용함
  • 6. WarpTex Lambert Half Lambert Warping Function Squared Half Lambert (Not used) illuminance( P, n, PI) { Ln = normalize(L); halflambert += .5*(Ln.nf)+.5; float chl = clamp(halflambert,0.01,1); accumulateMapColor = texture(warp,chl,0)*2; hlsw_clrlght += Cl*accumulateMapColor; } diffusecolor = albedocolor * (Ka + hlsw_clrlght); Light Color Ambient Albedo Ka : ambient Cl : LightColor http://www.sfdm.scad.edu/faculty/mkesson/vsfx419/wip/spring11/eric_kurzmack/toon.html
  • 7. Specular Fresnel Mixed Specular Primary Specularity Rim Fresnel Upward Ambient Rim Final Mix http://www.sfdm.scad.edu/faculty/mkesson/vsfx419/wip/spring11/eric_kurzmack/toon.html Rim Specular
  • 8. Code Specular Fresnel vector i= normalize(-I); float fres=spline((nf.i),1,1,1,.95,.6,.6); Primary Specularity illuminance( P, n, PI/2) { Ln = normalize(L); vector R = reflect(-Ln,nf); ridot += clamp(max(0,(R.i)),.01,.99); phngspec += (1-fres)*pow(ridot,specE); } Mixed Specular illuminance( P, n, PI/2) { Ln = normalize(L); vector R = reflect(-Ln,nf); vector R2 = reflect(Ln,nf); ridot += clamp(max(0,(R.i)),.01,.99); ridot2 += clamp(max(0,(R2.i)),.01,.99); phngspec += (1-fres)*pow(ridot,specE); phngrim += rimfres*pow(ridot2,Krim); phngmix += Cl*Ks*(max(phngrim,phngspec)*2); } speccolor = phngmix; Rim Fresnel vector i= normalize(-I); float rimfres=pow((1-(nf.i)),2); vector i= normalize(-I); Upward Ambient Rim float upward = clamp((nf.vector(0,1,0)),0,1); float uprim= upward*rimfres*Kr*(Ka*5); Rim Specular illuminance( P, n, PI/2) { Ln = normalize(L); vector R2 = reflect(Ln,nf); ridot2 += clamp(max(0,(R2.i)),.01,.99); phngrim += rimfres*pow(ridot2,Krim); } Final Mix Ci = Oi*(diffusecolor+speccolor+uprim);
  • 9. Q&A
  • 10. 참고자료 • Wrap Shading : http://www.iro.umontreal.ca/~derek/publication8.html • Energy-Conserving Wrapped Diffuse • Wrapped Diffuse와 팀포트리스 셰이딩 : http://cagetu.egloos.com/5621806 • 팀포트리스 셰이딩 따라해보기 : http://cagetu.egloos.com/4212681 • Energy Conservation in Games : http://www.rorydriscoll.com/2009/01/25/energyconservation-in-games/ • http://www.gamedevforever.com/150 • http://cagetu.egloos.com/5621806