opengl - 线性过滤可以用于 MSAA 纹理到非 MSAA 纹理的 FBO blit 吗?

标签 opengl textures framebuffer blit msaa

我有两个 2D 纹理。第一个是 MSAA 纹理,使用目标 GL_TEXTURE_2D_MULTISAMPLE .第二个,非 MSAA 纹理,使用目标 GL_TEXTURE_2D .

根据 OpenGL 的 spec on ARB_texture_multisample , 仅 GL_NEAREST在绘制 MSAA 纹理时是一个有效的过滤选项。

在这种情况下,这两个纹理都附加到 GL_COLOR_ATTACHMENT0通过它们各自的 Framebuffer 对象。它们的分辨率也相同(据我所知,在将 MSAA 传送到非 MSAA 时,这是必要的)。

因此,鉴于当前的限制,如果我将持有 MSAA 的 FBO 转为持有非 MSAA 的 FBO,我还需要使用 GL_NEAREST作为过滤选项,或者是 GL_LINEAR有效,因为这两个纹理都已经被渲染到了?

最佳答案

过滤选项仅在您使用 时起作用。来自 的样本纹理。在您 时,它们不起作用渲染到 纹理。

从多重采样纹理中采样时,GL_NEAREST确实是唯一受支持的过滤器选项。您还需要在 GLSL 代码中使用特殊的采样器类型 (sampler2DMS),并带有相应的采样指令。

我实际上在规范中找不到任何将过滤器设置为 GL_LINEAR 的内容对于多样本纹理是一个错误。但过滤器根本没有使用。从 OpenGL 4.5 规范(强调添加):

When a multisample texture is accessed in a shader, the access takes one vector of integers describing which texel to fetch and an integer corresponding to the sample numbers described in section 14.3.1 determining which sample within the texel to fetch. No standard sampling instructions are allowed on the multisample texture targets, and no filtering is performed by the fetch.



使用 glBlitFramebuffer() 在多样本和非多样本纹理之间进行位 block 传输,过滤器参数可以是 GL_LINEARGL_NEAREST ,但在这种情况下被忽略。从 4.5 规范:

If the read framebuffer is multisampled (its effective value of SAMPLE_BUFFERS is one) and the draw framebuffer is not (its value of SAMPLE_BUFFERS is zero), the samples corresponding to each pixel location in the source are converted to a single sample before being written to the destination. filter is ignored.



这是有道理的,因为在这种情况下,源矩形和目标矩形的大小需要相同:

An INVALID_OPERATION error is generated if either the read or draw framebuffer is multisampled, and the dimensions of the source and destination rectangles provided to BlitFramebufferare not identical.



由于仅在拉伸(stretch)图像时应用过滤器,因此在这种情况下无关紧要。

关于opengl - 线性过滤可以用于 MSAA 纹理到非 MSAA 纹理的 FBO blit 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30720791/

相关文章:

graphics - DXT2/3 和 DXT4/5 纹理格式有什么区别?

linux - linux framebuffer 驱动程序是视频卡驱动程序吗?

ios - 离屏渲染 Metal

java - Wavefront .obj .Mtl 结构

iphone - 如何在iPhone上更快地插入像素?

android - 如何更改 Android 的默认帧缓冲区?

c++ - 这些 OpenGL 函数末尾需要 "3f"吗?

c++ - sfgui 没有构建,看起来像是 opengl 的问题

c++ - 像素数据传输 : 24BPP images and GL_UNPACK_ALIGNMENT set to 4

java - 提前更新场景,同时仍然渲染前一帧