SlideShare une entreprise Scribd logo
1  sur  25
Télécharger pour lire hors ligne
shaderX7 4.1

      Practical
Cascaded Shadow Maps
    http://cafe.naver.com/shader.cafe
                http://ohyecloudy.com
                            2010.01.25
CSM
Overview
• CSM 기본 구현에 대핚 내용이 아니다.

• 실무에 적용할 때, 생기는 문제들 해결
  방법을 알려주는 글.
flickering of shadow quality
storage strategy
non-optimized split selection
correct computation of texture
  coordinates
filter across splits
• 그림자 품질이 다음 프레임에 급격히 변핚다.
• light, viewer 위치가 변하면 발생.
Exact Solution




• split을 감싸는 bounding sphere 사용
  – shadow map size가 stable
  – scale, offset 문제 해결
// step   1 : calculate the light basis
vector3   direction = normalize(WORLD.getColumn3(2));
vector3   side = normalize(WORLD.getColumn3(1));
vector3   up = normalize(WORLD.getColumn3(0));

// update all splits
for (int i = 0; i < numSplits; i++)
{
   // Step 2 : Calculate the bounding sphere “bs” of each split

    // Step 3 : update the split-specific view matrix
    // ‘matrixView[i]’ and projection matrix ‘matrixProjections[i]’
}
// step 1 : calculate the light basis
direction, side, up

// update all splits
for (int i = 0; i < numSplits; i++)
{
   // Step 2 : Calculate the bounding sphere “bs” of each split
   Sphere bs = CalculateBoundingSphere(split[i]);
   vector3 center = INVWORLDVIEW * bs.getCenter();
   float radius = bs.getRadius();

    // adjust the sphere’s center to make sure it is transformed
    into the center of the shadow map
    float x = ceilf(dot(center,up)*sizeSM/radius)*radius/sizeSM;
    float y = ceilf(dot(center,side)*sizeSM/radius)*radius/sizeSM;
    center = up*x + side*y + direction * dot(center, direction);

    // Step 3 : update the split-specific view matrix
    // ‘matrixView[i]’ and projection matrix ‘matrixProjections[i]’
}
// step 1 : calculate the light basis
direction, side, up

// update all splits
for (int i = 0; i < numSplits; i++)
{
   // Step 2 : Calculate the bounding sphere “bs” of each split

    // Step 3 : update the split-specific view matrix
    // ‘matrixView[i]’ and projection matrix ‘matrixProjections[i]’
    matrixProjections[i]
         = MatrixOrthoProjection(
                -radius, radius, radius, -radius, near, far);
    vector3 origin = center – direction * far;
    matrixView[i] = MatrixLookAt(origin, center, up);
}
Approximated Solution




• sphere를 사용하니 그림자 텍스쳐 낭비 심함.
 – bounding-box 사용.
 – scale, offset 직접 계산.
 – 구한 scale, offset을 여러 프레임에 걸쳐 부드럽게
   보간.
// calculate scale values
float scaleX = 2.0f / (maxX – minX);
float scaleY = 2.0f / (maxY – minY);

// the scale values will be quantized into 64 discrete levels
float scaleQuantizer = 64.0f;

// quantize scale
scaleX = scaleQuantizer / ceilf(scaleQuantizer / scaleX);
scaleY = scaleQuantizer / ceilf(scaleQuantizer / scaleY);

// calculate offset values

                                              scaleQuantizer 
        scaleX  0, scaleQuantizer  0, ceil                  1
                                                  scaleX     
                                               scaleQuantizer
                        scaleQuantizer                            0
                                                 scaleQuantizer 
                                           ceil                 
                                                     scaleX     
// calculate scale values

// calculate offset values
float offsetX = -0.5f * (maxX + minX) * scaleX;
float offsetY = -0.5f * (maxY + minY) * scaleY;

// quantize offset
float halfTextureSize = 0.5f * sizeSM;
offsetX = ceilf(offsetX * halfTextureSize) / halfTextureSize;
offsetY = ceilf(offsetY * halfTextureSize) / halfTextureSize;
flickering of shadow quality
storage strategy
non-optimized split selection
correct computation of texture
  coordinates
filter across splits
• Texture arrays
  – Direct3D 10.1 이상
• Cube maps
  – 항상 6개 shadow map 텍스쳐
• Multiple textures
  – CSM 마다 텍스쳐 핚 장씩.
• Texture atlas
flickering of shadow quality
storage strategy
non-optimized split selection
correct computation of texture
  coordinates
filter across splits
• fragment P
  – Z 값을 따지면 split-1
  – X,Y 값을 따지면 split-0
  – 품질을 극대화 하려면 split-0를 사용하는 게 맞다.
