[shaderx4] 4.2 Eliminating Surface Acne with Gradient Shadow Mapping

17
4.2 Eliminating Surface Acne with Gradient Shadow Mapping ohyecloudy(http://ohyecloudy.com) shader study(http://cafe.naver.com/shader.cafe) 2010.4.26

Transcript of [shaderx4] 4.2 Eliminating Surface Acne with Gradient Shadow Mapping

Page 1: [shaderx4] 4.2 Eliminating Surface Acne with Gradient Shadow Mapping

4.2 Eliminating Surface Acne with Gradient Shadow Mapping

ohyecloudy(http://ohyecloudy.com)

shader study(http://cafe.naver.com/shader.cafe)

2010.4.26

Page 2: [shaderx4] 4.2 Eliminating Surface Acne with Gradient Shadow Mapping

The Phenomenon of Surface Acne Depth Bias to the Rescue

Depth Gradient

Depth Comparison as a Fuzzy Function

Conclusion

Page 3: [shaderx4] 4.2 Eliminating Surface Acne with Gradient Shadow Mapping
Page 4: [shaderx4] 4.2 Eliminating Surface Acne with Gradient Shadow Mapping

Light

Sampled surface 깊이 맵에서 샘플링 된 깊이 값.

Surface 렌더링하는 오브젝트 표면

False Shadow

Page 5: [shaderx4] 4.2 Eliminating Surface Acne with Gradient Shadow Mapping

The Phenomenon of Surface Acne

Depth Bias to the Rescue Depth Gradient

Depth Comparison as a Fuzzy Function

Conclusion

Page 6: [shaderx4] 4.2 Eliminating Surface Acne with Gradient Shadow Mapping

Light

Light

Depth Bias 평면에선 문제가 없다.

Page 7: [shaderx4] 4.2 Eliminating Surface Acne with Gradient Shadow Mapping

false nonshadowing 지나친 depth bias로 그림자가 생겨야 할 곳에 안 생긴다.

곡면에선 문제

곡면에선 적절한 Depth Bias가 Depth Gradient마다 다르다.

Page 8: [shaderx4] 4.2 Eliminating Surface Acne with Gradient Shadow Mapping
Page 9: [shaderx4] 4.2 Eliminating Surface Acne with Gradient Shadow Mapping

The Phenomenon of Surface Acne

Depth Bias to the Rescue

Depth Gradient Depth Comparison as a Fuzzy Function

Conclusion

Page 10: [shaderx4] 4.2 Eliminating Surface Acne with Gradient Shadow Mapping

Light

Depth Bias Depth Gradient

• depth map에서 이웃 샘플갂 차이

• 입사각의 탄젠트와 비례한다.

• bias scale에 사용 가능.

Page 11: [shaderx4] 4.2 Eliminating Surface Acne with Gradient Shadow Mapping

// gradient calculation

float pixeloffset = INVPIXEL / 2;

float4 depths = float4(

tex2D( ShadowSampler, shadowP + float2( -pixeloffset, 0 ) ).x,

tex2D( ShadowSampler, shadowP + float2( +pixeloffset, 0 ) ).x,

tex2D( ShadowSampler, shadowP + float2( 0, -pixeloffset ) ).x,

tex2D( ShadowSampler, shadowP + float2( 0, +pixeloffset ) ).x );

float2 differences = abs( depths.yw - depths.xz );

float gradient =

min( GradientClamp, max( differences.x, differences.y ) );

difference

Page 12: [shaderx4] 4.2 Eliminating Surface Acne with Gradient Shadow Mapping

The Phenomenon of Surface Acne

Depth Bias to the Rescue

Depth Gradient

Depth Comparison as a Fuzzy Function

Conclusion

Page 13: [shaderx4] 4.2 Eliminating Surface Acne with Gradient Shadow Mapping

1

uncertainty region

Fuzzy depth comparison unbiased depth comparison

Page 14: [shaderx4] 4.2 Eliminating Surface Acne with Gradient Shadow Mapping

// visibility function

float delta_z = centerdepth + gradient * ShadowGradientScaleBias - In.ShadowmapCoord.z;

float visibility = saturate( 1 + delta_z / ( gradient * ShadowFuzzyWidth ) );

Page 15: [shaderx4] 4.2 Eliminating Surface Acne with Gradient Shadow Mapping
Page 16: [shaderx4] 4.2 Eliminating Surface Acne with Gradient Shadow Mapping

The Phenomenon of Surface Acne

Depth Bias to the Rescue

Depth Gradient

Depth Comparison as a Fuzzy Function

Conclusion

Page 17: [shaderx4] 4.2 Eliminating Surface Acne with Gradient Shadow Mapping

• 왜 acne가 생기는지 알아봤다.

• surface acne를 없애기 위한 기술

– depth bias

– gradient-scaled bias

– fuzzy function