从 OpenGL 渲染输出获取法线信息

发布于 2024-09-06 01:23:33 字数 229 浏览 1 评论 0原文

我会尽量保持简单。

我想要一种从帧缓冲区输出(或类似的)访问场景的正常信息的方法。使用 glGetTexImage 和 GL_DEPTH_COMPONENT 访问深度缓冲区的方式相同。

我知道我可以设置一个片段着色器,它输出 RGB 颜色空间中的法线信息,而这些信息又可以从渲染的图像中读取。不过我想知道是否有办法在 openGL API 中做到这一点。

我会根据要求尽可能地澄清任何事情, 谢谢

I'll try to keep this simple.

I want a way to access the normal information of the scene, from the Frame Buffer output (or similar). The same way one is able to access the Depth Buffer using glGetTexImage and GL_DEPTH_COMPONENT.

I know I could set up a fragment shader which outputs the normal information in RGB color space, which could in turn be read from the rendered image. I'm wondering however if there is a way to do this within the openGL API.

I'll clarify anything upon request as best as I can,
Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

屋檐 2024-09-13 01:23:33

您已经知道解决方案:将法线渲染为 RGB。没有可以使用的内置普通缓冲区。如果您不想渲染场景两次,请使用具有多个渲染目标 (MRT) 的帧缓冲区对象 (FBO)。然后,您可以将颜色和法线写入片段着色器中的单独纹理中。

You already know the solution: Render the normal as RGB. There's no built-in normal buffer you could use. If you don't want to render your scene twice, use framebuffer objects (FBO) with multiple render targets (MRT). Then you can write both color and normal into separate textures in your fragment shader.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文