generating mipmaps manually

Started by
2 comments, last by grunt123 15 years, 10 months ago
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.
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.
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]
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?

This topic is closed to new replies.

Advertisement