码迷,mamicode.com
首页 > 移动开发 > 详细

OpenGL.Tutorial16_ShadowMapping

时间:2019-04-29 22:39:21      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:dynamic   produces   rri   search   red   create   rom   shadows   min   

1、

2、

In Tutorial 15 we learnt how to create lightmaps, which encompasses static lighting. While it produces very nice shadows, it doesn’t deal with animated models.

Shadow maps are the current (as of 2016) way to make dynamic shadows. The great thing about them is that it’s fairly easy to get to work. The bad thing is that it’s terribly difficult to get to work right.

In this tutorial, we’ll first introduce the basic algorithm, see its shortcomings, and then implement some techniques to get better results. Since at time of writing (2012) shadow maps are still a heavily researched topic, we’ll give you some directions to further improve your own shadowmap, depending on your needs.

Basic shadowmap

The basic shadowmap algorithm consists in two passes. First, the scene is rendered from the point of view of the light. Only the depth of each fragment is computed. Next, the scene is rendered as usual, but with an extra test to see it the current fragment is in the shadow.

The “being in the shadow” test is actually quite simple. If the current sample is further from the light than the shadowmap at the same point, this means that the scene contains an object that is closer to the light. In other words, the current fragment is in the shadow.

The following image might help you understand the principle :

3、

4、

5、

 

OpenGL.Tutorial16_ShadowMapping

标签:dynamic   produces   rri   search   red   create   rom   shadows   min   

原文地址:https://www.cnblogs.com/cppskill/p/10793267.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!