SlideShare a Scribd company logo
Depth of Field

    김정희
    최유표
Table of Contents
• DOF?

• Our DOF

• QnA
DOF
• Depth Of Field (피사계심도)
  – 렌즈로 피사체를 바라보면 그 앞/뒤에 초점이 맞는데 그 범위를
    이르는 말


• Circle Of Confusion (착란원)
  – 점모양의 물체가 초점이 맞지 않는 위치에 있으면, 이 물체는 둥
    그런 반점 모양으로 보이는데 이를 COC라고 한다.


• Focal Length (초점거리)
  – 렌즈의 초점거리.
DOF




v


      In computer graphics, we typically project onto our virtual film
      using an idealized pinhole camera that has a lens of zero size,
      so there is only a single path for light to travel from the scene
      to the film. So to achieve the depth-of-field effect, we must
      approximate the blur that would otherwise happen with a
      real lens.
                                                        – GPU Gems1
DOF
D2
• ATI Sample 참고
  – MipMap과 MSAA를 사용하여 DOF
  – 장점
    • Source가 매우 Simple!
    • MipMap 생성에 HW 및 DX API 이용
    • Blur Pass를 절약
  – 단점
    • MipMap 생성을 제어할 수 없다.
    • 이 Sample에서 쓰인 MSAA는 DX10 전용
D2
• Flow
  … 생략…
  Device.CreateTexture(width, height,
     Usage.RenderTarget | Usage.AutoGenerateMipMap,
     format,
     Pool.Default);
  … 생략


  RenderRepository.cs

  … 생략…
  PostProcessing()
     {
        … 생략…
        PostProcessing.TextureHandle.DxTexture.GenerateMipSubLevels();
     }

  BeginViewPort();
       Dof();
  EndViewPort();
D2
float4 DefaultPS( OUTPUT_VS In ) : COLOR
{
                                                                             * Uniform 상수
     float lodLevel = GetLod(In.tex);
                                                                             maxLevel = 2.5f
     float3 deferredRgb = GetLodColor(In.tex, lodLevel);
                                                                             distance = 100
     return float4(deferredRgb,1);
}

float GetLod(float2 tex)
{
      float viewZ = tex2D(depthSampler, tex).a; // MRT1번
      float blur = abs(viewZ - dofZ); // 렌더링 물체의 viewZ와 Focal Plane의 viewZ (= 카메라와 캐릭터의 거리)
      return maxLevel * saturate(blur / distance);
}

float3 GetLodColor(float2 tex, float lod)
{
      return tex2Dlod(ldSampler, float4(tex, 0, lod)).rgb; // PostProcessing, MotionBlur까지 끝낸 Texture
}
D2
• Artifact
  – MipLevel이 커질수록 Aliasing 발생
  – MipLevel이 차이나는 곳에서 Aliasing 발생


• 원인
  – MipMap에서 이미 Blurring 되었기 때문에
D2
D2



Level0                         Level1




         0   0
         1   0
                      Screen
D2
• Solution
  – MipMap을 자동생성하지 않고 깊이를 비교하
    여 생성 (귀찮음 적용하지 않음)
  – Sampling 할 때 인접 픽셀들과 평균
  – 인접픽셀은 대각선 방향의 4개 픽셀을 사용
    • Aliasing은 대각선에만 발생되기 때문에 상하좌우
      보다 대각선방향의 픽셀을 가져오는 것이 효과적
      인 것 같다!
D2
float4 DefaultPS( OUTPUT_VS In ) : COLOR
{
    float lodLevel = GetLod(In.tex);
    float3 deferredRgb = GetLodColor(In.tex, lodLevel);

    // 좌상, 우상, 우하, 좌하 + 중앙
    float p = lodLevel * 2;
    float offsetA = offsetAB.xy * p;
    float offsetB = offsetAB.zw * p;
    deferredRgb += GetLodColor(In.tex+offsetA, lodLevel);
    deferredRgb += GetLodColor(In.tex-offsetA, lodLevel);
    deferredRgb += GetLodColor(In.tex+offsetB, lodLevel);
    deferredRgb += GetLodColor(In.tex-offsetB, lodLevel);
    deferredRgb /= 5;
    return float4(deferredRgb,1);
}
D2
D2
QnA
• Future Work
  – 없어

More Related Content

