TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
Optimizing Gradient Shadow Maps
1. ShaderX5
4.2 Multisampling Extension
for Gradient Shadow Maps
ohyecloudyhttp://ohyecloudy.com
shader study http://cafe.naver.com/shader.cafe
2010.5.24
2. Overview of Gradient Shadow Maps
Multisampling and PCF
Merging the Algorithms
Optimizing Texture Look-ups
Conclusion
3.
4.
5.
6.
7. • Slope-scale depth bias
– gradient를 depth bias에 사용
• Fuzzy depth comparison
– 1 or 0이 아니라 0~1 값을 쓴다.
• Linearly filtered depth values
– point 샘플링이 아니라 보간 해서 사용.
• 예) bilinear filter
8. 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);
}
9. Overview of Gradient Shadow Maps
Multisampling and PCF
Merging the Algorithms
Optimizing Texture Look-ups
Conclusion
10. 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;
}
11. Overview of Gradient Shadow Maps
Multisampling and PCF
Merging the Algorithms
Optimizing Texture Look-ups
Conclusion
14. incident light incident light
surface surface
shadow volume shadow volume
PCF area PCF area
15. 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);
}
16. Overview of Gradient Shadow Maps
Multisampling and PCF
Merging the Algorithms
Optimizing Texture Look-ups
Conclusion
17. • depth map에 scalar depth 저장했을 때
– gradient vector : texture loockup 3번
• 추가로 depth sampling 한번, PCF에서 4번
• 전체 PCF 영역에서 평균 gradient를 근사
– 최소 제곱 근사값least squares approximation을
찾기 위한 선형회귀linear regression
20. Overview of Gradient Shadow Maps
Multisampling and PCF
Merging the Algorithms
Optimizing Texture Look-ups
Conclusion
21. • ShaderX4에서 봤던 Acne 제거 기술 복습
– Slope-scale depth bias,
– Fuzzy depth comparison,
– Linearly filtered depth values
• 추가로 부드러운 그림자 가장자리(edge)를
만들기 위한 기술
– PCF
– 샘플링 회수를 줄이기 위한 근사