Archived

This topic is now archived and is closed to further replies.

Mip mapping

This topic is 4952 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

I have a texture thats 800x600. I am going to create a texture 400x300, 200x150, 100x75, 50x34.5, 25x16.75 Is that correct, I know examples use 256x256,128x128, etc. Not every texture is that nice. haha. So can I create those textures and add the surfaces onto the main one and do mip mapping? Thanks Jeff.

Share this post


Link to post
Share on other sites
Well, first off, thats a mighty big texture!! ;O)

secondly if you''re using OpenGL im fairly sure textures have to be a power of 2 eg: 512x512, 512x256, 128x64 etc

Im not sure about D3D but I''d bet it was the same.

Also you''re almost certainly going to get a boost by using power of 2 texture than not..thats if the latter are acceptable at all.

Hope that helps.

GCoder

Share this post


Link to post
Share on other sites
Appologies for not answering your question directly!

im quite distracted today

There are mipmapping examples on nehe''s site if you''re using Opengl otherwise I think theres probably D3D examples here on gamedev in the articles section?...worth a look.

otherwise....good old Google! :o)

GCoder

Share this post


Link to post
Share on other sites
If you are using OpenGL or Direct3D, then you can simply supply one version of your texture (the largest version) and the API will create all the necessary mipmaps for you. There''s no need to create all the different sized versions of your texture.

Share this post


Link to post
Share on other sites
Yea, I already searched but all the examples say 256x256, 128x128, etc. Non show a 800x600 so I dont know if I just scale it down by 50% will mip mapping still work?? or do I need to convert my texture to 1024,x1024 for it to work, that would suck.

Thanks
Jeff.

Share this post


Link to post
Share on other sites
why not just have filler on the edges? take your 1024x1024 texture, put your actual 800x600 of data in the top left corner, and set your mapping coords so that the poly on displays the 800x600 area?

also, on a little side note, you''re going to have a really hard time getting 50x34.5 and 25x16.75

Share this post


Link to post
Share on other sites
crap, I forgot the other thing I was going to say! I''m pretty sure that OpenGL will allow you to use non-power of 2 textures (though, I''m sure it''s slower). Nehe mentions it somewhere on his site. I know that in my application I''ve got a poly that''s mapped with a non-po2 image, but I don''t really remember what specifically I did to put it in there. Just have to make sure your poly is the same ratio as the image, or you''ll have stretching

Share this post


Link to post
Share on other sites
If I add filler to the 800x600 image, black, will that mess up the UV coords, and I will need to adjust that or will it work, because 800x600 is still the same, its just extended??

Let me know please, thanks for your help.
Jeff

Share this post


Link to post
Share on other sites
it shouldn''t mess up the coords, ''cause they''re expressed in a range from 0.0-1.0 (unless, of course, you''re doing tiling). I''d try the built in mipmapping functionality first, though. if it works, then great, if not then look for other options

Share this post


Link to post
Share on other sites
Non-power of two textures are supported as an extension in OpenGL.

You need to check the device caps if you''re using D3D (in the TextureCaps part of the caps structure, the flags D3DPTEXTURECAPS_NONPOW2CONDITIONAL, D3DPTEXTURECAPS_POW2, D3DPTEXTURECAPS_CUBEMAP_POW2 and D3DPTEXTURECAPS_VOLUMEMAP_POW2 are the ones to check)

Putting the texture into a bigger (next power of two bigger) texture is a reasonable idea, although (IIRC) you can get problems with filtering pulling texels from outside your original image (especially when using the lower mip levels).

HTH

Share this post


Link to post
Share on other sites
Well, I''m using DirectX 9. Hmm, this could get harry. Well, I will look into increasing the size of the textures and reapplying them. Thanks guys. Does anyone know if mip mapping happens automatically. I put the correct samplestates to do mip mapping but it didn''t look like anything changed. However, I looked online and I saw a tutorial that shows you resizing the textures itself. Do I really need to do that or will DX do it for you?

Thanks again

Jeff

Share this post


Link to post
Share on other sites
Use D3DXCreateTextureFromFileEx and keep miplevels as zero for a complete mipmap chain to be built for you.

Also remember not every graphics card can support non-power of two textures, and if they do it will be slower than if you where.

Share this post


Link to post
Share on other sites
Actually, it is recomented that the dimentions of textures that you use should have dimentions in power of 2 (128, 256, 512...).
That's sure for Direct3D.
In Direct3D you can create a mipmap chain by specifing the DDSCAPS_MIPMAP | DDSCAPS_COMPLEX flags in DDSURFACEDESC2 structure passed to the IDirectDraw::CreateSurface. For example, to create a chain of 4 mipmap levels (256x256), (128x128), (64x64), (32x32) write:


DDSURFACEDESC2 ddsd2;
LPDIRECTDRAWSURFACE lpDDMipMap;
ddsd2.dwSize = sizeof(ddsd2);
ddsd2.dwFlags = DDSD_CAPS | DDSD_MIPMAPCOUNT;
ddsd2.dwMipMapCount = 4; // 4 mipmap levels
ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP | DDSCAPS_COMPLEX;
//DDSCAPS_TEXTURE flag must be set also
ddsd2.dwWidth = 256; // First mipmap
ddsd2.dwHeight = 256; // First mipmap

ddres = lpDD->CreateSurface(&ddsd2, &lpDDMipMap);

where lpDD is a valid pointer to a DirectDraw interface.

This sould work with non-power of two textures dimentions, also it is not recommented for speed optimization.

Jim Valavanis



[edited by - Jimmy Valavanis on May 20, 2004 2:37:39 PM]

Share this post


Link to post
Share on other sites