PPTX
D2 Rain (2/2)
PDF
[ShaderX5] 4.4 Edge Masking and Per-Texel Depth Extent Propagation For Comput...
PPTX
Post processing in_color
PPTX
[14.10.21] Far Cry and DX9 번역(shaderstudy)
PPTX
실전프로젝트 정서경 양현찬
PPTX
Light in screen_space(Light Pre Pass)
PDF
Deferred Shading
PDF
[GEG1] 3.volumetric representation of virtual environments
D2 Rain (2/2)
[ShaderX5] 4.4 Edge Masking and Per-Texel Depth Extent Propagation For Comput...
Post processing in_color
[14.10.21] Far Cry and DX9 번역(shaderstudy)
실전프로젝트 정서경 양현찬
Light in screen_space(Light Pre Pass)
Deferred Shading
[GEG1] 3.volumetric representation of virtual environments

What's hot (19)

PPTX
게임에서 사용할 수 있는 포물선 운동
PPT
Rendering realistic Ice objects
PDF
Unity Surface Shader for Artist 02
PDF
Unity Surface Shader for Artist 04
PPTX
[데브루키] FOG
PDF
Unity Surface Shader for Artist 03
PPT
1.4.4 입력과 출력
PPT
D2 Havok
PPTX
Doing math with python.ch05
PPTX
Doing mathwithpython.ch02
PDF
밑바닥부터시작하는딥러닝 Ch05
PDF
[Swift] Higher order function
PDF
Week9 quicksort
PPTX
Convolutional neural networks
PDF
딥러닝 제대로시작하기 Ch04
PDF
[ES6] 5. Destructuring
PDF
밑바닥부터시작하는딥러닝 Ch05
PDF
Effective c++ item27
게임에서 사용할 수 있는 포물선 운동
Rendering realistic Ice objects
Unity Surface Shader for Artist 02
Unity Surface Shader for Artist 04
[데브루키] FOG
Unity Surface Shader for Artist 03
1.4.4 입력과 출력
D2 Havok
Doing math with python.ch05
Doing mathwithpython.ch02
밑바닥부터시작하는딥러닝 Ch05
[Swift] Higher order function
Week9 quicksort
Convolutional neural networks
딥러닝 제대로시작하기 Ch04
[ES6] 5. Destructuring
밑바닥부터시작하는딥러닝 Ch05
Effective c++ item27
Ad

Viewers also liked (6)

PPT
GPU Gems3 Vegetation
PDF
D2 Rain (1/2)
DOC
D2 Job Pool
PDF
D2 Horizon Occlusion
PPTX
D2 Hdr
PPTX
How to Write the Fastest JSON Parser/Writer in the World
GPU Gems3 Vegetation
D2 Rain (1/2)
D2 Job Pool
D2 Horizon Occlusion
D2 Hdr
How to Write the Fastest JSON Parser/Writer in the World
Ad

Similar to D2 Depth of field (20)

PPTX
크게, 아름답게,빠르게, 일관되게 만들기: Just Cause 2 개발에서 배운 교훈들 (GPU Pro)
PDF
[GPU Gems3] Chapter 28. Practical Post Process Depth Of Field
PDF
DOF Depth of Field
PPTX
9_혼합_DirectX 11을 이용한 3D 게임 프로그래밍 입문
PDF
Ndc11 이창희_hdr
PPTX
Graphics 8장 텍스처 적용.pptx
PDF
NDC2016 프로젝트 A1의 AAA급 캐릭터 렌더링 기술
PPTX
게임 개발을 위한 렌더링 기법 한성환
PDF
Motion blur
PDF
[Shader study] Color control (2014.05.12)
PDF
[Shader study] the rendering technology of lords of the fallen - 발표메모(14.06.23)
PPT
3D 기술 세미나2주차
PPTX
2018.02.03 이미지 텍스처링
PDF
Game Visual Art Technologies
PPTX
[0312 조진현] good bye dx9
PDF
Kgc make stereo game on pc
PDF
Modern gpu optimize
PDF
Modern gpu optimize blog
PPTX
I phone3d programming - Chap04:깊이와 현실감 향상시키기
PPTX
니시카와젠지의 3 d게임 팬을 위한「gravity daze」그래픽스 강좌
크게, 아름답게,빠르게, 일관되게 만들기: Just Cause 2 개발에서 배운 교훈들 (GPU Pro)
[GPU Gems3] Chapter 28. Practical Post Process Depth Of Field
DOF Depth of Field
9_혼합_DirectX 11을 이용한 3D 게임 프로그래밍 입문
Ndc11 이창희_hdr
Graphics 8장 텍스처 적용.pptx
NDC2016 프로젝트 A1의 AAA급 캐릭터 렌더링 기술
게임 개발을 위한 렌더링 기법 한성환
Motion blur
[Shader study] Color control (2014.05.12)
[Shader study] the rendering technology of lords of the fallen - 발표메모(14.06.23)
3D 기술 세미나2주차
2018.02.03 이미지 텍스처링
Game Visual Art Technologies
[0312 조진현] good bye dx9
Kgc make stereo game on pc
Modern gpu optimize
Modern gpu optimize blog
I phone3d programming - Chap04:깊이와 현실감 향상시키기
니시카와젠지의 3 d게임 팬을 위한「gravity daze」그래픽스 강좌

