• Advertisement
Sign in to follow this  

select mimap level?

This topic is 1969 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

Hi,

I'm trying to sample a certain mipmap level of a mipmapped texture. How do I do that?


//do the downsampling
tex.bind();
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
glGenerateMipmap( GL_TEXTURE_2D );

//process the half res texture
glViewport( 0, 0, o->conf.SCREEN_WIDTH / 2, o->conf.SCREEN_HEIGHT / 2 );

half_fbo.bind();
shader->bind();

shader->pass_m4x4( o->ppl.get_projection_matrix(), "proj" );
shader->pass_m4x4( o->ppl.get_model_view_matrix(), "modelview" );
shader->pass_int( 0, "texture0" );

tex.bind();
//how do I select the desired mipmap level here?
quad.render();

shader->unbind();
half_fbo.unbind();


Best regards,
Yours3!f Edited by Yours3!f

Share this post


Link to post
Share on other sites
Advertisement
Since you're using GLSL you don't need to respecify any glTexParameter stuff; just use textureLod to sample the specific level you want: http://www.opengl.org/wiki/GLSL_Sampler#Lod_texture_access

Share this post


Link to post
Share on other sites
thank you both, I think I'll stick to the GLSL version, this seems more convenient.

Share this post


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

  • Advertisement