线性过滤是否可以用于将MSAA纹理转换为非MSAA纹理的FBO? [英] Can linear filtering be used for an FBO blit of an MSAA texture to non-MSAA texture?

查看:233
本文介绍了线性过滤是否可以用于将MSAA纹理转换为非MSAA纹理的FBO?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have two 2D textures. The first, an MSAA texture, uses a target of GL_TEXTURE_2D_MULTISAMPLE. The second, non MSAA texture, uses a target of GL_TEXTURE_2D.

根据OpenGL的关于ARB_texture_multisample的规范,只有GL_NEAREST是绘制MSAA纹理时的有效过滤选项.

According to OpenGL's spec on ARB_texture_multisample, only GL_NEAREST is a valid filtering option when the MSAA texture is being drawn to.

在这种情况下,这两个纹理均通过它们各自的Framebuffer对象附加到GL_COLOR_ATTACHMENT0.它们的分辨率也相同(据我所知,将MSAA转换为非MSAA时这是必需的.

In this case, both of these textures are attached to GL_COLOR_ATTACHMENT0 via their individual Framebuffer objects. Their resolutions are also the same size (to my knowledge this is necessary when blitting an MSAA to non-MSAA).

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

So, given the current constraints, if I blit the MSAA holding FBO to the non-MSAA holding FBO, do I still need to use GL_NEAREST as the filtering option, or is GL_LINEAR valid, since both textures have already been rendered to?

推荐答案

仅当您从纹理中采样时,过滤选项才起作用.当您渲染纹理时,它们不起作用.

The filtering options only come into play when you sample from the textures. They play no role while you render to the texture.

从多样本纹理采样时,GL_NEAREST实际上是唯一受支持的滤镜选项.您还需要在GLSL代码中使用特殊的采样器类型(sampler2DMS),并带有相应的采样说明.

When sampling from multisample textures, GL_NEAREST is indeed the only supported filter option. You also need to use a special sampler type (sampler2DMS) in the GLSL code, with corresponding sampling instructions.

我实际上在规范中找不到任何内容,这说明将多样本纹理的滤镜设置为GL_LINEAR是错误的.但是根本不使用过滤器.从OpenGL 4.5规范开始(强调):

I actually can't find anything in the spec saying that setting the filter to GL_LINEAR for multisample textures is an error. But the filter is not used at all. From the OpenGL 4.5 spec (emphasis added):

在着色器中访问多样本纹理时,该访问将使用一个整数向量(描述要提取哪个纹理像素)和一个整数(对应于14.3.1节中描述的样本编号)来确定要提取的纹理像素中的哪个样本.多样本纹理目标上不允许使用标准采样指令,并且提取操作不执行过滤.

要使用glBlitFramebuffer()在多样本纹理和非多样本纹理之间划痕, filter 参数可以是GL_LINEARGL_NEAREST,但是在这种情况下将被忽略.根据4.5规范:

For blitting between multisample and non-multisample textures with glBlitFramebuffer(), the filter argument can be either GL_LINEAR or GL_NEAREST, but it is ignored in this case. From the 4.5 spec:

如果读取的帧缓冲区是多采样的(其SAMPLE_BUFFERS的有效值为1)而绘制的帧缓冲区不是(其SAMPLE_BUFFERS的值为零),则与源中每个像素位置相对应的样本在转换为单个样本之前被写入目的地. 过滤器被忽略.

这是有道理的,因为在这种情况下存在一个限制,即源矩形和目标矩形的大小必须相同:

This makes sense because there is a restriction in this case that the source and destination rectangle need to be the same size:

如果对读取或绘制帧缓冲区进行了多次采样,并且提供给BlitFramebuffer的源矩形和目标矩形的尺寸不同,则会生成INVALID_OPERATION错误.

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.

由于仅在拉伸图像时才应用滤镜,因此在这种情况下没有关系.

Since the filter is only applied when the image is stretched, it does not matter in this case.

这篇关于线性过滤是否可以用于将MSAA纹理转换为非MSAA纹理的FBO?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