使用OpenGL进行光照体积计算和渲染
项目描述
此软件包提供了名为 lightvolume 的模块,该模块提供对 trylock/visibility 的CFFI绑定。这反过来又是对Red Blob Games网站上详细记录(带有惊人的交互式演示)的可见性算法的C++实现。
API
首先,导入 lightvolume
import lightvolume
然后,我们可以创建多个投掷阴影的实体
objects = [ lightvolume.rect(0, 0, 500, 500), # outer bounds - this is needed lightvolume.rect(20, 30, 10, 20), lightvolume.rect(290, 300, 100, 300), ]
最后,我们可以渲染场景中光所投射的照明区域(OpenGL上下文必须已经创建并设置适当的GL状态)
light = 90, 200 lightvolume.draw_light(light, objects)
此模块旨在与适当的着色器一起使用,以提供衰减、表面交互(如凹凸映射)等功能。