Hi All. I am really confused on how to multisample textures in FBOs .I found some info on Multisampling in "OpenGL super bible" and in the examples from www.g-truc.ne . And I can't get a unified picture of how to do it right .What I want to do is to create an FBO , render my object with texture applied to it to the FBO's color attachment .After that I am reading the color attachment into pixels which I render to image file.
Now I found several options but none works for me . For example I see that it is possible to attach to FBO multisampled render buffers and multisampled tex images. I tried both.Reading from any of those pixels gets me an image with black screen.So anyone can answer me to the following questions? I do it with OpenGL 4.0 btw.
The texture for object material has to be defined as GL_TEXTURE_2D_MULTISAMPLE always?
FBO -what is the better way to compose it for depth and color attachments - using render buffers or textures?
What is going on the shader side ?
I have tried this :
Code :Color = texture(Diffuse, interpolateAtSample(Vert.Texcoord, gl_SampleID));
Still nothing . What do I miss? I set my context to use x8 level (out of 16) .
Also I can anyone explain this part of texture setup (taken from www.g-truc.ne) :
Code :glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, Texture2DName); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); gli::texture2D Image = gli::load(TEXTURE_DIFFUSE); for(std::size_t Level = 0; Level < Image.levels(); ++Level) { glTexImage2D( GL_TEXTURE_2D, GLint(Level), GL_RGB, GLsizei(Image[Level].dimensions().x), GLsizei(Image[Level].dimensions().y), 0, GL_RGB, GL_UNSIGNED_BYTE, Image[Level].data()); }
Are these mipmap levels? Do I have to do it for multisampling ?
Thanks in advance.