LangFox
12-08-2009, 07:37 AM
Hi guys,
I tried multisample texture with fbo. The fbo is completed, and object is rendered. But the result is NOT multisampled, just like rendered to normal texture with normal fbo. I can't figure it out...
Code to generate texture and fbo:
glGenFramebuffers(1, &m_FrameBuffer);
glBindFramebuffer(GL_FRAMEBUFFER, m_FrameBuffer);
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, texture);
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 16, GL_RGBA16F, 512, 512, false);
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texture, 0);
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, texture);
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 16, GL_DEPTH_COMPONENT32, 512, 512, false);
glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, texture, 0);
Code to bind multisample texture:
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, texture);
Fragment Shader:
#version 150
uniform sampler2DMS g_Texture0;
out vec4 g_FragData;
void main()
{
g_FragData = texelFetch(g_Texture0, ivec2(gl_FragCoord.xy), 16);
}
I tried multisample texture with fbo. The fbo is completed, and object is rendered. But the result is NOT multisampled, just like rendered to normal texture with normal fbo. I can't figure it out...
Code to generate texture and fbo:
glGenFramebuffers(1, &m_FrameBuffer);
glBindFramebuffer(GL_FRAMEBUFFER, m_FrameBuffer);
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, texture);
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 16, GL_RGBA16F, 512, 512, false);
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texture, 0);
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, texture);
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 16, GL_DEPTH_COMPONENT32, 512, 512, false);
glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, texture, 0);
Code to bind multisample texture:
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, texture);
Fragment Shader:
#version 150
uniform sampler2DMS g_Texture0;
out vec4 g_FragData;
void main()
{
g_FragData = texelFetch(g_Texture0, ivec2(gl_FragCoord.xy), 16);
}