float shadow = 0.0;

// get the potential texture coordinates in the first shadow map
float4 texcoord = mul(matrixWorld2Texture[0], PS_Input.world_position);

// projective coordinates
texcoord.xyz = texcoord.xyz / texcoord.w;

// 1st SM x,y:[0,0.5]
if (max(abs(texcoord.x – 0.25), abs(texcoord.y – 0.25)) >= 0.25)
{
   texcoord = mul(matrixWorld2Texture[1], PS_Input.world_position);
   texcoord.xyz = texcoord.xyz / texcoord.w;
   // 2nd SM, x:[0,0.5], y:[0.5,1]
   if(max(abs(texcoord.x – 0.25), abs(texcoord.y – 0.75)) >= 0.25)
   {
         shadow = 1.0;
   }
}

if (shadow != 1.0)
{
   shadow = tex2D(samplerAtlas, texcoord);
}
flickering of shadow quality
storage strategy
non-optimized split selection
correct computation of texture
 coordinates
filter across splits
기존 방법
• Vertex Shader
  – split 번호를 판단 X.
  – 가능핚 모든 정보를 PS에 넘긴다.


• Pixel Shader
  – split 번호를 계산.
  – 해당하는 shadow maps에서 depth 샘플링.
struct VS_OUTPUT
{
   float4 position : POSITION;
   float4 tex0 : TEXCOORD0; // CSM0
   float4 tex1 : TEXCOORD0; // CSM1
   float4 tex2 : TEXCOORD0; // CSM2
}

// VS
float4 posWorldSpace = mul(VSInput.position, WORLD);
VSOutput.position = mul(posWorldSpace, matrixViewProj);
VSOutput.tex0 = mul(posWorldSpace, matrixTexture[0]);
VSOutput.tex1 = mul(posWorldSpace, matrixTexture[1]);
VSOutput.tex2 = mul(posWorldSpace, matrixTexture[2]);

// PS
float shadow;
int split = .....;
if (split < 1)
   shadow = tex2DProj(samplerCSM0, PSInput.tex0);
else if (split < 2)
...
개선된 방법
• Vertex Shader
  – split 번호를 판단 X
  – 월드 좌표를 PS에 넘겨준다.

• Pixel Shader
  – split 번호를 계산
  – world  texcoord 트랜스폼
  – 해당하는 shadow maps에서 depth 샘플링.

• 수학적으로 틀렸으나 빠르고 눈에 띄는 artifacts X
struct VS_OUTPUT
{
   float4 position : POSITION;
   float4 tex0 : TEXCOORD0;
}

// VS
VSOutput.position = mul(VSInput.position, WORLDVIEWPROJ);
VSOutput.tex0 = mul(VSInput.position, WORLD);

// PS
float shadow;
float4 texCoords;
int split = ...;
if (split < 1)
{
   texCoords = mul(PSInput.tex0, matrixWorld2Texture[split]);
   shadow = tex2DProj(samplerCSM0, texCoords);
}
else if (split < 2)
...

Contenu connexe

Tendances

Paris Master Class 2011 - 03 Order Independent Transparency
Paris Master Class 2011 - 03 Order Independent TransparencyParis Master Class 2011 - 03 Order Independent Transparency
Paris Master Class 2011 - 03 Order Independent TransparencyWolfgang Engel
 
[shaderx5] 4.2 Multisampling Extension for Gradient Shadow Maps
[shaderx5] 4.2 Multisampling Extension for Gradient Shadow Maps[shaderx5] 4.2 Multisampling Extension for Gradient Shadow Maps
[shaderx5] 4.2 Multisampling Extension for Gradient Shadow Maps종빈 오
 
Interactive Refractions And Caustics Using Image Space Techniques
Interactive Refractions And Caustics Using Image Space TechniquesInteractive Refractions And Caustics Using Image Space Techniques
Interactive Refractions And Caustics Using Image Space Techniquescodevania
 
Implementing a modern, RenderMan compliant, REYES renderer
Implementing a modern, RenderMan compliant, REYES rendererImplementing a modern, RenderMan compliant, REYES renderer
Implementing a modern, RenderMan compliant, REYES rendererDavide Pasca
 
Crysis Next-Gen Effects (GDC 2008)
Crysis Next-Gen Effects (GDC 2008)Crysis Next-Gen Effects (GDC 2008)
Crysis Next-Gen Effects (GDC 2008)Tiago Sousa
 
SPU Assisted Rendering
SPU Assisted RenderingSPU Assisted Rendering
SPU Assisted RenderingSteven Tovey
 
Java3 d 1
Java3 d 1Java3 d 1
Java3 d 1Por Non
 
Five Rendering Ideas from Battlefield 3 & Need For Speed: The Run
Five Rendering Ideas from Battlefield 3 & Need For Speed: The RunFive Rendering Ideas from Battlefield 3 & Need For Speed: The Run
Five Rendering Ideas from Battlefield 3 & Need For Speed: The RunElectronic Arts / DICE
 
30th コンピュータビジョン勉強会@関東 DynamicFusion
30th コンピュータビジョン勉強会@関東 DynamicFusion30th コンピュータビジョン勉強会@関東 DynamicFusion
30th コンピュータビジョン勉強会@関東 DynamicFusionHiroki Mizuno
 
Volumetric Lighting for Many Lights in Lords of the Fallen
Volumetric Lighting for Many Lights in Lords of the FallenVolumetric Lighting for Many Lights in Lords of the Fallen
Volumetric Lighting for Many Lights in Lords of the FallenBenjamin Glatzel
 
Introduction to Global Illumination by Aryo
Introduction to Global Illumination by AryoIntroduction to Global Illumination by Aryo
Introduction to Global Illumination by AryoAgate Studio
 
Z Buffer Optimizations
Z Buffer OptimizationsZ Buffer Optimizations
Z Buffer Optimizationspjcozzi
 
Secrets of CryENGINE 3 Graphics Technology
Secrets of CryENGINE 3 Graphics TechnologySecrets of CryENGINE 3 Graphics Technology
Secrets of CryENGINE 3 Graphics TechnologyTiago Sousa
 
Advancements in-tiled-rendering
Advancements in-tiled-renderingAdvancements in-tiled-rendering
Advancements in-tiled-renderingmistercteam
 
Cascades Demo Secrets
Cascades Demo SecretsCascades Demo Secrets
Cascades Demo Secretsicastano
 
CG OpenGL surface detection+illumination+rendering models-course 9
CG OpenGL surface detection+illumination+rendering models-course 9CG OpenGL surface detection+illumination+rendering models-course 9
CG OpenGL surface detection+illumination+rendering models-course 9fungfung Chen
 
Siggraph2016 - The Devil is in the Details: idTech 666
Siggraph2016 - The Devil is in the Details: idTech 666Siggraph2016 - The Devil is in the Details: idTech 666
Siggraph2016 - The Devil is in the Details: idTech 666Tiago Sousa
 

Tendances (20)

Reyes
ReyesReyes
Reyes
 
Paris Master Class 2011 - 03 Order Independent Transparency
Paris Master Class 2011 - 03 Order Independent TransparencyParis Master Class 2011 - 03 Order Independent Transparency
Paris Master Class 2011 - 03 Order Independent Transparency
 
[shaderx5] 4.2 Multisampling Extension for Gradient Shadow Maps
[shaderx5] 4.2 Multisampling Extension for Gradient Shadow Maps[shaderx5] 4.2 Multisampling Extension for Gradient Shadow Maps
[shaderx5] 4.2 Multisampling Extension for Gradient Shadow Maps
 
Interactive Refractions And Caustics Using Image Space Techniques
Interactive Refractions And Caustics Using Image Space TechniquesInteractive Refractions And Caustics Using Image Space Techniques
Interactive Refractions And Caustics Using Image Space Techniques
 
Implementing a modern, RenderMan compliant, REYES renderer
Implementing a modern, RenderMan compliant, REYES rendererImplementing a modern, RenderMan compliant, REYES renderer
Implementing a modern, RenderMan compliant, REYES renderer
 
Crysis Next-Gen Effects (GDC 2008)
Crysis Next-Gen Effects (GDC 2008)Crysis Next-Gen Effects (GDC 2008)
Crysis Next-Gen Effects (GDC 2008)
 
SPU Assisted Rendering
SPU Assisted RenderingSPU Assisted Rendering
SPU Assisted Rendering
 
Java3 d 1
Java3 d 1Java3 d 1
Java3 d 1
 
Five Rendering Ideas from Battlefield 3 & Need For Speed: The Run
Five Rendering Ideas from Battlefield 3 & Need For Speed: The RunFive Rendering Ideas from Battlefield 3 & Need For Speed: The Run
Five Rendering Ideas from Battlefield 3 & Need For Speed: The Run
 
30th コンピュータビジョン勉強会@関東 DynamicFusion
30th コンピュータビジョン勉強会@関東 DynamicFusion30th コンピュータビジョン勉強会@関東 DynamicFusion
30th コンピュータビジョン勉強会@関東 DynamicFusion
 
Volumetric Lighting for Many Lights in Lords of the Fallen
Volumetric Lighting for Many Lights in Lords of the FallenVolumetric Lighting for Many Lights in Lords of the Fallen
Volumetric Lighting for Many Lights in Lords of the Fallen
 
