Successfully reported this slideshow.
Upcoming SlideShare
×

of

Upcoming SlideShare
Next

2 Likes

Share

See all

### Related Audiobooks

#### Free with a 30 day trial from Scribd

See all

2. 2. Overview of Gradient Shadow Maps Multisampling and PCF Merging the Algorithms Optimizing Texture Look-ups Conclusion
3. 3. • Slope-scale depth bias – gradient를 depth bias에 사용 • Fuzzy depth comparison – 1 or 0이 아니라 0~1 값을 쓴다. • Linearly filtered depth values – point 샘플링이 아니라 보간 해서 사용. • 예) bilinear filter
4. 4. float lightVisibility_GSM(float3 lightCoord) { // get the magnitude of the gradient, by either method float gradient = length(getGradientVector(lightCoord)); // get the difference between stored and interpolated depth // (depthMap should have LINEAR filtering enabled) float diff = tex2D(depthMap, lightCoord.xy).x – lightCoord.z; // replace the less-than operator with a smooth function // for diff >= 0 the result is 1 return saturate(diff/gradient + 1); }
5. 5. Overview of Gradient Shadow Maps Multisampling and PCF Merging the Algorithms Optimizing Texture Look-ups Conclusion
6. 6. float lightVisibility_PCF(float3 ligthCoord) { float result = 0; for (int i = 0; i < n; ++i) { float3 offCoord = lightCoord + offset[i]; result += lightCoord.z < tex2D(depthMap, offCoord.xy).x; } return result / n; }
7. 7. Overview of Gradient Shadow Maps Multisampling and PCF Merging the Algorithms Optimizing Texture Look-ups Conclusion
8. 8. float lightVisibility_PCF_with_GSM(float3 lightCoord) { float result = 0; for (int i = 0; i < n; ++i) { result += lightVisibility_GSM(lightCoord + offset[i]); } return result / n; }
9. 9. incident light incident light surface surface shadow volume shadow volume PCF area PCF area
10. 10. float lightVisibility_GSM_modified(float3 lightCoord, float2 offset) { // get the gradient, by either method float2 gradientVector = getGradientVector(lightCoord); float gradient = length(gradientVector); // calculate an offset coordinate // the z coord is moved along with the local gradient // (this is equivalent to having a local plane equation) float3 offCoord = float3( lightCoord.xy + offset, lightCoord.z + dot(offset, gradientVector)); // the rest is straightforward float diff = offCoord.z – tex2D(depthMap, offCoord.xy).x; return saturate(diff/gradient + 1); }
11. 11. Overview of Gradient Shadow Maps Multisampling and PCF Merging the Algorithms Optimizing Texture Look-ups Conclusion
12. 12. • depth map에 scalar depth 저장했을 때 – gradient vector : texture loockup 3번 • 추가로 depth sampling 한번, PCF에서 4번 • 전체 PCF 영역에서 평균 gradient를 근사 – 최소 제곱 근사값least squares approximation을 찾기 위한 선형회귀linear regression
13. 13. z    x 2  xy  1  z x   x    i i i  z   xy  y 2   z y   y   i   i i  공(共)분산 행렬 covariance matrix  z   pi p i  T 1  zi pi  xy 제거   zi xi   z    x     xi2  z   zi yi    y     yi  2   
14. 14. 8 PCF samples float lightVisibility_unrolled_circluar8(float3 lightCoord) { const float displace = .5 / depthMapResolution; const float displaceLong = 1.41421 * displace; float depths[8] = { tex2D(depthMap, lightCoord.xy + float2(-displaceLong,0)).x, tex2D(depthMap, lightCoord.xy + float2(displaceLong,0)).x, tex2D(depthMap, lightCoord.xy + float2(0,-displaceLong)).x, tex2D(depthMap, lightCoord.xy + float2(0,displaceLong)).x, tex2D(depthMap, lightCoord.xy + float2(-displaceLong,-displaceLong)).x, tex2D(depthMap, lightCoord.xy + float2(displaceLong,-displaceLong)).x, tex2D(depthMap, lightCoord.xy + float2(-displaceLong, displaceLong)).x, tex2D(depthMap, lightCoord.xy + float2(displaceLong, displaceLong)).x }; const float inverseCovariance = 1. / (1 + 1+ 2); float2 gradientVector = float2( depths[1] * 1.41421 + depths[5] + depths[7] -depths[0] * 1.41421 – depths[4] – depths[6], depths[3] * 1.41421 + depths[6] + depths[7] -depths[2] * 1.41421 – depths[4] – depths[5] ) * inverseCovariance; // continue with summation over PCF samples // using the average gradient }
15. 15. Overview of Gradient Shadow Maps Multisampling and PCF Merging the Algorithms Optimizing Texture Look-ups Conclusion
16. 16. • ShaderX4에서 봤던 Acne 제거 기술 복습 – Slope-scale depth bias, – Fuzzy depth comparison, – Linearly filtered depth values • 추가로 부드러운 그림자 가장자리(edge)를 만들기 위한 기술 – PCF – 샘플링 회수를 줄이기 위한 근사
• #### nsdaler

Aug. 18, 2013

Dec. 6, 2012

Total views

2,424

On Slideshare

0

From embeds

0

Number of embeds

21

23

Shares

0