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.

  • 相关阅读:
    编程之美1的个数统计
    组合以及可以重复的排列
    Swing之图书管理系统
    经常熬夜的人一定要看
    利用SharePoint Designer开发可循环工作流
    SharePoint Software DownLoad Address 微软软件 下载地址
    日期验证 正则表达式
    时间验证 正则表达式
    Reporting Services SharePoint AddIn Setup Problems
    char、varchar、text和nchar、nvarchar、ntext的区别
  • 原文地址:https://www.cnblogs.com/zengqh/p/2815501.html
Copyright © 2011-2022 走看看