Jump to content

  • Log In with Google      Sign In   
  • Create Account

14 years ago on June 15th Gamedev.net was first launched! We want to thank all of you for being part of our community and hope the best years are ahead of us. Happy birthday Gamedev.net!

#ActualYours3!f

Posted 31 August 2012 - 01:48 PM

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

#2Yours3!f

Posted 31 August 2012 - 01:47 PM

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

#1Yours3!f

Posted 31 August 2012 - 01:45 PM

Hi,

I'm trying to sample a certain 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 mipmap level here?
  quad.render();

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

Best regards,
Yours3!f

PARTNERS