Global illumination
Global illuminationGlobal illumination
Global illumination
 
Introduction to Global Illumination by Aryo
Introduction to Global Illumination by AryoIntroduction to Global Illumination by Aryo
Introduction to Global Illumination by Aryo
 
Z Buffer Optimizations
Z Buffer OptimizationsZ Buffer Optimizations
Z Buffer Optimizations
 
Games 3 dl4-example
Games 3 dl4-exampleGames 3 dl4-example
Games 3 dl4-example
 
Secrets of CryENGINE 3 Graphics Technology
Secrets of CryENGINE 3 Graphics TechnologySecrets of CryENGINE 3 Graphics Technology
Secrets of CryENGINE 3 Graphics Technology
 
Advancements in-tiled-rendering
Advancements in-tiled-renderingAdvancements in-tiled-rendering
Advancements in-tiled-rendering
 
Cascades Demo Secrets
Cascades Demo SecretsCascades Demo Secrets
Cascades Demo Secrets
 
CG OpenGL surface detection+illumination+rendering models-course 9
CG OpenGL surface detection+illumination+rendering models-course 9CG OpenGL surface detection+illumination+rendering models-course 9
CG OpenGL surface detection+illumination+rendering models-course 9
 
Siggraph2016 - The Devil is in the Details: idTech 666
Siggraph2016 - The Devil is in the Details: idTech 666Siggraph2016 - The Devil is in the Details: idTech 666
Siggraph2016 - The Devil is in the Details: idTech 666
 

Similaire à [shaderx7] 4.1 Practical Cascaded Shadow Maps

I need help with this assignment Ive gotten abit stuck with the cod.pdf
I need help with this assignment Ive gotten abit stuck with the cod.pdfI need help with this assignment Ive gotten abit stuck with the cod.pdf
I need help with this assignment Ive gotten abit stuck with the cod.pdfConint29
 
05 Geographic scripting in uDig - halfway between user and developer
05 Geographic scripting in uDig - halfway between user and developer05 Geographic scripting in uDig - halfway between user and developer
05 Geographic scripting in uDig - halfway between user and developerAndrea Antonello
 
The Day You Finally Use Algebra: A 3D Math Primer
The Day You Finally Use Algebra: A 3D Math PrimerThe Day You Finally Use Algebra: A 3D Math Primer
The Day You Finally Use Algebra: A 3D Math PrimerJanie Clayton
 
Caret Package for R
Caret Package for RCaret Package for R
Caret Package for Rkmettler
 
Caret max kuhn
Caret max kuhnCaret max kuhn
Caret max kuhnkmettler
 
openFrameworks 007 - 3D
openFrameworks 007 - 3DopenFrameworks 007 - 3D
openFrameworks 007 - 3Droxlu
 
Exploring Canvas
Exploring CanvasExploring Canvas
Exploring CanvasKevin Hoyt
 
Im looking for coding help I dont really need this to be explained.pdf
Im looking for coding help I dont really need this to be explained.pdfIm looking for coding help I dont really need this to be explained.pdf
Im looking for coding help I dont really need this to be explained.pdfcontact41
 
maXbox starter67 machine learning V
maXbox starter67 machine learning VmaXbox starter67 machine learning V
maXbox starter67 machine learning VMax Kleiner
 
The Technology behind Shadow Warrior, ZTG 2014
The Technology behind Shadow Warrior, ZTG 2014The Technology behind Shadow Warrior, ZTG 2014
The Technology behind Shadow Warrior, ZTG 2014Jarosław Pleskot
 
Adobe AIR: Stage3D and AGAL
Adobe AIR: Stage3D and AGALAdobe AIR: Stage3D and AGAL
Adobe AIR: Stage3D and AGALDaniel Freeman
 
Trident International Graphics Workshop 2014 2/5
Trident International Graphics Workshop 2014 2/5Trident International Graphics Workshop 2014 2/5
Trident International Graphics Workshop 2014 2/5Takao Wada
 
3Dtexture_doc_rep
3Dtexture_doc_rep3Dtexture_doc_rep
3Dtexture_doc_repLiu Zhen-Yu
 
Exploring Canvas
Exploring CanvasExploring Canvas
Exploring CanvasKevin Hoyt
 
Graphics Programming for Web Developers
Graphics Programming for Web DevelopersGraphics Programming for Web Developers
Graphics Programming for Web DevelopersJarrod Overson
 
properties, application and issues of support vector machine
properties, application and issues of support vector machineproperties, application and issues of support vector machine
properties, application and issues of support vector machineDr. Radhey Shyam
 

Similaire à [shaderx7] 4.1 Practical Cascaded Shadow Maps (20)

