如何在延迟阴影中从光线几何的内部绘制
How to draw from the inside of the light geometry in deferred shading
我试图用OpenGL和GLSL实现延迟着色器,我在光几何上遇到麻烦。以下是我正在采取的步骤:
Bind multitarget framebuffer
Render color, position, normal and depth
Unbind framebuffer
Enable blend
Disable depth testing
Render every light
Enable depth testing
Disable blend
Render to screen
但是因为我只渲染正面,当我在灯光里面的时候,它完全消失了,渲染背面不起作用,因为我将得到两倍的光功率(当我在里面的时候,一半[或正常量])。
我如何从内部和外部的光几何渲染相同的光值?
在我的例子中,我是这样做的:
Bind gbuffer framebuffer
Render color, position, normal
Unbind framebuffer
Enable blend
Enable depth testing
glDepthMask(0);
glCullFace(GL_FRONT); //to render only backfaces
glDepthFunc(GL_GEQUAL); //to test if light fragment is "behind geometry", or it shouldn't affect it
Bind light framebuffer
Blit depth from gbuffer to light framebuffer //so you can depth-test light volumes against geometry
Render every light
如果我没记错的话,在我的延迟渲染器中,我只渲染光体的背面。缺点是你不能进行深度测试,你只能在光计算完成后知道光是否在几何后面,并丢弃像素。正如另一个答案所解释的那样,你可以进行深度测试。测试大于或等于,以查看背面是否在几何图形的后面或上面,因此与几何图形的表面相交。
或者你可以在渲染时检查你是否在灯光体积内,并相应地切换正面
相关文章:
- 将函数类成员映射到类本身内部
- Boost Spirit,获取迭代器内部语义动作
- 我不明白为什么我声明一个空的内部结构并将其传递给构造函数
- 内联函数中具有内部链接的全局变量
- 在函数内部的声明中初始化数组,并在外部使用它
- 如何在不知道向量大小的情况下输入向量内部的向量?
- QuadTree只在窗口的右上角绘制
- 绘制旋转的三角形
- flutter:即使shouldRepaint()返回true,自定义画家也不会重新绘制
- 卷曲bracers内部结构的声明
- 从函数角度看ID到文件路径的内部与外部映射
- spdlog标头仅与外部fmt一起使用.spdlog错误:'内部':不是'fmt'
- 如何在pugixml中获取节点的内部XML
- 使用C链接在函数内部创建C++模板
- 从图像中裁剪椭圆形状,而不是在OpenCV中在内部绘制
- 使用内部灰泥构建器绘制地图
- 如何在圆角矩形或圆形内部绘制图像
- gtkmm 2.4 开罗时钟示例在修改为在 HBox 内部而不是主窗口内绘制时不起作用
- c++opengGL:绘制多边形+图像处理内部像素
- 如何在延迟阴影中从光线几何的内部绘制