zoukankan      html  css  js  c++  java
  • Shadow blur with PCF and Gaussian filter

    Long time back, GPU Gems introduced how to soften shadow with Percentage Closer Filter: http://http.developer.nvidia.com/GPUGems/gpugems_ch11.html

    The article fetches eight times and get a similar result to sixteen times fetching.

    I have tried both ways but I wasn't satisfied with them.

    As the article explains the problem on the shadow map is that we needs to get binary depth testing results first. We cannot just blur the shadow depth values.

    To get a correct Gaussian blur result, we first need to get sixteen texels from the shadow map. Then we compare those values with the actual depth value. Now we need to use Gaussian blur on those binary testing results.

    The article on the GPU Gems just takes the average on them, but the quality can be much more improved with Gaussian blur and/or Bilinear filter.

    We can use a 3x3 Gaussian mask on 4x4 texels. Thus we will get four boolean values. Then we can take bilinear filter on them.

    To improve the result even further, we can calculate floating values from the depth testing, rather than just boolean values.

    float depthOffset = 0.001;

    float depth00 = GetDepth( uv + float2( -1.5, -1.5 ) );

    float brightness00 = saturate( ( depth00 - ( actualDepth - depthOffset ) ) / ( 2* depthOffset ) );

    // do the same thing on different offsets.

    This approach is trying to estimate how much the pixel is open to the light; I tried to apply SSAO trick on the shadow map, but in a simpler way.

    The result was looking good, but I am still looking for a better way, because sixteen texel fetching seems too expensive.

    One way to improve the performance can be to fetch half or quarter of them and fetch others only when those depth testing results differ.

  • 相关阅读:
    java全栈day01-03注释、关键字与标识符
    java全栈day01-02入门案例
    java全栈day01-01
    Python中list常用的10个基本方法----list的灰魔法
    python开发[第二篇]------str的7个必须掌握的方法以及五个常用方法
    Python开发【第二篇】:Python基本数据类型
    爬虫相关
    存储库-MongoDB简单的操作
    解析库-beautifulsoup模块
    拉勾网自动发送简历
  • 原文地址:https://www.cnblogs.com/zengqh/p/2815501.html
Copyright © 2011-2022 走看看