简体   繁体   English

OpenGL FBO颜色附件缩小

[英]OpenGL FBO colour attachment shrinking

I have an FBO with 4 frame buffer textures. 我有一个带有4帧缓冲区纹理的FBO。 These textures are 4 different sizes. 这些纹理有4种不同的大小。

  • texture 1 = 512 * 360 纹理1 = 512 * 360
  • texture 2 = 256 * 180 纹理2 = 256 * 180
  • texture 3 = 128 * 90 纹理3 = 128 * 90
  • texture 4 = 64 * 45 纹理4 = 64 * 45

The problem is that if texture 4 and texture 1 for example are attached using: 问题是,例如,如果使用以下方式附加纹理4和纹理1:

    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, GL_TEXTURE_2D, bl_64, 0);
    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, bl_128, 0);

When I draw to texture 1 the image on the texture only takes up the size of texture 4. 当我绘制到纹理1时​​,纹理上的图像仅占据纹理4的大小。

 m_blurrFBO.DrawingBind();   
 glUniformSubroutinesuiv(GL_FRAGMENT_SHADER, 1, &BlurrPass);  
 glViewport(0, 0, 512, 360);
 glDrawBuffer(GL_COLOR_ATTACHMENT0);
 DrawQuad();       
 FBO::UnbindDrawing();

The reason I'm using 4 different textures with different sizes is that I'm down sampling the same image 4 times each half the size as the last. 我使用4个具有不同大小的不同纹理的原因是,我对同一图像进行下采样4次,每次采样的大小是最后一次的一半。

The problem is the code has been tested on 5 different computers all with either AMD or NVIDIA cards and it works as expected. 问题在于该代码已经在5台均装有AMD或NVIDIA卡的不同计算机上进行了测试,并且可以正常工作。 I have the up to date drivers for my nvidia gtx 550 is this a known problem ? 我的nvidia gtx 550驱动程序是最新的,这是一个已知问题吗?

日落应该占据屏幕的整个尺寸

This problem is called "That's how OpenGL works. " 这个问题称为“ OpenGL的工作方式。

The total size of a framebuffer is based on the smallest size, in each dimension, of all of the attached images. 帧缓冲区的总大小基于所有附加图像中每个维度的最小大小。 You are not allowed to render outside of any attached image. 不允许在任何附加图像之外进行渲染。 Even if you use write masking or draw buffers state so that you don't actually render to it, the available viewport size is always limited to the smallest size of the attached images. 即使您使用写遮罩绘制缓冲区状态,以便实际上不对其进行渲染,可用的视口大小也始终限于所附加图像的最小大小。

As a general rule, do not attach an image to a framebuffer unless you are serious about rendering to it. 通常,除非认真考虑对其进行渲染,否则请勿将图像附加到帧缓冲区。 If you want to do downsampling, swap FBOs or change attached images between each sampling pass. 如果要进行下采样,请在每次采样之间交换FBO或更改附加的图像。

Oh and BTW: it is undefined behavior (unless you're using GL 4.5 or ARB/NV_texture_barrier) to read from any texture object that is currently attached to the FBO . 哦,顺便说一句:这是未定义的行为(除非您使用GL 4.5或ARB / NV_texture_barrier),以读取当前附加到FBO的任何纹理对象 Again, write masks and draw buffers state is irrelevant; 同样,写掩码和绘制缓冲区的状态无关紧要。 what matters is that the image is attached . 重要的是图像已附加 So again, don't attach something unless you are writing to it. 同样,除非您正在写东西,否则请不要附加任何东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM