際際滷

際際滷Share a Scribd company logo
Screen
Space
Reflection
Screen Space Reflection?
Screen Space Reflection
: 覃 : 螻糾 : 覦
Reflection?
 覦 觜 牛伎 覓殊 覺.
Reflection?
蠏碁磯 朱 覦 觜 蟯  觜 訖襷  るジ 覓殊牡 覦
觜  給.
Reflection?
蟇一語 企  螳  蟯谿壱  給.
Reflection?
蟇一 訖襷  れ 覓殊 蟯谿壱  給.
Reflection?
3D 襴貅伎 企 覦襯 企至   蟾?
れ螻 螳  覃伎   蟇一語 螳 覺.
蟇一
蟇一 
 覓
Reflection?
蟇一瑚骸 螳 襷る 覃伎 れ伎 觜 覃伎 覯 覦レ 伎 螳螻 
 螳襦 覦.
蟇一
蟇一 
 覓
Reflection?
蠏 蟆郁骸 蟇一 覃伎 豺朱 覓殊  襷鷺蟆 .
3D 襴貅伎 ル伎 蟇一語 襷 る 蟇一語 襷鷺  豺襦 覓
 企 覯  蠏碁Μ覃 .
蟇一
蟇一 
 覓
蟇一語
襷鷺
Reflection?
讀 蟇一 企  ル伎 覈 覓殊牡  覯  襷覃 .
る 蟇一語 り 覦覩襦 豺企朱ゼ 蠍一朱 結伎 覃伎 蟇一語 朱 蠏碁
讌  給. 磯殊 winding order襯 螻ろ伎 .
蟇一
蟇一 
 覓
蟇一語
襷鷺
Reflection?
伎 3D 襴貅伎 蟇一語 覦    給.
蠏碁  ル伎 蟇一語  螳朱 企至 覃 蟾?
=> 蟇一語 螳 襷 覦  襷れ 覓殊牡襯  覯 蠏碁Μ覃 .
讀 覦   覦 ル伎 覓殊牡 螳 X 蟇一語 螳 襷  襷 
伎 .
蟇一語 螳 磯 Draw call 讀螳蟆 .
Reflection?
蠏碁Μ螻 企 覓殊牡    蟾?
豢豌 : https://en.wikipedia.org/wiki/Specular_reflection
Reflection?
覦   覦  襷鷺 豺 覓殊牡襯  覯 蠏碁暑.
蟲 螳  覃伎 譟伎 蠍壱 蟲譟磯 覓殊牡襯  覯 蟆轟 蠏碁れ .
Environment Mapping
 蟆曙 蟆 襷ろ   給.
覓殊牡襯 蠍一朱 譯朱 蟆曙 襷螻  覲企ゼ 覦朱 覦  螻壱
 蟆.
蟲蠍 ろ碁Μ 觀一 螳 碁朱 讌 螳覃 .
豢豌 : https://www.google.co.kr/intl/ko/streetview/apps/
Environment Mapping
譯朱 蟆曙 れ  れ襦  ロ  螻 latitude/longitude,
mirrored ball, horizontal cross 煙 朱 ル  給.
豢豌 : http://spiralgraphics.biz/genetica/help/index.htm?environment_maps_explained.htm
Environment Mapping
蠏 譴 °伎牡  Cube れ襯 譯朱  螳 一企 貊
襦 所 蟆 襷ろ 蟲  給.
覓
豌
Cube れ
蟯谿 
TextureCube cubeTex : register( t0 );
float4 main( PS_INPUT input ) : SV_Target
{
return cubeTex.Sample( baseSampler, 覦 覯″);
}
Environment Mapping
覦 覯″磯ゼ 牛 Cube れ襯 襷覃 れ螻 螳 覦螳  覃伎 3D
襴貅伎   蟆 .
豢豌 : https://learnopengl.com/Advanced-OpenGL/Cubemaps
Environment Mapping
蟆 襷ろ 覓殊牡 蟇一瑚骸 螳  覦襯 螳讌 れ 覃伎  蟆曙一
蟆   給.
讌襷 襴貅伎伎 れ螳朱 讌企 覓殊牡襯 蠍 伎 覦
   蟆豌 譯朱 蟆曙 襷る れ 蠏碁れ .
Cube れ襯  蟆曙 6覃伎 れ X 覓殊牡 螳 襷殊 Draw Call 豢螳
  給.
Environment Mapping
 れ螻 螳 覓語螳 覦  給.
豢豌 : http://www.cse.chalmers.se/edu/year/2017/course/TDA361/Advanced%20Computer%20Graphics/Screen-space%20reflections.pdf
Environment Mapping
 覓語 譯朱 蟆曙 襷 豺螳 れ 覦螳 殊企 豺 るゴ蠍 覓語
覦 .
Cube れ
蟯谿 
Cube れ 覓殊牡 譴 襷 
覦襦 螳語   豺
讌襷 襷 豺襯 蠍一朱 覃
Environment Mapping
讀 蟆 襷ろ 覓殊牡 覦 譯朱蟆曙 覓殊牡 覓危 蟇磯Μ襷 伎
 蟆曙一  螻朱ゼ 螻牛.
襷讌襷朱 蟆 襷ろ 蠍   覦襯 讌 覈詩.
豢豌 : http://schorsch.efi.fh-nuernberg.de/roettger/index.php/Computergrafik/EnvironmentMapping
譯殊 譯朱レ 覿覿 覲伎伎
Screen Space Reflection
覦   覦覯 覦  轟 覃伎 覩襦 るジ 覃伎 覦
 覓殊牡襯 蠏碁Μ蠍 伎  れ 蟲伎 覓殊牡襯 譴覲旧朱 蠏碁れ .
蟆 襷ろ れ螳 覦襯 伎  覓殊牡襯 れ 蠏碁れ 螻 覦 覓殊牡螳
覦覃伎 蠏殊   蟯企Μ螳 覦  給.
企 蠍一ヾ 蠍磯れ  企 覲伎 蠍磯 覦襦 Screen Space
Reflection .
Screen Space Reflection
Screen Space Reflection 旧 蠍 伎 れ 讌 危エ覲願給.
覃伎 蟇企殊 蟾蟆 覦 覲伎企 讌.
Screen Space Reflection
 讌  危エ覲企 覃伎 覦 覲伎企 蟇企朱れ 讌 覈 谿場  
る 蟇   給.
Screen Space Reflection
讀 覃 螻糾(Screen Space) 一危磯ゼ 牛伎 覦襯 螻壱  給.
企  蠏碁Π ル伎 一危磯ゼ 覃 覦襯 伎 覓殊牡襯  覯
蠏碁Μ讌  覩襦 ル伎 覲旧° レ 覦讌 給.
 ル伎 襷ろ 螳煙 蠍 覓語 れ螳 覦襯  豢螳 
讌 給.
蠍   覦 螳ロ覃 轟 覃伎 讌 給.
Screen Space Reflection
覃 螻糾 一危磯ゼ 牛伎 覦襯 螻壱る 3螳讌 覲企ゼ 螻 伎 .
1. ル伎  覲
2. ル伎 覯 覲
3. ル伎 豺 覲
Screen Space Reflection
Screen Space Reflection朱  螳 曙 豺 覦襯 螻壱企慨蟆給.
豺企殊 企 曙 蟾讌 蟯 覃伎 覦 企 覓殊牡 覿讌襯
豢覃 .
 覃伎 覦螳  讌
Screen Space Reflection
豺企 螻糾 豺企殊 豺 (0, 0, 0) 企襦 企 曙襦 蟯 讌
覦レ 曙 豺企 螻糾 豺螳 .
企ゼ ル伎 豺 覲企ゼ 伎 詞 .
Screen Space Reflection
伎 企 曙 覯 覯″磯ゼ 覃 覦 覯″磯ゼ 蟲  給.
Screen Space Reflection
伎 覦 覯″一 覦レ朱 Ray Marching 牛伎 蟯 豢 豺襯 
願 企 豺  螳語る .
豢 豺 企至    蟾?
Ray Marching?
蟯螻 企 覃伎 豢 觜蟲 所 蟲   覦覯 覯 危エ覲願給.
企 蟯 蟲 豢る 蠏 豢 蟯螻 蟲襯 襦  れ 蟯
襯 蟲   蟆朱 螻壱  給.
蟯 襦  :   =  + $   0
蟲襯 襦  :        = 2
 + $  C   + $  C = 2
 + $   + $ = 2
(  矩ゼ 朱 豺)
   2 + 2     + (  ) = 2 (螳)
 
+      +      
=  (   = )
蠏殊 螻旧 牛伎  襯 蟲  螻 企ゼ 蟯  覃 豺
Ray Marching?
企蟆 轟 覃伎 襦    蟆曙一 豢 觜蟲 所 谿場
  給.
讌襷 企 蠏碁れ 覲旧″ ル伎 覃伎 襦 蠍 企旧給.
Ray Marching朱 覃 螳 所 襴讌  蟆曙一 覃願骸 蟯 豢
谿場  給.
Ray Marching?
れ螻 螳 覃伎 Ray Marching  蟯 豢 谿場覲願給.
Ray Origin
Ray Marching?
蟯 讌 覦レ朱 殊蟇磯Μ 襷 讌.
企 豺螳 覃願骸 豢讌 蟆.  螻 豢讌 給.
Ray Origin
Ray Marching?
覃願骸 豢   蟾讌 覦覲牛.
伎 覃願骸 豢給.
Ray Origin
Ray Marching?
 豢豺 豢螳朱 伎  襯   給.
Ray Origin
伎 讌 蠍語伎 覦 襷殊 覦襦 企
豢讌 覿 磯 讌覦レ 覲蟆渚螻
讌 蠍語企ゼ 覦 譴螳覃 企
Ray Marching?
企 朱 讌 蟯 讌 覦レ朱 殊 蟇磯Μ襷 企貅 螳覃 豢
 谿場企 覦 Ray Marching企手 .
豢 谿場企 蟆 語 Ray Marching 蠏狩讌  覲朱エ 螳讌 覈
覓殊牡襯 蠏碁Υ  .
豢豌 : https://en.wikipedia.org/wiki/Volume_ray_casting
Screen Space Reflection
Using Ray Marching
Screen Space Reflection
Using Ray Marching
float4 main( PS_INPUT input ) : SV_TARGET
{
float3 incidentVec = normalize( input.viewPos );
float3 viewNormal = normalize( input.viewNormal );
float3 reflectVec = reflect( incidentVec, viewNormal );
reflectVec = normalize( reflectVec );
reflectVec *= g_rayStepScale;
float3 reflectPos = input.viewPos;
float thickness = g_maxThickness / g_FarPlaneDist;
[loop]
for ( int i = 0; i < g_maxRayStep; ++i )
{
float3 texCoord = GetTexCoordXYLinearDepthZ( reflectPos );
float srcdepth = depthbufferTex.SampleLevel( baseSampler, texCoord.xy, 0 ).x;
float depthDiff = texCoord.z - srcdepth;
if ( depthDiff > g_depthbias && depthDiff < thickness )
{
float4 reflectColor = BinarySearch( reflectVec, reflectPos );
float edgeFade = 1.f - pow( length( texCoord.xy - 0.5f ) * 2.f, 2.f );
reflectColor.a *= pow( 0.75f, (length( reflectPos - input.viewPos ) / g_maxRayLength) ) * edgeFade;
return reflectColor;
}
else
{
reflectPos += ( i + Noise( texCoord.xy ) ) * reflectVec;
}
}
return float4(0.f, 0.f, 0.f, 0.f);
}
覦 覯″ 螻
Ray Marching
豢 覈 谿場  蟯 讌
豌 豢  伎
Screen Space Reflection
Using Ray Marching
Screen Space Reflection  るジ 覃 螻糾 螻襴讀 (朱 SSAO)螻
襷谿螳讌襦 願屋   曙 螳讌螻  覃 螻糾 語 蠍壱覲企ゼ
讌 覈詩.
 螻糾  るジ 覓殊牡螳 企蟆