D2 Depth of field

  • 1. Depth of Field 김정희 최유표
  • 2. Table of Contents • DOF? • Our DOF • QnA
  • 3. DOF • Depth Of Field (피사계심도) – 렌즈로 피사체를 바라보면 그 앞/뒤에 초점이 맞는데 그 범위를 이르는 말 • Circle Of Confusion (착란원) – 점모양의 물체가 초점이 맞지 않는 위치에 있으면, 이 물체는 둥 그런 반점 모양으로 보이는데 이를 COC라고 한다. • Focal Length (초점거리) – 렌즈의 초점거리.
  • 4. DOF v In computer graphics, we typically project onto our virtual film using an idealized pinhole camera that has a lens of zero size, so there is only a single path for light to travel from the scene to the film. So to achieve the depth-of-field effect, we must approximate the blur that would otherwise happen with a real lens. – GPU Gems1
  • 5. DOF
  • 6. D2 • ATI Sample 참고 – MipMap과 MSAA를 사용하여 DOF – 장점 • Source가 매우 Simple! • MipMap 생성에 HW 및 DX API 이용 • Blur Pass를 절약 – 단점 • MipMap 생성을 제어할 수 없다. • 이 Sample에서 쓰인 MSAA는 DX10 전용
  • 7. D2 • Flow … 생략… Device.CreateTexture(width, height, Usage.RenderTarget | Usage.AutoGenerateMipMap, format, Pool.Default); … 생략 RenderRepository.cs … 생략… PostProcessing() { … 생략… PostProcessing.TextureHandle.DxTexture.GenerateMipSubLevels(); } BeginViewPort(); Dof(); EndViewPort();
  • 8. D2 float4 DefaultPS( OUTPUT_VS In ) : COLOR { * Uniform 상수 float lodLevel = GetLod(In.tex); maxLevel = 2.5f float3 deferredRgb = GetLodColor(In.tex, lodLevel); distance = 100 return float4(deferredRgb,1); } float GetLod(float2 tex) { float viewZ = tex2D(depthSampler, tex).a; // MRT1번 float blur = abs(viewZ - dofZ); // 렌더링 물체의 viewZ와 Focal Plane의 viewZ (= 카메라와 캐릭터의 거리) return maxLevel * saturate(blur / distance); } float3 GetLodColor(float2 tex, float lod) { return tex2Dlod(ldSampler, float4(tex, 0, lod)).rgb; // PostProcessing, MotionBlur까지 끝낸 Texture }
  • 9. D2 • Artifact – MipLevel이 커질수록 Aliasing 발생 – MipLevel이 차이나는 곳에서 Aliasing 발생 • 원인 – MipMap에서 이미 Blurring 되었기 때문에
  • 10. D2
  • 11. D2 Level0 Level1 0 0 1 0 Screen
  • 12. D2 • Solution – MipMap을 자동생성하지 않고 깊이를 비교하 여 생성 (귀찮음 적용하지 않음) – Sampling 할 때 인접 픽셀들과 평균 – 인접픽셀은 대각선 방향의 4개 픽셀을 사용 • Aliasing은 대각선에만 발생되기 때문에 상하좌우 보다 대각선방향의 픽셀을 가져오는 것이 효과적 인 것 같다!
  • 13. D2 float4 DefaultPS( OUTPUT_VS In ) : COLOR { float lodLevel = GetLod(In.tex); float3 deferredRgb = GetLodColor(In.tex, lodLevel); // 좌상, 우상, 우하, 좌하 + 중앙 float p = lodLevel * 2; float offsetA = offsetAB.xy * p; float offsetB = offsetAB.zw * p; deferredRgb += GetLodColor(In.tex+offsetA, lodLevel); deferredRgb += GetLodColor(In.tex-offsetA, lodLevel); deferredRgb += GetLodColor(In.tex+offsetB, lodLevel); deferredRgb += GetLodColor(In.tex-offsetB, lodLevel); deferredRgb /= 5; return float4(deferredRgb,1); }
  • 14. D2
  • 15. D2
  • 16. QnA • Future Work – 없어