select mimap level?

Started by
3 comments, last by Yours3!f 11 years, 7 months ago
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
Advertisement
duplicate :D
http://www.opengl.org/sdk/docs/man/xhtml/glTexParameter.xml

MIN_LOD, MAX_LOD, BASE_LEVEL, MAX_LEVEL

Setting 2 of those should do it.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

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

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

thank you both, I think I'll stick to the GLSL version, this seems more convenient.

This topic is closed to new replies.

Advertisement