Jump to content
  • Advertisement
Sign in to follow this  
orange451

get mipmaps from framebuffer

This topic is 653 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello!

 

In my project, I render a deferred scene to a final frame buffer. Afterwards, I do a screen-space reflection pass. I want to mix in some glossiness and specularity with the SSR, and I thought the best way would be to use the mipmaps from the final scene framebuffer.

 

However, in my shader, whenever I call textureLod( sampler, position, mip ), it always returns the color value from the main sampler, not the mipmaps no matter what the mip level is.

 

Here is the generic code I use to initialize a framebuffer:

this.fboId = glGenFramebuffers();
this.textureId = glGenTextures();
this.depthTextureId = glGenTextures();

// Initialize color texture
glBindTexture(GL_TEXTURE_2D, textureId);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
int internalFormat = highPrecision?(soloChannel?GL_R16F:GL_RGBA16F):(soloChannel?GL_R8:GL_RGBA8);
glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, width, height, 0, GL_RGBA, GL_FLOAT, (java.nio.ByteBuffer)null);

// Initialize depth texture
glBindTexture(GL_TEXTURE_2D, depthTextureId);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, width, height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, (java.nio.ByteBuffer)null);

// Bind FBO
glBindFramebuffer(GL_FRAMEBUFFER, fboId);

// Bind diffuse to FBO
glBindTexture(GL_TEXTURE_2D, textureId);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureId, 0);
glGenerateMipmap(GL_TEXTURE_2D);

// Bind depth to FBO
glBindTexture(GL_TEXTURE_2D, depthTextureId);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthTextureId, 0);
glGenerateMipmap(GL_TEXTURE_2D);

Can anyone spot what I am doing wrong?

Edited by orange451

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!