现在的位置: 首页 > 综合 > 正文

simple shadow mapping

2012年09月04日 ⁄ 综合 ⁄ 共 775字 ⁄ 字号 评论关闭

解决了project texture后,shadow mapping就比较容易了。

对于基于ogl的shadow mapping,基本上有如下几种做法:

1 采用GL_ARB_depth_texture, GL_ARB_shadow扩展。Pass1中以光源为视点渲染场景到帧缓存,然后将深度部分copy到depth texture;Pass2中以眼睛为视点,将depth texture投影到场景后使用GL_ARB_shadow扩展比较纹理值与纹理坐标的r值,判断该fragment是否处于阴影中。

2 采用GL_ARB_depth_texture, GL_ARB_shadow, WGL_ARB_pixel_format, WGL_ARB_pbuffer扩展。与做法1的区别仅在于Pass1的渲染目标由帧缓存改为了PBuffer。

3 采用GL_ARB_depth_texture, GL_ARB_shadow, WGL_ARB_pixel_format, WGL_ARB_pbuffer, WGL_ARB_render_texture, WGL_NV_render_depth_texture扩展。与做法2的不同之处在于不需要copy PBuffer到纹理,而是使用WGL_ARB_render_texture扩展直接渲染到纹理。

4 先得到depth texture,然后自己编写fragment shader来进行阴影测试。

目前1~3种做法都试过了,晚点用GLSL试试方法4。:)

 

Demo:

http://downloads.cnblogs.com/CGTeam/Member/Pointer/dlls.rar

http://files.cnblogs.com/Pointer/simple_shadow_mapping.rar

wasdqezx 控制视角

ijkluom, 控制光源

esc      退出

抱歉!评论已关闭.