   How to generate custom Mipmaps using HLSL?
  Hi,  I have a high-resolution image as a input texture, and I want to generate a MipMap texture object based on my algorithm for it. Is HLSL possible to do it and how?   
  Sure. Just set the render target to point to the MIP level of the texture you want to generate, then execute as normal. The DirectX SDK HDRLighting example does something somewhat similar to this, though as I recall they don't use MIP levels specifically, instead doing downsampling to individual render targets with a single MIP level. This might be a D3D9 limitation, however, thus this may not work if that's what you're using.   ;Quote:Original post by InvalidPointerSure. Just set the render target to point to the MIP level of the texture you want to generate, then execute as normal. The DirectX SDK HDRLighting example does something somewhat similar to this, though as I recall they don't use MIP levels specifically, instead doing downsampling to individual render targets with a single MIP level. This might be a D3D9 limitation, however, thus this may not work if that's what you're using.Thanks for your reply. But as I known, DX9 is not support MRT for different size rendertarget, is DX10 support it?   ;  Surface of every dx texture has mipmaps at its creation.You can retrieve any of theese surfaces by calling dxtexture->GetSurface(level of mip);If you render to theese surfaces, dx texture will use those.If you are after an algorithm that creates mip maps, you do it by scaling down the picture.   ;Quote:Original post by Rfy LeeThanks for your reply. But as I known, DX9 is not support MRT for different size rendertarget, is DX10 support it?Even in DX10 and DX11 all render targets must be the same size. This is so that you can have a 1:1 ratio between pixel shader executions and texels in the render target.;  Maybe I understood you wrong, but how is it possible to render to a shadow map then? Or is that something different?   ;Quote:Original post by mind in a boxMaybe I understood you wrong, but how is it possible to render to a shadow map then? Or is that something different?Shadow map is a whole separate scene pass not MRT.   ;Quote:Original post by MJPQuote:Original post by Rfy LeeThanks for your reply. But as I known, DX9 is not support MRT for different size rendertarget, is DX10 support it?Even in DX10 and DX11 all render targets must be the same size. This is so that you can have a 1:1 ratio between pixel shader executions and texels in the render target.So I've decided to run multipass to generate my custom Mip-mapIs it possible for me to set Level i as the input texture and Level i+1 as the render target in a pass(I use DX10). And is there any way that I can check the each level's data of the texture to do some debug work?   ;  I'm not sure if you can have the same resource bound as a shader resource view and a render target simultaneously in D3D10. It *might* work if you create a shader resource view that only views 1 mip level (in D3D10_SHADER_RESOURCE_VIEW_DESC, D3D10_TEX2D_SRV has "MostDetailedMip" and "MipLevel" parameters that you can set) but you'd have to try to know for sure.   ;  Say the image is 1024x1024:Make two rendertargets;RenderTarget A : the size of the first mip sublevel (512x512)Rendertarget B : and the other for the texture with the complete mipchain (1024x1024..1x1)1) Render the fullsize image into B2) Debug code: clear the entire rendertarget A to a random primary color every iteration3) Run a downsample shader from B@1024x1024 to A@512x512.  It will need to specifically address the miplevel of B correctly (tex2DLOD, point filtering probably), and clamp the UVs for the smaller subimages if your filter kernel is anything non-trivial4) Run a subimage copy shader from A to B+1repeat 2 and 3 and 4 until the mipchain is completed.   