本文介绍了如何从延迟着色中的光几何体的内部绘制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我正在尝试使用OpenGL和GLSL实现延迟着色器,并且我遇到了光几何体的麻烦。这些是我采取的步骤:I'm trying to implement a deferred shader with OpenGL and GLSL and I'm having trouble with the light geometry. These are the steps I'm taking:Bind multitarget framebufferRender color, position, normal and depthUnbind framebufferEnable blendDisable depth testingRender every lightEnable depth testingDisable blendRender to screen但是因为我只渲染正面,当我在一个灯光,它完全消失,渲染的背面不工作,因为我会得到双倍的光功率(当在里面,一半[或正常的金额])。But since I'm only rendering the front face, when I'm inside a light it disappears completely, rendering the back face does not work, since I would get double the light power (And when inside, half [or the normal amount]).如何从内部渲染相同的光值和外部的光几何?How can I render the same light value from inside and outside the light geometry?推荐答案如果我记得正确,在我的延迟渲染器只是渲染光体积的背面。 缺点是你不能深度测试,你将只知道光计算完成后几何的背后,并丢弃像素。 另一个答案解释,你可以做深度测试。 If i remember correctly, in my deferred renderer i just render only the backfaces of the light volume. The drawback is you cannot depth test, you will only know if a light is behind a geometry after the light calculation is done and discard the pixel.As another answer explained, you can do depth testing. Test for greater or equal to see if the backface is behind or on a geometry, therefore intersects with the surface of the geometry.或者,您可以检查您是否位于几何图形的内部渲染时光量和切换前面。Alternatively you could check if you are inside the light volume when rendering and switch front faces accordingly. 这篇关于如何从延迟着色中的光几何体的内部绘制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-21 06:57