Recommended
[ShaderX5] 4.4 Edge Masking and Per-Texel Depth Extent Propagation For Comput...
[14.10.21] Far Cry and DX9 번역(shaderstudy)
Light in screen_space(Light Pre Pass)
[GEG1] 3.volumetric representation of virtual environments
Rendering realistic Ice objects
Unity Surface Shader for Artist 02
Unity Surface Shader for Artist 04
Unity Surface Shader for Artist 03
Doing math with python.ch05
Doing mathwithpython.ch02
밑바닥부터시작하는딥러닝 Ch05
[Swift] Higher order function
Convolutional neural networks
딥러닝 제대로시작하기 Ch04
밑바닥부터시작하는딥러닝 Ch05
More Related Content
[ShaderX5] 4.4 Edge Masking and Per-Texel Depth Extent Propagation For Comput...
[14.10.21] Far Cry and DX9 번역(shaderstudy)
Light in screen_space(Light Pre Pass)
[GEG1] 3.volumetric representation of virtual environments
What's hot (19)
Rendering realistic Ice objects
Unity Surface Shader for Artist 02
Unity Surface Shader for Artist 04
Unity Surface Shader for Artist 03
Doing math with python.ch05
Doing mathwithpython.ch02
밑바닥부터시작하는딥러닝 Ch05
[Swift] Higher order function
Convolutional neural networks
딥러닝 제대로시작하기 Ch04
밑바닥부터시작하는딥러닝 Ch05
Viewers also liked (6)
How to Write the Fastest JSON Parser/Writer in the World
Similar to D2 Depth of field (20) 크게, 아름답게,빠르게, 일관되게 만들기: Just Cause 2 개발에서 배운 교훈들 (GPU Pro)
[GPU Gems3] Chapter 28. Practical Post Process Depth Of Field
9_혼합_DirectX 11을 이용한 3D 게임 프로그래밍 입문
NDC2016 프로젝트 A1의 AAA급 캐릭터 렌더링 기술
[Shader study] Color control (2014.05.12)
[Shader study] the rendering technology of lords of the fallen - 발표메모(14.06.23)
Game Visual Art Technologies
Kgc make stereo game on pc
I phone3d programming - Chap04:깊이와 현실감 향상시키기
니시카와젠지의 3 d게임 팬을 위한「gravity daze」그래픽스 강좌
D2 Depth of field3. 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
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 되었기 때문에
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);
}