Manual generation of mip maps?

Started by
1 comment, last by Hodgman 7 years, 11 months ago

Hi guys,

MonoGame Dev here (aka XNA with SharpDX)

how would I go about manually generating mip maps for a rendertarget (or texture for that matter)?

I often read that for min/max shadow mip chains are generated manually (in this example obviously not just an average downsample but rather a min/max) as well as for bloom RTs.

I presume in these papers the engineers are actually writing to the corresponding mip maps instead of having a dozen other renderTargets called rtMip0, rtMip1 etc.

As of now I use several differently sized renderTargets for my bloom and such, but i feel it would be more convenient to store it all in one RT with its child MIPs - especially for min/max shadows.

So - if that is indeed feasible - how would I go about it?

Thanks in advance.

Advertisement

the dx API has calls to add / load your own mip maps. check the docs.

its usually used to make your own mip maps in a separate app that doesn't blend the background into the image the way dx does. blending in the background is what creates the back halo around the edge of sprite textures, and is why alpha tests must be something like "value<128" instead of "value==0".

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

I've got no monogame experience... Which version of D3D is it using?

In D3D11, a texture resource is separate from "views" of that resource. A render-target view is basically a link to a particular mip-level in the texture resource. So, you can make an array of RTV's for your texture's mip-chain, and then render to each of them one by one.

In D3D9, a "surface" acts similarly to an RTV. If you've got a renderable texture with a mip-chain, you can use IDirect3DTexture9::GetSurfaceLevel to obtain one writable surface for each mipmap, which can be bound as a render-target.

This topic is closed to new replies.

Advertisement