豺螻 る 企 覓殊牡  覲企ゼ
詞  給.
 螳れ 覓殊牡 
覲企 詞  給.
Screen Space Reflection
Using Ray Marching
覲企ゼ 詞   蟆曙一 れ螻 螳 壱碁ゼ 誤  給.
 覦  蟆曙 覓殊牡 螳れ 蟆曙
Screen Space Reflection
Using Ray Marching
企 壱碁 誤 伎 觜譯殊殊 豕蠍 伎 れ螻 螳 豌襴襯
.
1.  螳レ襴 螳蟾磯 Fade out 
2. 殊 蠍一 蟷 螳 轟 蟷襯 ロ れ襯 
float edgeFade = 1.f - pow( length( texCoord.xy - 0.5f ) * 2.f, 2.f );
reflectColor.a *= pow( 0.75f, (length( reflectPos - input.viewPos ) / g_maxRayLength) ) * edgeFade;
return reflectColor;
float thickness = g_maxThickness / g_FarPlaneDist; // 殊 蠍一 蟷 螳
// ...
if ( depthDiff > g_depthbias && depthDiff < thickness )
{
float4 reflectColor = BinarySearch( reflectVec, reflectPos );
// ...
}
Screen Space Reflection
Using Ray Marching
Ray Marching  Screen Space Reflection 蠍磯 襷讌襷朱 蟯
讌 蠍語伎  危エ覲企襦 蟆給.
蟯 讌 蠍語企 螻 螳  蟆   れ 螳 磯 覲
  給.
讌 蠍語企ゼ 襴覃 Ray Marching 譬  觜襴  焔レ 企 詞  
讌  讌 蠍語企ゼ れ覃 れ螻 螳 壱碁ゼ 蟯谿   給.
Screen Space Reflection
Using Ray Marching
Screen Space Reflection
Using Ray Marching
讌 蠍語願 覓 企覃 企 豺 蟯 覓殊牡襯 蠏碁 糾骸企襴蟆 螻
蠏 蟆郁骸 覦  蟲磯 蟲磯 蟲覃 蠍郁 .
蟯 讌 蠍語企 ル伎 磯 譴蟆 蟆一伎  願 曙 給.
3谿 螻糾 Ray Marching 蠏朱 覓語 企 曙 螻狩蟆 襷  
 螻 企 曙  襷   給.
豢豌 : http://casual-effects.blogspot.com/2014/08/screen-space-ray-tracing.html
螻狩蟆 襷  覿覿 螳 曙
 覯 襷  襦 覿
 襷  覿覿 蟯 蟆暑 
覈覈 曙 蟇企 磯 蟆 蟯谿磯
覃 螻糾 覲 3D Ray March
Screen Space Ray Tracing
3谿 螻糾 Ray Marching 覓語襯 願屋蠍 伎 覃 螻糾 Ray
Marching .
覃 螻糾 Ray Marching 覿 蠏碁Μ蠍 螻襴讀 DDA( Digital
Differential Analyzer ) 螻襴讀 .
豢豌 : http://casual-effects.blogspot.com/2014/08/screen-space-ray-tracing.html
Digital Differential Analyzer
DDA 螻襴讀 れ螻 螳 螻襦 .
1. 蠏碁Μ螻  覿 蠍一瑚鍵襯 螻 ( =
  $
  $
)
2. 蠍一瑚鍵螳 願   1  蟆曙 x豢 覦レ朱 1 讀螳覃伎 y螳 螻
 +1 =   + 1
 +1 =   + 
3. 1 <   蟆曙 y豢 覦レ朱 1 讀螳覃伎 x螳 螻
 +1 =   +
1

 +1 =   + 1