HTML5 Canvas
HTML5 CanvasHTML5 Canvas
HTML5 Canvas
 
I need help with this assignment Ive gotten abit stuck with the cod.pdf
I need help with this assignment Ive gotten abit stuck with the cod.pdfI need help with this assignment Ive gotten abit stuck with the cod.pdf
I need help with this assignment Ive gotten abit stuck with the cod.pdf
 
05 Geographic scripting in uDig - halfway between user and developer
05 Geographic scripting in uDig - halfway between user and developer05 Geographic scripting in uDig - halfway between user and developer
05 Geographic scripting in uDig - halfway between user and developer
 
The Day You Finally Use Algebra: A 3D Math Primer
The Day You Finally Use Algebra: A 3D Math PrimerThe Day You Finally Use Algebra: A 3D Math Primer
The Day You Finally Use Algebra: A 3D Math Primer
 
Caret Package for R
Caret Package for RCaret Package for R
Caret Package for R
 
Caret max kuhn
Caret max kuhnCaret max kuhn
Caret max kuhn
 
openFrameworks 007 - 3D
openFrameworks 007 - 3DopenFrameworks 007 - 3D
openFrameworks 007 - 3D
 
Feature Extraction
Feature ExtractionFeature Extraction
Feature Extraction
 
Exploring Canvas
Exploring CanvasExploring Canvas
Exploring Canvas
 
Im looking for coding help I dont really need this to be explained.pdf
Im looking for coding help I dont really need this to be explained.pdfIm looking for coding help I dont really need this to be explained.pdf
Im looking for coding help I dont really need this to be explained.pdf
 
maXbox starter67 machine learning V
maXbox starter67 machine learning VmaXbox starter67 machine learning V
maXbox starter67 machine learning V
 
The Technology behind Shadow Warrior, ZTG 2014
The Technology behind Shadow Warrior, ZTG 2014The Technology behind Shadow Warrior, ZTG 2014
The Technology behind Shadow Warrior, ZTG 2014
 
Adobe AIR: Stage3D and AGAL
Adobe AIR: Stage3D and AGALAdobe AIR: Stage3D and AGAL
Adobe AIR: Stage3D and AGAL
 
Trident International Graphics Workshop 2014 2/5
Trident International Graphics Workshop 2014 2/5Trident International Graphics Workshop 2014 2/5
Trident International Graphics Workshop 2014 2/5
 
3Dtexture_doc_rep
3Dtexture_doc_rep3Dtexture_doc_rep
3Dtexture_doc_rep
 
Lec2
Lec2Lec2
Lec2
 
Exploring Canvas
Exploring CanvasExploring Canvas
Exploring Canvas
 
Css5 canvas
Css5 canvasCss5 canvas
Css5 canvas
 
Graphics Programming for Web Developers
Graphics Programming for Web DevelopersGraphics Programming for Web Developers
Graphics Programming for Web Developers
 
properties, application and issues of support vector machine
properties, application and issues of support vector machineproperties, application and issues of support vector machine
properties, application and issues of support vector machine
 

Plus de 종빈 오

트위터 봇 개발 후기
트위터 봇 개발 후기트위터 봇 개발 후기
트위터 봇 개발 후기종빈 오
 
적당한 스터디 발표자료 만들기 2.0
적당한 스터디 발표자료 만들기 2.0적당한 스터디 발표자료 만들기 2.0
적당한 스터디 발표자료 만들기 2.0종빈 오
 
페리 수열(Farey sequence)
페리 수열(Farey sequence)페리 수열(Farey sequence)
페리 수열(Farey sequence)종빈 오
 
내가 본 미드 이야기
내가 본 미드 이야기내가 본 미드 이야기
내가 본 미드 이야기종빈 오
 
비트 경제와 공짜
비트 경제와 공짜비트 경제와 공짜
비트 경제와 공짜종빈 오
 
[NDC12] 게임 물리 엔진의 내부 동작 원리 이해
[NDC12] 게임 물리 엔진의 내부 동작 원리 이해[NDC12] 게임 물리 엔진의 내부 동작 원리 이해
[NDC12] 게임 물리 엔진의 내부 동작 원리 이해종빈 오
 
[Windows via c/c++] 4장 프로세스
[Windows via c/c++] 4장 프로세스[Windows via c/c++] 4장 프로세스
[Windows via c/c++] 4장 프로세스종빈 오
 
Intrusive data structure 소개
Intrusive data structure 소개Intrusive data structure 소개
Intrusive data structure 소개종빈 오
 
2011 아꿈사 오전반 포스트모템
2011 아꿈사 오전반 포스트모템2011 아꿈사 오전반 포스트모템
2011 아꿈사 오전반 포스트모템종빈 오
 
