在OpenGL中将数据上传到多重采样纹理(Upload data to multisample texture in OpenGL)

编程入门 行业动态 更新时间:2024-10-25 10:28:08
在OpenGL中将数据上传到多重采样纹理(Upload data to multisample texture in OpenGL)

我想将数据从CPU上传到OpenGL中的多重采样2D纹理。 对于2D纹理,我可以使用该功能:

void glTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels);

将数据从像素推送到纹理。 如何对多重采样2D纹理做同样的事情?

I want to upload data from CPU to a multisample 2D texture in OpenGL. For 2D texture I could use the function:

void glTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels);

to push data from pixels to the texture. How can I do the same thing for multisample 2D texture?

最满意答案

您无法通过OpenGL的客户端访问多重采样纹理的图像数据。 唯一的方法是使用着色器和/或FBO。

从概念上讲,您可以将全屏四边形渲染为多重采样纹理,并在片段着色器中使用gl_SampleID来确定您当前正在写入的样本。 与gl_FragCoord结合使用,您可以例如索引到TBO,该TBO包含要存储在纹理中的原始每样本值。

但是,由于样品位置完全受GL控制,因此该操作是否有用是值得怀疑的。 因人而异。

You can't acces the image data of multisample textures via the client side of OpenGL. The only way around that is by using shaders and/or FBOs.

Conceptually, you can render a full-screen quad to a multisample texture and in the fragment shader, use gl_SampleID to determine which sample you are currently writing to. In combination with the gl_FragCoord, you can for example index into an TBO which holds the raw per-sample value you want to store in the texture.

However, as the sample locations are completely under the GL's control it is questionable if this operation is of any use. YMMV.

更多推荐

本文发布于:2023-07-06 07:55:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1047563.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:纹理   中将   数据   OpenGL   texture

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!