4. 蠍一瑚鍵螳   蟆曙一 曙 豺襯 螻壱蠍   螻一 企讌
Digital Differential Analyzer
Screen Space Reflection
Using Digital Differential Analyzer
Screen Space Reflection
Using Digital Differential Analyzer
float4 main( PS_INPUT input ) : SV_TARGET
{
float3 incidentVec = normalize( input.viewPos );
float3 viewNormal = normalize( input.viewNormal );
float3 reflectVec = reflect( incidentVec, viewNormal );
reflectVec = normalize( reflectVec );
float3 hitPixel_alpha;
bool isHit = TraceScreenSpaceRay( reflectVec, input.viewPos, hitPixel_alpha );
float3 color = framebufferTex.SampleLevel( baseSampler, hitPixel_alpha.xy, 0 ).rgb;
return float4( color, hitPixel_alpha.z ) * isHit;
}
覦 覯″ 螻
豢 覿 覦 豢 曙 譬襯 螻
bool TraceScreenSpaceRay( float3 dir, float3 viewPos, out float3 hitPixel_alpha )
{
float rayLength = ( viewPos.z + dir.z * g_maxRayLength ) < g_nearPlaneDist ? ( g_nearPlaneDist - viewPos.z ) / dir.z : g_maxRayLength;
hitPixel_alpha = float3( -1, -1, 1 );
float3 rayEnd = viewPos + dir * rayLength;
float4 ssRayBegin = mul( float4( viewPos, 1.0 ), g_projectionMatrix );
float4 ssRayEnd = mul( float4( rayEnd, 1.0 ), g_projectionMatrix );
float k0 = 1 / ssRayBegin.w;
float k1 = 1 / ssRayEnd.w; 覃 螻糾朱 蟯 ,  覲
Screen Space Reflection
Using Digital Differential Analyzer
float2 P0 = ssRayBegin.xy * k0;
float2 P1 = ssRayEnd.xy * k1;
P0 = ( P0 * 0.5 + 0.5 ) * g_targetSize;
P1 = ( P1 * 0.5 + 0.5 ) * g_targetSize;
P1 += ( dot( P1 - P0, P1 - P0 ) < 0.0001 ) ? float2( 0.01, 0.01 ) : float2( 0, 0 );
float2 delta = P1 - P0;
bool permute = false;
if ( abs( delta.x ) < abs( delta.y ) )
{
permute = true;
delta = delta.yx;
P0 = P0.yx;
P1 = P1.yx;
}
float stepDir = sign( delta.x );
float invdx = stepDir / delta.x;
float stepCount = 0;
float rayZ = viewPos.z;
float sceneZMax = viewPos.z + 100.f;
float end = stepDir * P1.x;
float3 Pk = float4( P0, k0 );
float3 dPk = float4( float2( stepDir, delta.y * invdx ), ( k1 - k0 ) * invdx );
dPk *= g_rayStepScale;
float thickness = g_maxThickness;
覃 螻糾朱 蟯 ,  覲
蠍一瑚鍵 螻  DDA delta 螳 螻
1 <
   $
    $
=     $ <    $
Screen Space Reflection
Using Digital Differential Analyzer
[loop]
for ( ;
( ( Pk.x * stepDir ) <= end ) &&
( stepCount < g_maxRayStep ) &&
( ( rayZ < sceneZMax ) ||
( ( rayZ - thickness ) > sceneZMax ) ) &&
( sceneZMax != 0.0 );
Pk += dPk,
stepCount += 1 )
{
hitPixel_alpha.xy = permute ? Pk.yx : Pk.xy;
hitPixel_alpha.xy *= g_invTargetSize;
hitPixel_alpha.y = 1 - hitPixel_alpha.y;
rayZ = 1 / Pk.w;
sceneZMax = depthbufferTex.SampleLevel( baseSampler, hitPixel_alpha.xy, 0 ).x;
thickness = backfaceDepthBufferTex.SampleLevel( baseSampler, hitPixel_alpha.xy, 0 ).x * g_FarPlaneDist;
sceneZMax *= g_FarPlaneDist;
thickness -= sceneZMax;
sceneZMax += g_depthbias;
}
float edgeFade = 1.f - pow( length( hitPixel_alpha.xy - 0.5 ) * 2.f, 3.0f );
hitPixel_alpha.z = edgeFade;
return ( rayZ >= sceneZMax ) && ( rayZ - thickness <= sceneZMax );
}
Ray Marching
// 蟯 蟾讌 讌蠍 蟾讌
// 豕 Ray Marching 螻 蠍 蟾讌
// 覓殊牡 覿蠍 蟾讌
// 覃 螻糾 蟯 讌
Summary
蠍一ヾ 覦  覦  覲伎    蠍一企手   給.
焔レ ル伎 覲旧° レ 覦讌 讌襷 觜 り   給.
2谿 れ襦 蠍磯 ル 覲企 蠍 覓語 覲 覿譟煙朱 誤 れ
覓語螳 覦   給.
豢豌 : http://casual-effects.blogspot.com/2014/08/screen-space-ray-tracing.html
殊暑 谿襦襦
1. 豌 覦 覲 X
2. 覓殊牡 結覿 覲 X
3. 螳れ 覓殊牡  覲 X
Future?
豢豌 : https://www.techpowerup.com/247365/dice-to-dial-back-ray-tracing-eye-candy-in-battlefield-v-to-favor-performance
Future?
2018 9 20殊 豢 GeForce RTX 20 襴讀 れ螳  碁伎
蠍磯レ 讌.
れ螳  碁伎煙 牛伎 蠍一ヾ 蠍一れ 螻 覯企 覦 訖襷 
 蟲伎, 蠏碁殊 螻壱  給.
る れ螳  碁伎煙 伎 譬 蠍一願 螳蟆螳 蟆 豈
  ( RTX 2070 60襷 覦 ) 覲危ク朱 谿  讌 螻 覲 螳
給.
Screenshot
Screenshot
Screenshot
Reference
伎 豢豌 : https://www.flaticon.com/
蟲 蟯 豢 : Real-Time Collision Detection (Christer Ericson)
Screen Space Ray Tracing : http://casual-effects.blogspot.com/2014/08/screen-space-
ray-tracing.html
Battlefield V: Official GeForce RTX Real-Time Ray Tracing Demo :
https://youtu.be/WoQr0k2IA9A
蠏 覦 譬 危  :
http://www.kode80.com/blog/2015/03/11/screen-space-reflections-in-unity-5/
http://tips.hecomi.com/entry/2016/04/04/022550
Appendix
Reflection Matrix
蟇一語 襷鷺  豺襯 谿剰鍵 伎  覃 P襯 螳 覲願給.
P
Reflection Matrix
蠏碁Μ螻   v螳 れ螻 螳 豺 り 蟆給.
P
n
v
Reflection Matrix
 覃 P襯 蠍一朱 v螳 豺 企 豺襯 蟲伎 .
1.  v 豺襯 覯″磯 豬蠍 覃 P 覯 覯″一 伎. 蠏 蟆郁骸襦 n
 v 蠍語企ゼ   給.
P
n
v
v
Reflection Matrix
2. 覃 P 伎 豺 企 v 豺  蠍語(b  )  2覦 襷殊 蟇磯Μ襯
覯 n 覦 覦レ朱 企 豺螳 .
P
n
v
v
Reflection Matrix
朱 襴覃
螳 螻 企ゼ 襦 覃 れ螻 螳給.
  2  b    
  2 

=
1  2 
2
2    2    0
2    1  2 
2
2  0
2    2    1  2 
2 0
2  2 2  1
Reflection Vector
覦 覯″磯ゼ れ 譬襦 覦襦   給. Cube れ襷 る 覦
覯″磯ゼ 蟲 覦覯襷 覃 .
れ  覃 P襯 螳 覺.
P
Reflection Vector
蠏碁Μ螻 れ螻 螳  覯″ v螳 り 螳 覺.
P
n
v
Reflection Vector
1.  覯″ v 覃伎 覯 覯″ n 伎覃 覯 覯″ n  v 蠍語企ゼ 
  給.  螳 -2覦磯ゼ  覯 覯″一 螻燕覃 れ螻 螳 覯″ u襯 至
.
P
n
v
u
Reflection Vector
2. 伎 企蟆 詞 覯″ u 覯″ v襯 覃 覦 覯″磯ゼ 詞  給.
P
n
v
Reflection Vector
朱 襴覃 蟆郁記   2       螳 螻 hlsl reflect 襦 所
蟲  給.