[프로젝트가 서쪽으로 간 까닭은] chap 17, 18, 26, 33, 81
[프로젝트가 서쪽으로 간 까닭은] chap 17, 18, 26, 33, 81[프로젝트가 서쪽으로 간 까닭은] chap 17, 18, 26, 33, 81
[프로젝트가 서쪽으로 간 까닭은] chap 17, 18, 26, 33, 81종빈 오
 
[GEG1] 3.volumetric representation of virtual environments
[GEG1] 3.volumetric representation of virtual environments[GEG1] 3.volumetric representation of virtual environments
[GEG1] 3.volumetric representation of virtual environments종빈 오
 
넘쳐나는 정보 소화 노하우
넘쳐나는 정보 소화 노하우넘쳐나는 정보 소화 노하우
넘쳐나는 정보 소화 노하우종빈 오
 
[Domain driven design] 17장 전략의 종합
[Domain driven design] 17장 전략의 종합[Domain driven design] 17장 전략의 종합
[Domain driven design] 17장 전략의 종합종빈 오
 
LevelDB 간단한 소개
LevelDB 간단한 소개LevelDB 간단한 소개
LevelDB 간단한 소개종빈 오
 
[GEG1] 2.the game asset pipeline
[GEG1] 2.the game asset pipeline[GEG1] 2.the game asset pipeline
[GEG1] 2.the game asset pipeline종빈 오
 
[TAOCP] 2.5 동적인 저장소 할당
[TAOCP] 2.5 동적인 저장소 할당[TAOCP] 2.5 동적인 저장소 할당
[TAOCP] 2.5 동적인 저장소 할당종빈 오
 
[GEG1] 24. key value dictionary
[GEG1] 24. key value dictionary[GEG1] 24. key value dictionary
[GEG1] 24. key value dictionary종빈 오
 
[TAOCP] 2.2.3 연결된 할당 - 위상정렬
[TAOCP] 2.2.3 연결된 할당 - 위상정렬[TAOCP] 2.2.3 연결된 할당 - 위상정렬
[TAOCP] 2.2.3 연결된 할당 - 위상정렬종빈 오
 
[TAOCP] 1.3.1 MIX 설명
[TAOCP] 1.3.1 MIX 설명[TAOCP] 1.3.1 MIX 설명
[TAOCP] 1.3.1 MIX 설명종빈 오
 
[GEG1] 10.camera-centric engine design for multithreaded rendering
[GEG1] 10.camera-centric engine design for multithreaded rendering[GEG1] 10.camera-centric engine design for multithreaded rendering
[GEG1] 10.camera-centric engine design for multithreaded rendering종빈 오
 

Plus de 종빈 오 (20)

트위터 봇 개발 후기
트위터 봇 개발 후기트위터 봇 개발 후기
트위터 봇 개발 후기
 
적당한 스터디 발표자료 만들기 2.0
적당한 스터디 발표자료 만들기 2.0적당한 스터디 발표자료 만들기 2.0
적당한 스터디 발표자료 만들기 2.0
 
페리 수열(Farey sequence)
페리 수열(Farey sequence)페리 수열(Farey sequence)
페리 수열(Farey sequence)
 
내가 본 미드 이야기
내가 본 미드 이야기내가 본 미드 이야기
내가 본 미드 이야기
 
비트 경제와 공짜
비트 경제와 공짜비트 경제와 공짜
비트 경제와 공짜
 
[NDC12] 게임 물리 엔진의 내부 동작 원리 이해
[NDC12] 게임 물리 엔진의 내부 동작 원리 이해[NDC12] 게임 물리 엔진의 내부 동작 원리 이해
[NDC12] 게임 물리 엔진의 내부 동작 원리 이해
 
[Windows via c/c++] 4장 프로세스
[Windows via c/c++] 4장 프로세스[Windows via c/c++] 4장 프로세스
[Windows via c/c++] 4장 프로세스
 
Intrusive data structure 소개
Intrusive data structure 소개Intrusive data structure 소개
Intrusive data structure 소개
 
2011 아꿈사 오전반 포스트모템
2011 아꿈사 오전반 포스트모템2011 아꿈사 오전반 포스트모템
2011 아꿈사 오전반 포스트모템
 
[프로젝트가 서쪽으로 간 까닭은] chap 17, 18, 26, 33, 81
[프로젝트가 서쪽으로 간 까닭은] chap 17, 18, 26, 33, 81[프로젝트가 서쪽으로 간 까닭은] chap 17, 18, 26, 33, 81
[프로젝트가 서쪽으로 간 까닭은] chap 17, 18, 26, 33, 81
 
