Jump to content
  • Advertisement
Sign in to follow this  
grunt123

generating mipmaps manually

This topic is 3754 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 generate mipmap levels manually in GPU. I have a rendertarget (created to have 4 mipmap levels) where i render some reflection map on it (at mipmap level 0) After that, i want to generate sub mipmap levels manually using shaders. Basically, i need to know how you can specify source mipmap level texture, and how to specify destination mipmap level. thanks a lot.

Share this post


Link to post
Share on other sites
Advertisement
Once you have a texture bound, you can sample from different mip levels in the shader. Render targets are surfaces, meaning you can grab a surface level directly from the texture and make that the render target. So the process might go something like:

1) Bind texture, set mip level 1 as target. In shader, sample from level 0.
2) Set mip level 2 as target. In shader, sample from level 1.
3) Etc.

Your shader should also just pass the texture sample straight to the output. If you sample from the center of four texels in the source texture, the hardware will automatically blend them for you, given you have linear blending enabled.

Share this post


Link to post
Share on other sites
I'm following the above mentioned method ... and destination render target (mipmap texture) is sampling only part of the source texture. (1/4 of the source texture to be exact) I'm using (0,0) to (1,1) texture coordinate ... any idea on why this is happening?

btw, i'm using 1024x1024 res texture as my default texture (mipmap 0) and try to render 3 sublevels. (so, 512x512, 256x256, 128x128) For 512x512, it's rendering 1/4 of the default texture (top-right portion of the default texture), for 256x256, 1/8 of the default texture (top-right), and for 128x128, 1/16 of the default texture (top-right)

[Edited by - grunt123 on June 9, 2008 8:55:54 PM]

Share this post


Link to post
Share on other sites
umm ... maybe, i can't directly set submiplevel as render target? Do i need to create another render target (that has same size as the original render target texture) and downsample it and then copy it to sub-miplevel?

Share this post


Link to post
Share on other sites
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!