More Related Content

Screen space reflection

  • 2. Screen Space Reflection? Screen Space Reflection : 覃 : 螻糾 : 覦
  • 3. Reflection? 覦 觜 牛伎 覓殊 覺.
  • 4. Reflection? 蠏碁磯 朱 覦 觜 蟯 觜 訖襷 るジ 覓殊牡 覦 觜 給.
  • 5. Reflection? 蟇一語 企 螳 蟯谿壱 給.
  • 6. Reflection? 蟇一 訖襷 れ 覓殊 蟯谿壱 給.
  • 7. Reflection? 3D 襴貅伎 企 覦襯 企至 蟾? れ螻 螳 覃伎 蟇一語 螳 覺. 蟇一 蟇一 覓
  • 8. Reflection? 蟇一瑚骸 螳 襷る 覃伎 れ伎 觜 覃伎 覯 覦レ 伎 螳螻 螳襦 覦. 蟇一 蟇一 覓
  • 9. Reflection? 蠏 蟆郁骸 蟇一 覃伎 豺朱 覓殊 襷鷺蟆 . 3D 襴貅伎 ル伎 蟇一語 襷 る 蟇一語 襷鷺 豺襦 覓 企 覯 蠏碁Μ覃 . 蟇一 蟇一 覓 蟇一語 襷鷺
  • 10. Reflection? 讀 蟇一 企 ル伎 覈 覓殊牡 覯 襷覃 . る 蟇一語 り 覦覩襦 豺企朱ゼ 蠍一朱 結伎 覃伎 蟇一語 朱 蠏碁 讌 給. 磯殊 winding order襯 螻ろ伎 . 蟇一 蟇一 覓 蟇一語 襷鷺
  • 11. Reflection? 伎 3D 襴貅伎 蟇一語 覦 給. 蠏碁 ル伎 蟇一語 螳朱 企至 覃 蟾? => 蟇一語 螳 襷 覦 襷れ 覓殊牡襯 覯 蠏碁Μ覃 . 讀 覦 覦 ル伎 覓殊牡 螳 X 蟇一語 螳 襷 襷 伎 . 蟇一語 螳 磯 Draw call 讀螳蟆 .
  • 12. Reflection? 蠏碁Μ螻 企 覓殊牡 蟾? 豢豌 : https://en.wikipedia.org/wiki/Specular_reflection
  • 13. Reflection? 覦 覦 襷鷺 豺 覓殊牡襯 覯 蠏碁暑. 蟲 螳 覃伎 譟伎 蠍壱 蟲譟磯 覓殊牡襯 覯 蟆轟 蠏碁れ .
  • 14. Environment Mapping 蟆曙 蟆 襷ろ 給. 覓殊牡襯 蠍一朱 譯朱 蟆曙 襷螻 覲企ゼ 覦朱 覦 螻壱 蟆. 蟲蠍 ろ碁Μ 觀一 螳 碁朱 讌 螳覃 . 豢豌 : https://www.google.co.kr/intl/ko/streetview/apps/
  • 15. Environment Mapping 譯朱 蟆曙 れ れ襦 ロ 螻 latitude/longitude, mirrored ball, horizontal cross 煙 朱 ル 給. 豢豌 : http://spiralgraphics.biz/genetica/help/index.htm?environment_maps_explained.htm
  • 16. Environment Mapping 蠏 譴 °伎牡 Cube れ襯 譯朱 螳 一企 貊 襦 所 蟆 襷ろ 蟲 給. 覓 豌 Cube れ 蟯谿 TextureCube cubeTex : register( t0 ); float4 main( PS_INPUT input ) : SV_Target { return cubeTex.Sample( baseSampler, 覦 覯″); }
  • 17. Environment Mapping 覦 覯″磯ゼ 牛 Cube れ襯 襷覃 れ螻 螳 覦螳 覃伎 3D 襴貅伎 蟆 . 豢豌 : https://learnopengl.com/Advanced-OpenGL/Cubemaps
  • 18. Environment Mapping 蟆 襷ろ 覓殊牡 蟇一瑚骸 螳 覦襯 螳讌 れ 覃伎 蟆曙一 蟆 給. 讌襷 襴貅伎伎 れ螳朱 讌企 覓殊牡襯 蠍 伎 覦 蟆豌 譯朱 蟆曙 襷る れ 蠏碁れ . Cube れ襯 蟆曙 6覃伎 れ X 覓殊牡 螳 襷殊 Draw Call 豢螳 給.
  • 19. Environment Mapping れ螻 螳 覓語螳 覦 給. 豢豌 : http://www.cse.chalmers.se/edu/year/2017/course/TDA361/Advanced%20Computer%20Graphics/Screen-space%20reflections.pdf
  • 20. Environment Mapping 覓語 譯朱 蟆曙 襷 豺螳 れ 覦螳 殊企 豺 るゴ蠍 覓語 覦 . Cube れ 蟯谿 Cube れ 覓殊牡 譴 襷 覦襦 螳語 豺 讌襷 襷 豺襯 蠍一朱 覃
  • 21. Environment Mapping 讀 蟆 襷ろ 覓殊牡 覦 譯朱蟆曙 覓殊牡 覓危 蟇磯Μ襷 伎 蟆曙一 螻朱ゼ 螻牛. 襷讌襷朱 蟆 襷ろ 蠍 覦襯 讌 覈詩. 豢豌 : http://schorsch.efi.fh-nuernberg.de/roettger/index.php/Computergrafik/EnvironmentMapping 譯殊 譯朱レ 覿覿 覲伎伎
  • 22. Screen Space Reflection 覦 覦覯 覦 轟 覃伎 覩襦 るジ 覃伎 覦 覓殊牡襯 蠏碁Μ蠍 伎 れ 蟲伎 覓殊牡襯 譴覲旧朱 蠏碁れ . 蟆 襷ろ れ螳 覦襯 伎 覓殊牡襯 れ 蠏碁れ 螻 覦 覓殊牡螳 覦覃伎 蠏殊 蟯企Μ螳 覦 給. 企 蠍一ヾ 蠍磯れ 企 覲伎 蠍磯 覦襦 Screen Space Reflection .
  • 23. Screen Space Reflection Screen Space Reflection 旧 蠍 伎 れ 讌 危エ覲願給. 覃伎 蟇企殊 蟾蟆 覦 覲伎企 讌.
  • 24. Screen Space Reflection 讌 危エ覲企 覃伎 覦 覲伎企 蟇企朱れ 讌 覈 谿場 る 蟇 給.
  • 25. Screen Space Reflection 讀 覃 螻糾(Screen Space) 一危磯ゼ 牛伎 覦襯 螻壱 給. 企 蠏碁Π ル伎 一危磯ゼ 覃 覦襯 伎 覓殊牡襯 覯 蠏碁Μ讌 覩襦 ル伎 覲旧° レ 覦讌 給. ル伎 襷ろ 螳煙 蠍 覓語 れ螳 覦襯 豢螳 讌 給. 蠍 覦 螳ロ覃 轟 覃伎 讌 給.
  • 26. Screen Space Reflection 覃 螻糾 一危磯ゼ 牛伎 覦襯 螻壱る 3螳讌 覲企ゼ 螻 伎 . 1. ル伎 覲 2. ル伎 覯 覲 3. ル伎 豺 覲
  • 27. Screen Space Reflection Screen Space Reflection朱 螳 曙 豺 覦襯 螻壱企慨蟆給. 豺企殊 企 曙 蟾讌 蟯 覃伎 覦 企 覓殊牡 覿讌襯 豢覃 . 覃伎 覦螳 讌
  • 28. Screen Space Reflection 豺企 螻糾 豺企殊 豺 (0, 0, 0) 企襦 企 曙襦 蟯 讌 覦レ 曙 豺企 螻糾 豺螳 . 企ゼ ル伎 豺 覲企ゼ 伎 詞 .
  • 29. Screen Space Reflection 伎 企 曙 覯 覯″磯ゼ 覃 覦 覯″磯ゼ 蟲 給.
  • 30. Screen Space Reflection 伎 覦 覯″一 覦レ朱 Ray Marching 牛伎 蟯 豢 豺襯 願 企 豺 螳語る . 豢 豺 企至 蟾?
  • 31. Ray Marching? 蟯螻 企 覃伎 豢 觜蟲 所 蟲 覦覯 覯 危エ覲願給. 企 蟯 蟲 豢る 蠏 豢 蟯螻 蟲襯 襦 れ 蟯 襯 蟲 蟆朱 螻壱 給. 蟯 襦 : = + $ 0 蟲襯 襦 : = 2 + $ C + $ C = 2 + $ + $ = 2 ( 矩ゼ 朱 豺) 2 + 2 + ( ) = 2 (螳) + + = ( = ) 蠏殊 螻旧 牛伎 襯 蟲 螻 企ゼ 蟯 覃 豺
  • 32. Ray Marching? 企蟆 轟 覃伎 襦 蟆曙一 豢 觜蟲 所 谿場 給. 讌襷 企 蠏碁れ 覲旧″ ル伎 覃伎 襦 蠍 企旧給. Ray Marching朱 覃 螳 所 襴讌 蟆曙一 覃願骸 蟯 豢 谿場 給.
  • 33. Ray Marching? れ螻 螳 覃伎 Ray Marching 蟯 豢 谿場覲願給. Ray Origin
  • 34. Ray Marching? 蟯 讌 覦レ朱 殊蟇磯Μ 襷 讌. 企 豺螳 覃願骸 豢讌 蟆. 螻 豢讌 給. Ray Origin
  • 35. Ray Marching? 覃願骸 豢 蟾讌 覦覲牛. 伎 覃願骸 豢給. Ray Origin
  • 36. Ray Marching? 豢豺 豢螳朱 伎 襯 給. Ray Origin 伎 讌 蠍語伎 覦 襷殊 覦襦 企 豢讌 覿 磯 讌覦レ 覲蟆渚螻 讌 蠍語企ゼ 覦 譴螳覃 企
  • 37. Ray Marching? 企 朱 讌 蟯 讌 覦レ朱 殊 蟇磯Μ襷 企貅 螳覃 豢 谿場企 覦 Ray Marching企手 . 豢 谿場企 蟆 語 Ray Marching 蠏狩讌 覲朱エ 螳讌 覈 覓殊牡襯 蠏碁Υ . 豢豌 : https://en.wikipedia.org/wiki/Volume_ray_casting
  • 39. Screen Space Reflection Using Ray Marching float4 main( PS_INPUT input ) : SV_TARGET { float3 incidentVec = normalize( input.viewPos ); float3 viewNormal = normalize( input.viewNormal ); float3 reflectVec = reflect( incidentVec, viewNormal ); reflectVec = normalize( reflectVec ); reflectVec *= g_rayStepScale; float3 reflectPos = input.viewPos; float thickness = g_maxThickness / g_FarPlaneDist; [loop] for ( int i = 0; i < g_maxRayStep; ++i ) { float3 texCoord = GetTexCoordXYLinearDepthZ( reflectPos ); float srcdepth = depthbufferTex.SampleLevel( baseSampler, texCoord.xy, 0 ).x; float depthDiff = texCoord.z - srcdepth; if ( depthDiff > g_depthbias && depthDiff < thickness ) { float4 reflectColor = BinarySearch( reflectVec, reflectPos ); float edgeFade = 1.f - pow( length( texCoord.xy - 0.5f ) * 2.f, 2.f ); reflectColor.a *= pow( 0.75f, (length( reflectPos - input.viewPos ) / g_maxRayLength) ) * edgeFade; return reflectColor; } else { reflectPos += ( i + Noise( texCoord.xy ) ) * reflectVec; } } return float4(0.f, 0.f, 0.f, 0.f); } 覦 覯″ 螻 Ray Marching 豢 覈 谿場 蟯 讌 豌 豢 伎
  • 40. Screen Space Reflection Using Ray Marching Screen Space Reflection るジ 覃 螻糾 螻襴讀 (朱 SSAO)螻 襷谿螳讌襦 願屋 曙 螳讌螻 覃 螻糾 語 蠍壱覲企ゼ 讌 覈詩. 螻糾 るジ 覓殊牡螳 企蟆 豺螻 る 企 覓殊牡 覲企ゼ 詞 給. 螳れ 覓殊牡 覲企 詞 給.
  • 41. Screen Space Reflection Using Ray Marching 覲企ゼ 詞 蟆曙一 れ螻 螳 壱碁ゼ 誤 給. 覦 蟆曙 覓殊牡 螳れ 蟆曙
  • 42. Screen Space Reflection Using Ray Marching 企 壱碁 誤 伎 觜譯殊殊 豕蠍 伎 れ螻 螳 豌襴襯 . 1. 螳レ襴 螳蟾磯 Fade out 2. 殊 蠍一 蟷 螳 轟 蟷襯 ロ れ襯 float edgeFade = 1.f - pow( length( texCoord.xy - 0.5f ) * 2.f, 2.f ); reflectColor.a *= pow( 0.75f, (length( reflectPos - input.viewPos ) / g_maxRayLength) ) * edgeFade; return reflectColor; float thickness = g_maxThickness / g_FarPlaneDist; // 殊 蠍一 蟷 螳 // ... if ( depthDiff > g_depthbias && depthDiff < thickness ) { float4 reflectColor = BinarySearch( reflectVec, reflectPos ); // ... }
  • 43. Screen Space Reflection Using Ray Marching Ray Marching Screen Space Reflection 蠍磯 襷讌襷朱 蟯 讌 蠍語伎 危エ覲企襦 蟆給. 蟯 讌 蠍語企 螻 螳 蟆 れ 螳 磯 覲 給. 讌 蠍語企ゼ 襴覃 Ray Marching 譬 觜襴 焔レ 企 詞 讌 讌 蠍語企ゼ れ覃 れ螻 螳 壱碁ゼ 蟯谿 給.
  • 45. Screen Space Reflection Using Ray Marching 讌 蠍語願 覓 企覃 企 豺 蟯 覓殊牡襯 蠏碁 糾骸企襴蟆 螻 蠏 蟆郁骸 覦 蟲磯 蟲磯 蟲覃 蠍郁 . 蟯 讌 蠍語企 ル伎 磯 譴蟆 蟆一伎 願 曙 給. 3谿 螻糾 Ray Marching 蠏朱 覓語 企 曙 螻狩蟆 襷 螻 企 曙 襷 給. 豢豌 : http://casual-effects.blogspot.com/2014/08/screen-space-ray-tracing.html 螻狩蟆 襷 覿覿 螳 曙 覯 襷 襦 覿 襷 覿覿 蟯 蟆暑 覈覈 曙 蟇企 磯 蟆 蟯谿磯 覃 螻糾 覲 3D Ray March
  • 46. Screen Space Ray Tracing 3谿 螻糾 Ray Marching 覓語襯 願屋蠍 伎 覃 螻糾 Ray Marching . 覃 螻糾 Ray Marching 覿 蠏碁Μ蠍 螻襴讀 DDA( Digital Differential Analyzer ) 螻襴讀 . 豢豌 : http://casual-effects.blogspot.com/2014/08/screen-space-ray-tracing.html
  • 47. Digital Differential Analyzer DDA 螻襴讀 れ螻 螳 螻襦 . 1. 蠏碁Μ螻 覿 蠍一瑚鍵襯 螻 ( = $ $ ) 2. 蠍一瑚鍵螳 願 1 蟆曙 x豢 覦レ朱 1 讀螳覃伎 y螳 螻 +1 = + 1 +1 = + 3. 1 < 蟆曙 y豢 覦レ朱 1 讀螳覃伎 x螳 螻 +1 = + 1 +1 = + 1 4. 蠍一瑚鍵螳 蟆曙一 曙 豺襯 螻壱蠍 螻一 企讌
  • 49. Screen Space Reflection Using Digital Differential Analyzer
  • 50. Screen Space Reflection Using Digital Differential Analyzer float4 main( PS_INPUT input ) : SV_TARGET { float3 incidentVec = normalize( input.viewPos ); float3 viewNormal = normalize( input.viewNormal ); float3 reflectVec = reflect( incidentVec, viewNormal ); reflectVec = normalize( reflectVec ); float3 hitPixel_alpha; bool isHit = TraceScreenSpaceRay( reflectVec, input.viewPos, hitPixel_alpha ); float3 color = framebufferTex.SampleLevel( baseSampler, hitPixel_alpha.xy, 0 ).rgb; return float4( color, hitPixel_alpha.z ) * isHit; } 覦 覯″ 螻 豢 覿 覦 豢 曙 譬襯 螻 bool TraceScreenSpaceRay( float3 dir, float3 viewPos, out float3 hitPixel_alpha ) { float rayLength = ( viewPos.z + dir.z * g_maxRayLength ) < g_nearPlaneDist ? ( g_nearPlaneDist - viewPos.z ) / dir.z : g_maxRayLength; hitPixel_alpha = float3( -1, -1, 1 ); float3 rayEnd = viewPos + dir * rayLength; float4 ssRayBegin = mul( float4( viewPos, 1.0 ), g_projectionMatrix ); float4 ssRayEnd = mul( float4( rayEnd, 1.0 ), g_projectionMatrix ); float k0 = 1 / ssRayBegin.w; float k1 = 1 / ssRayEnd.w; 覃 螻糾朱 蟯 , 覲
  • 51. Screen Space Reflection Using Digital Differential Analyzer float2 P0 = ssRayBegin.xy * k0; float2 P1 = ssRayEnd.xy * k1; P0 = ( P0 * 0.5 + 0.5 ) * g_targetSize; P1 = ( P1 * 0.5 + 0.5 ) * g_targetSize; P1 += ( dot( P1 - P0, P1 - P0 ) < 0.0001 ) ? float2( 0.01, 0.01 ) : float2( 0, 0 ); float2 delta = P1 - P0; bool permute = false; if ( abs( delta.x ) < abs( delta.y ) ) { permute = true; delta = delta.yx; P0 = P0.yx; P1 = P1.yx; } float stepDir = sign( delta.x ); float invdx = stepDir / delta.x; float stepCount = 0; float rayZ = viewPos.z; float sceneZMax = viewPos.z + 100.f; float end = stepDir * P1.x; float3 Pk = float4( P0, k0 ); float3 dPk = float4( float2( stepDir, delta.y * invdx ), ( k1 - k0 ) * invdx ); dPk *= g_rayStepScale; float thickness = g_maxThickness; 覃 螻糾朱 蟯 , 覲 蠍一瑚鍵 螻 DDA delta 螳 螻 1 < $ $ = $ < $
  • 52. Screen Space Reflection Using Digital Differential Analyzer [loop] for ( ; ( ( Pk.x * stepDir ) <= end ) && ( stepCount < g_maxRayStep ) && ( ( rayZ < sceneZMax ) || ( ( rayZ - thickness ) > sceneZMax ) ) && ( sceneZMax != 0.0 ); Pk += dPk, stepCount += 1 ) { hitPixel_alpha.xy = permute ? Pk.yx : Pk.xy; hitPixel_alpha.xy *= g_invTargetSize; hitPixel_alpha.y = 1 - hitPixel_alpha.y; rayZ = 1 / Pk.w; sceneZMax = depthbufferTex.SampleLevel( baseSampler, hitPixel_alpha.xy, 0 ).x; thickness = backfaceDepthBufferTex.SampleLevel( baseSampler, hitPixel_alpha.xy, 0 ).x * g_FarPlaneDist; sceneZMax *= g_FarPlaneDist; thickness -= sceneZMax; sceneZMax += g_depthbias; } float edgeFade = 1.f - pow( length( hitPixel_alpha.xy - 0.5 ) * 2.f, 3.0f ); hitPixel_alpha.z = edgeFade; return ( rayZ >= sceneZMax ) && ( rayZ - thickness <= sceneZMax ); } Ray Marching // 蟯 蟾讌 讌蠍 蟾讌 // 豕 Ray Marching 螻 蠍 蟾讌 // 覓殊牡 覿蠍 蟾讌 // 覃 螻糾 蟯 讌
  • 53. Summary 蠍一ヾ 覦 覦 覲伎 蠍一企手 給. 焔レ ル伎 覲旧° レ 覦讌 讌襷 觜 り 給. 2谿 れ襦 蠍磯 ル 覲企 蠍 覓語 覲 覿譟煙朱 誤 れ 覓語螳 覦 給. 豢豌 : http://casual-effects.blogspot.com/2014/08/screen-space-ray-tracing.html 殊暑 谿襦襦 1. 豌 覦 覲 X 2. 覓殊牡 結覿 覲 X 3. 螳れ 覓殊牡 覲 X
  • 55. Future? 2018 9 20殊 豢 GeForce RTX 20 襴讀 れ螳 碁伎 蠍磯レ 讌. れ螳 碁伎煙 牛伎 蠍一ヾ 蠍一れ 螻 覯企 覦 訖襷 蟲伎, 蠏碁殊 螻壱 給. る れ螳 碁伎煙 伎 譬 蠍一願 螳蟆螳 蟆 豈 ( RTX 2070 60襷 覦 ) 覲危ク朱 谿 讌 螻 覲 螳 給.
  • 59. Reference 伎 豢豌 : https://www.flaticon.com/ 蟲 蟯 豢 : Real-Time Collision Detection (Christer Ericson) Screen Space Ray Tracing : http://casual-effects.blogspot.com/2014/08/screen-space- ray-tracing.html Battlefield V: Official GeForce RTX Real-Time Ray Tracing Demo : https://youtu.be/WoQr0k2IA9A 蠏 覦 譬 危 : http://www.kode80.com/blog/2015/03/11/screen-space-reflections-in-unity-5/ http://tips.hecomi.com/entry/2016/04/04/022550
  • 61. Reflection Matrix 蟇一語 襷鷺 豺襯 谿剰鍵 伎 覃 P襯 螳 覲願給. P
  • 62. Reflection Matrix 蠏碁Μ螻 v螳 れ螻 螳 豺 り 蟆給. P n v
  • 63. Reflection Matrix 覃 P襯 蠍一朱 v螳 豺 企 豺襯 蟲伎 . 1. v 豺襯 覯″磯 豬蠍 覃 P 覯 覯″一 伎. 蠏 蟆郁骸襦 n v 蠍語企ゼ 給. P n v v
  • 64. Reflection Matrix 2. 覃 P 伎 豺 企 v 豺 蠍語(b ) 2覦 襷殊 蟇磯Μ襯 覯 n 覦 覦レ朱 企 豺螳 . P n v v
  • 65. Reflection Matrix 朱 襴覃 螳 螻 企ゼ 襦 覃 れ螻 螳給. 2 b 2 = 1 2 2 2 2 0 2 1 2 2 2 0 2 2 1 2 2 0 2 2 2 1
  • 66. Reflection Vector 覦 覯″磯ゼ れ 譬襦 覦襦 給. Cube れ襷 る 覦 覯″磯ゼ 蟲 覦覯襷 覃 . れ 覃 P襯 螳 覺. P
  • 67. Reflection Vector 蠏碁Μ螻 れ螻 螳 覯″ v螳 り 螳 覺. P n v
  • 68. Reflection Vector 1. 覯″ v 覃伎 覯 覯″ n 伎覃 覯 覯″ n v 蠍語企ゼ 給. 螳 -2覦磯ゼ 覯 覯″一 螻燕覃 れ螻 螳 覯″ u襯 至 . P n v u
  • 69. Reflection Vector 2. 伎 企蟆 詞 覯″ u 覯″ v襯 覃 覦 覯″磯ゼ 詞 給. P n v
  • 70. Reflection Vector 朱 襴覃 蟆郁記 2 螳 螻 hlsl reflect 襦 所 蟲 給.