[GEG1] 3.volumetric representation of virtual environments
[GEG1] 3.volumetric representation of virtual environments[GEG1] 3.volumetric representation of virtual environments
[GEG1] 3.volumetric representation of virtual environments
 
넘쳐나는 정보 소화 노하우
넘쳐나는 정보 소화 노하우넘쳐나는 정보 소화 노하우
넘쳐나는 정보 소화 노하우
 
[Domain driven design] 17장 전략의 종합
[Domain driven design] 17장 전략의 종합[Domain driven design] 17장 전략의 종합
[Domain driven design] 17장 전략의 종합
 
LevelDB 간단한 소개
LevelDB 간단한 소개LevelDB 간단한 소개
LevelDB 간단한 소개
 
[GEG1] 2.the game asset pipeline
[GEG1] 2.the game asset pipeline[GEG1] 2.the game asset pipeline
[GEG1] 2.the game asset pipeline
 
[TAOCP] 2.5 동적인 저장소 할당
[TAOCP] 2.5 동적인 저장소 할당[TAOCP] 2.5 동적인 저장소 할당
[TAOCP] 2.5 동적인 저장소 할당
 
[GEG1] 24. key value dictionary
[GEG1] 24. key value dictionary[GEG1] 24. key value dictionary
[GEG1] 24. key value dictionary
 
[TAOCP] 2.2.3 연결된 할당 - 위상정렬
[TAOCP] 2.2.3 연결된 할당 - 위상정렬[TAOCP] 2.2.3 연결된 할당 - 위상정렬
[TAOCP] 2.2.3 연결된 할당 - 위상정렬
 
[TAOCP] 1.3.1 MIX 설명
[TAOCP] 1.3.1 MIX 설명[TAOCP] 1.3.1 MIX 설명
[TAOCP] 1.3.1 MIX 설명
 
[GEG1] 10.camera-centric engine design for multithreaded rendering
[GEG1] 10.camera-centric engine design for multithreaded rendering[GEG1] 10.camera-centric engine design for multithreaded rendering
[GEG1] 10.camera-centric engine design for multithreaded rendering
 

Dernier

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 

Dernier (20)

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

