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的目标是找到使得残差更小的分割线(超 ...
随机推荐
- 正则表达式匹配完整img标签php实现
处理html富文本的时候,碰到批量处理img标签,要把img标签格式化,并且去除不用的代码,class,各种data-等,首先想到使用正则匹配,然后处理匹配到的img标签和参数,经过一番尝试终于搞定了 ...
- jsp_设置错误页
在各个常用的web站点中,当一个页面出错后,会自动跳转到一个页面上进行错误信息的显示.下面我们说说这个操作是怎么实现的. 要想完成错误页的操作,在jsp页面必须满足两个条件: (1)指定错误出现时的跳 ...
- T4模板之初体验(语法)
一.什么是T4模板 T4是Text Template Transformation Toolkit(文本模板转换工具包)的四个英文首字母的简称.是微软提供的一种代码生成引擎. 在ADO.NET实体数据 ...
- hdu 5098 双队列拓扑排序
http://acm.hdu.edu.cn/showproblem.php?pid=5098 软件在安装之后需要重启才能发挥作用,现在给你一堆软件(有的需要重启有的不需要)以及安装这个软件之前需要哪些 ...
- 那些年我们学过的PHP黑魔法
那些年我们学过的PHP黑魔法 提交 我的评论 加载中 已评论 那些年我们学过的PHP黑魔法 2015-04-10 Sco4x0 红客联盟 红客联盟 红客联盟 微信号 cnhonker_huc 功能介绍 ...
- 《Automatic Face Classification of Cushing’s Syndrome in Women – A Novel Screening Approach》学习笔记
<针对女性库欣综合征患者的自动面部分类-一种新颖的筛查方法> Abstract 目的:库兴氏综合征对身体造成相当大的伤害如果不及时治疗,还经常是诊断的时间太长.在这项研究中,我们旨在测试面 ...
- 使用jsPlumb制作流程图设计器
jsPlumb是一个比较强大的绘图组件,它提供了一种方法,主要用于连接网页上的元素.在现代浏览器中,它使用SVG或者Canvas技术,而对于IE8以下(含IE8)的古董浏览器,则使用VML技术. 项目 ...
- TypeScript:类(Classes)
返回TypeScript手册总目录 传统的Javascript关注的是函数(function)和基于原型(prototype-based)的继承作为构建可重复使用组件的基本方式,但是与更舒服地使用面向 ...
- Python的with语句
写过多线程程序的人肯定对各种锁很熟悉,尤其是下面这种代码 def lock_usage: lock.Lock() if(...) : lock.Unlock() return lock.Unlock( ...
- MySql和SQL Server数据类型 对比
My Sql 数据类型 SQL Server 数据类型 Yes/No bit Smallint(字节型) tinyint Integer(长整型) int Real(单精度浮点型) real F ...