Linear or non-linear shadow maps?
Quote:
Original post by RobMaddison
I understand that, for aliasing mitigation, it might be beneficial to use linear depth maps as opposed to non-linear depth maps when rendering to a shadowmap floating point texture, but how is that normally achieved? Is it as simple as converting the regular float depth value to a 16.16 fixed point float or something like that?
First, some background on depth buffers. The "problem" with depth buffers is that with a perspective projection, the resulting depth value you get by dividing z by w will increase non-linearly from 0 to 1 as you move from the near-clip plane from the far-clip plane. So you end up with most of your viewable range ending up in the [0.9, 1.0] range which gives you a very uneven distribution of precision for your depth buffer. See this and this for more info.
Now for shadow maps, whether this is an issue depends on how you're storing your shadow maps and also the type of light source. For lights where you use a perspective projection for generating the shadow map (usually spot and point lights), this can be a problem if you store z/w in your shadow map. If you're manually writing the depth to a floating-point render target the problem is even worse...this is because floating-point values have more precision closer to 0 than they do closer to 1, and this compounds with the perspective projection problem to give you even more error. But for this particular case you have a very simple remedy: just store something other than z/w. For instance you can store the world-space distance from the light position to the pixel position, or you can store view-space z. For directional lights an orthographic projection is typically used, and with an orthographic projection your z/w value will be increase linearly so you won't have precision distribution problems.
Where things get tricky is if you don't write your shadow map values into a render target, and instead just directly sample a depth buffer. This is very common in commercial games, since it saves you from having to write to a render target in your shadow map generation step. This saves you bandwidth and memory, and also most modern GPU's have some sort of "fast-z" mode which allows to operate more quickly when only writing z values. In these cases you can't directly control the z value being output into your depth buffer unless you output depth from your pixel shader, and doing that is a pretty bad idea since it disables early-z optimizations. Also if you try to muck with the the z and w values in your vertex shader, you'll usually end up breaking some combination of rasterization, early-z, or z compression. The only remedy I know of for this situation is to use a floating-point depth buffer (if it's available), and flip the near and far planes in your projection.
Quote:
Original post by RobMaddison
Secondly, I've read in several places that there is some hardware-assistance when dealing with shadowmaps - could someone please explain what this assistance is exactly?Thanks in advance
This typically refers to Nvidia's hardware PCF extension, which has been around for a long time. Basically it performs 2x2 PCF on the depth values for you in the texture unit, so that you don't have write pixel shader code for doing the 4 samples, the 4 compares, and the filtering. It's still available as a "driver hack" in D3D9, but in 10/11 it's no longer necessary since the API has generalized support for performing a compare operation during a texture fetch. ATI actually supports the D3D9 hack for their most recent hardware.
Linear or non-linear shadow maps?的更多相关文章
- 一个简单的GI--Reflective Shadow Maps
Reflective Shadow Maps是一种简单的GI,虽然名字带有Shadow Maps,但是和Shadow Maps没有什么关系,是在screen space的一种方法,不像光线追踪和辐射度方 ...
- Linear Equations in Linear Algebra
Linear System Vector Equations The Matrix Equation Solution Sets of Linear Systems Linear Indenpende ...
- [Scikit-learn] 1.1 Generalized Linear Models - from Linear Regression to L1&L2
Introduction 一.Scikit-learning 广义线性模型 From: http://sklearn.lzjqsdd.com/modules/linear_model.html#ord ...
- PRML读书会第四章 Linear Models for Classification(贝叶斯marginalization、Fisher线性判别、感知机、概率生成和判别模型、逻辑回归)
主讲人 planktonli planktonli(1027753147) 19:52:28 现在我们就开始讲第四章,第四章的内容是关于 线性分类模型,主要内容有四点:1) Fisher准则的分类,以 ...
- 机器学习笔记1——Linear Regression with One Variable
Linear Regression with One Variable Model Representation Recall that in *regression problems*, we ar ...
- Note for video Machine Learning and Data Mining——Linear Model
Here is the note for lecture three. the linear model Linear model is a basic and important model in ...
- Python Linear algebra
Linear algebra 1.模块文档 NAME numpy.linalg DESCRIPTION Core Linear Algebra Tools ---------------------- ...
- 个案排秩 Rank (linear algebra) 秩 (线性代数)
非叫“秩”不可,有秩才有解_王治祥_新浪博客http://blog.sina.com.cn/s/blog_8e7bc4f801012c23.html 我在一个大学当督导的时候,一次我听一位老师给学生讲 ...
- 【Linear Regression】林轩田机器学习基石
这一节开始讲基础的Linear Regression算法. (1)Linear Regression的假设空间变成了实数域 (2)Linear Regression的目标是找到使得残差更小的分割线(超 ...
随机推荐
- 命令行参数 main()函数设计
一.main()函数的形式 int main( void )--无参数形式 { ... return 0; } int main( int argc, char *argv[] )--带参数形式 { ...
- 管理表空间和数据文件<六>
数据库管理 -- 管理表空间和数据文件 介绍 表空间是数据库的逻辑组成部分.从物理上讲,数据库数据存放在数据文件中:从逻辑上讲,数据库则是存放在表空间中,表 空间由一个或多个数据文件组成. 数据库 ...
- Android之ImageView 设置宽高
方案一: 设置布局参数 imageView.setLayoutParams(new LinearLayout.LayoutParams(newWidth, newWidth));
- 如何进行正确的SQL性能优化
在SQL查询中,为了提高查询的效率,我们常常采取一些措施对查询语句进行SQL性能优化.本文我们总结了一些优化措施,接下来我们就一一介绍. 1.查询的模糊匹配 尽量避免在一个复杂查询里面使用 LIKE ...
- ooad单例模式-Singleton
单例模式Singleton 主要作用是保证在Java应用程序中,一个类Class只有一个实例存在. 比如建立目录 ...
- java多条件不定条件查询
网站或各类管理系统都会用到搜索,会用到一个或多个不确定条件搜索,单条件搜索比较简单,有时候会有多个条件共同查询,如果系统中已经提供了相关的方法供你使用最好,像我做这老系统改版,需要添加搜索,就要自己写 ...
- HDU 1754 I Hate It (线段树)
题意:略. 析:裸的线段树. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include < ...
- Xcode配置.pch文件
--到Xcode7都可以这么解决.亲测. 发现一个好东西.就是这个.pch文件.我的理解是他里面存放了我们在各个controller里面需要的头文件,那这样一来,就免去了在不同的ViewControl ...
- 个性二维码开源专题<基础篇>
二维码原理介绍: 二维码为什么是黑白相间的?黑色表示二进制的“1”,白色表示二进制的“0” “我们之所以对二维码进行扫描能读出那么多信息,就是因为这些信息被编入了二维码之中.”黄海平说,“制作二维码输 ...
- [自娱自乐] 2、超声波测距模块DIY笔记(二)
前言 上一节我们已经大致浏览下目前销售的超声波测距模块同时设计了自己的分析电路,这次由于我买的电子元件都到了,所以就动手实验了下!至写该笔记时已经设计出超声波接收模块和超声波发射模块,同时存在超声波发 ...