[shaderx7] 4.1 Practical Cascaded Shadow Maps

  • 1. shaderX7 4.1 Practical Cascaded Shadow Maps http://cafe.naver.com/shader.cafe http://ohyecloudy.com 2010.01.25
  • 2. CSM
  • 3. Overview • CSM 기본 구현에 대핚 내용이 아니다. • 실무에 적용할 때, 생기는 문제들 해결 방법을 알려주는 글.
  • 4. flickering of shadow quality storage strategy non-optimized split selection correct computation of texture coordinates filter across splits
  • 5. • 그림자 품질이 다음 프레임에 급격히 변핚다. • light, viewer 위치가 변하면 발생.
  • 6.
  • 7. Exact Solution • split을 감싸는 bounding sphere 사용 – shadow map size가 stable – scale, offset 문제 해결
  • 8. // step 1 : calculate the light basis vector3 direction = normalize(WORLD.getColumn3(2)); vector3 side = normalize(WORLD.getColumn3(1)); vector3 up = normalize(WORLD.getColumn3(0)); // update all splits for (int i = 0; i < numSplits; i++) { // Step 2 : Calculate the bounding sphere “bs” of each split // Step 3 : update the split-specific view matrix // ‘matrixView[i]’ and projection matrix ‘matrixProjections[i]’ }
  • 9. // step 1 : calculate the light basis direction, side, up // update all splits for (int i = 0; i < numSplits; i++) { // Step 2 : Calculate the bounding sphere “bs” of each split Sphere bs = CalculateBoundingSphere(split[i]); vector3 center = INVWORLDVIEW * bs.getCenter(); float radius = bs.getRadius(); // adjust the sphere’s center to make sure it is transformed into the center of the shadow map float x = ceilf(dot(center,up)*sizeSM/radius)*radius/sizeSM; float y = ceilf(dot(center,side)*sizeSM/radius)*radius/sizeSM; center = up*x + side*y + direction * dot(center, direction); // Step 3 : update the split-specific view matrix // ‘matrixView[i]’ and projection matrix ‘matrixProjections[i]’ }
  • 10. // step 1 : calculate the light basis direction, side, up // update all splits for (int i = 0; i < numSplits; i++) { // Step 2 : Calculate the bounding sphere “bs” of each split // Step 3 : update the split-specific view matrix // ‘matrixView[i]’ and projection matrix ‘matrixProjections[i]’ matrixProjections[i] = MatrixOrthoProjection( -radius, radius, radius, -radius, near, far); vector3 origin = center – direction * far; matrixView[i] = MatrixLookAt(origin, center, up); }
  • 11.
  • 12. Approximated Solution • sphere를 사용하니 그림자 텍스쳐 낭비 심함. – bounding-box 사용. – scale, offset 직접 계산. – 구한 scale, offset을 여러 프레임에 걸쳐 부드럽게 보간.
  • 13. // calculate scale values float scaleX = 2.0f / (maxX – minX); float scaleY = 2.0f / (maxY – minY); // the scale values will be quantized into 64 discrete levels float scaleQuantizer = 64.0f; // quantize scale scaleX = scaleQuantizer / ceilf(scaleQuantizer / scaleX); scaleY = scaleQuantizer / ceilf(scaleQuantizer / scaleY); // calculate offset values  scaleQuantizer  scaleX  0, scaleQuantizer  0, ceil   1  scaleX  scaleQuantizer scaleQuantizer  0  scaleQuantizer  ceil    scaleX 
  • 14. // calculate scale values // calculate offset values float offsetX = -0.5f * (maxX + minX) * scaleX; float offsetY = -0.5f * (maxY + minY) * scaleY; // quantize offset float halfTextureSize = 0.5f * sizeSM; offsetX = ceilf(offsetX * halfTextureSize) / halfTextureSize; offsetY = ceilf(offsetY * halfTextureSize) / halfTextureSize;
  • 15. flickering of shadow quality storage strategy non-optimized split selection correct computation of texture coordinates filter across splits
  • 16. • Texture arrays – Direct3D 10.1 이상 • Cube maps – 항상 6개 shadow map 텍스쳐 • Multiple textures – CSM 마다 텍스쳐 핚 장씩. • Texture atlas
  • 17. flickering of shadow quality storage strategy non-optimized split selection correct computation of texture coordinates filter across splits
  • 18. • fragment P – Z 값을 따지면 split-1 – X,Y 값을 따지면 split-0 – 품질을 극대화 하려면 split-0를 사용하는 게 맞다.
  • 19. float shadow = 0.0; // get the potential texture coordinates in the first shadow map float4 texcoord = mul(matrixWorld2Texture[0], PS_Input.world_position); // projective coordinates texcoord.xyz = texcoord.xyz / texcoord.w; // 1st SM x,y:[0,0.5] if (max(abs(texcoord.x – 0.25), abs(texcoord.y – 0.25)) >= 0.25) { texcoord = mul(matrixWorld2Texture[1], PS_Input.world_position); texcoord.xyz = texcoord.xyz / texcoord.w; // 2nd SM, x:[0,0.5], y:[0.5,1] if(max(abs(texcoord.x – 0.25), abs(texcoord.y – 0.75)) >= 0.25) { shadow = 1.0; } } if (shadow != 1.0) { shadow = tex2D(samplerAtlas, texcoord); }
  • 20.
  • 21. flickering of shadow quality storage strategy non-optimized split selection correct computation of texture coordinates filter across splits
  • 22. 기존 방법 • Vertex Shader – split 번호를 판단 X. – 가능핚 모든 정보를 PS에 넘긴다. • Pixel Shader – split 번호를 계산. – 해당하는 shadow maps에서 depth 샘플링.
  • 23. struct VS_OUTPUT { float4 position : POSITION; float4 tex0 : TEXCOORD0; // CSM0 float4 tex1 : TEXCOORD0; // CSM1 float4 tex2 : TEXCOORD0; // CSM2 } // VS float4 posWorldSpace = mul(VSInput.position, WORLD); VSOutput.position = mul(posWorldSpace, matrixViewProj); VSOutput.tex0 = mul(posWorldSpace, matrixTexture[0]); VSOutput.tex1 = mul(posWorldSpace, matrixTexture[1]); VSOutput.tex2 = mul(posWorldSpace, matrixTexture[2]); // PS float shadow; int split = .....; if (split < 1) shadow = tex2DProj(samplerCSM0, PSInput.tex0); else if (split < 2) ...
  • 24. 개선된 방법 • Vertex Shader – split 번호를 판단 X – 월드 좌표를 PS에 넘겨준다. • Pixel Shader – split 번호를 계산 – world  texcoord 트랜스폼 – 해당하는 shadow maps에서 depth 샘플링. • 수학적으로 틀렸으나 빠르고 눈에 띄는 artifacts X
  • 25. struct VS_OUTPUT { float4 position : POSITION; float4 tex0 : TEXCOORD0; } // VS VSOutput.position = mul(VSInput.position, WORLDVIEWPROJ); VSOutput.tex0 = mul(VSInput.position, WORLD); // PS float shadow; float4 texCoords; int split = ...; if (split < 1) { texCoords = mul(PSInput.tex0, matrixWorld2Texture[split]); shadow = tex2DProj(samplerCSM0, texCoords); } else if (split < 2) ...