Hybrid-resolution shadow mapping design and hard shadows anti-aliasing in special effects movies
-
摘要: 在实时的虚拟场景渲染中,为减少阴影图算法由分辨率不足导致的阴影走样,提出了利用并行线性扫描的混合分辨率阴影图算法。首先,从光源视角生成高分辨率阴影图,利用并行线性扫描算法对深度均值差进行计算和分析,自底向上的合并纹素,建立纹素之间的索引关系并讨论混合分辨率阴影图的存储。在渲染阶段,利用混合分辨率阴影图进行深度测试,绘制实时的反走样阴影。实验表明,与标准阴影图相比,混合分辨率阴影图能提高20%以上的重要区域分辨率,明显改善阴影边界锯齿走样,使Dragon等模型的计算时间减少9%~18%。经实际应用验证,混合分辨率阴影图是一种有效的实时阴影绘制算法,可有效减少阴影图算法的走样。Abstract: In order to reduce the aliasing artifact due to the finite resolution of shadow mapping in real-time rendering, we propose a hybrid-resolution shadow map based on a parallel line-sweep algorithm.First, our method generates a high-resolution depth map from light's view, and analysizes the mean difference of depth using parallel line-sweep algorithm with threads and kernels.Then this method merges the texels from bottom to top to establish indexes for the texels and discusses the storage methods.At rendering pass, our method renders shadows in real time using the hybrid-resolution shadow map for occluder detection.Experimental results indicate that our algorithm improves the resolution of boundaries' area over 20% compared with standard shadow mapping and reduces the time consumption about 9%-18% running by Dragon model.Verified by practical application, the hybrid-resolution shadow mapping is an effective real-time shadow rendering algorithm, which can effectively reduce the aliasing artifact.
-
Key words:
- shadow map /
- hard shadow /
- hybrid-resolution /
- anti-aliasing
-
图 4 标准阴影图算法(左列)与混合分辨率阴影图算法(右列) 的效果对比,阴影图分辨率分别为(a)1 024×1 024,(b)2048×2 048 降至1 024×1 024,(c)512×512,(d)1 024×1 024 降至512×512,(e)2 048×2 048,(f)4 096×4 096 降至2048×2 048
Figure 4. Contrast of SM(left column) and HRSM(right column),with the resolution of shadow maps are (a)1 024×1 024,(b)2 048×2 048 down to 1 024×1 024,(c)512×512,(d)1 024×1 024 down to 512×512,(e)2 048×2 048,(f)4 096×4 096 down to 2 048×2 048
图 7 不同初始分辨率的混合阴影图算法绘制效果对比,(a)和(d)为标准阴影图512×512绘制效果; (b)、(c)和(e)为混合分辨率阴影图的分辨率分别由2 048×2 048降至512×512,4 096×4 096降至512×512 以及1 024×1 024降至512×512的绘制效果
Figure 7. Contrast of HRSM with different initial resolution,(a) and (d) are standard shadow map with resolution of 512×512; (b),(c) and (e) are HRSM with resolution of 2 048×2 048 to 512×512,4 096×4 096 to 512×512 and 1 024×1 024 to 512×512
算法1
Algorithm 1 Line-sweep shadow map pos is the coordinate of the first step in the shadow map and st is a vector for one step along the scanline. While ( steps--) { float3 sampleTexel(pos) ; for all (mapstexel s,s∈input) do D1=Depth At Point(s. Pos.Top Left()) D2=Depth At Point(s. Pos.Topt Right()) D3=Depth At Point(s. Pos.Bottom Left()) D4=Depth At Point(s. Pos.Bottom Right ()) If (Mean Difference(D1,D2,D3,D4)≤ε0)then {Parent Point=Merge Average(D1,D2,D3,D4) If (s.position) Output.Add(s.Parent Point()); Store normal and ID to new shadow map} else output.Add(s)} pos+=st; } 算法2
Algorithm 2 ShadowTest for Each view sample Project to light space intersect with texeli read from HRSM if texeli is indexed to subtexel,search index until end then Read dp~ in HRSM if dp≤dp~ then return true; else return false;} else Read dp~ in HRSM if dp≤dp~ then return true; else return false;} 表 1 SM与HRSM下Dragon的计算时间消耗情况(单位:ms)
Table 1. SM and HRSM time consuming of Dragon(Unit:ms)
阴影图分辨率 SM(T1) HRSM(T2) (T2-T1)/T1/% 1 024×1 024 32.6 29.5 9 2 048×2 048 34.9 30.8 11 4 096×4 096 62.9 51.5 18 表 2 不同测试模型计算时间 (单位:ms)
Table 2. Different model time consuming(Unit:ms)
模型 顶点 多边形 标准阴影图(SM) 混合分辨率阴影图(HRSM) 1 024×1 024 2 048×2 048 1 024×1 024 2 048×2 048 Dragon 1 526 433 2 400 000 32.6 34.9 29.5 30.8 Bunny 872 661 1 671 984 23.5 28.2 20.6 27.3 Ball model 134 184 268 800 9.8 12.9 8.5 11.2 Spheres 1 200 12 000 5.3 7.2 5.0 6.3 -
[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13]