步履蹒跚

知其然,知其所以然 - real-time rendering.
posts - 85, comments - 172, trackbacks - 0, articles - 0

2005年2月7日

解决了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://www.cnblogs.com/Files/Pointer/simple_shadow_mapping.rar

wasdqezx 控制视角
ijkluom, 控制光源
esc      退出


posted @ 2005-02-07 23:36 Pointer 阅读(511) | 评论 (0)编辑