• Advertisement
Sign in to follow this  

custom maps for vertex textures

This topic is 4432 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 problems with creating custom mip maps for vertex textures. if i use the "gluBuild2DMipmaps()" everything works perfectly, but when i try to set custom mipmap levels myself it doesn't seem to work, and it seems like always texture lod 0 is used in the fetching (even if i directly tell my cg vertex program to fetch from lod 3!) i can't use the glubuild2dmipmaps, because: 1. i need my own custom made mipmaps 2. all my mipmaps are actually of same width/height (and not decreasing in size, like the generated mipmaps) the way that i attempt to create the custom mipmaps is: pTemp is a float pointer to 64*64 allocated float elements. glGenTextures(1, &m_uiTextureID); glBindTexture(GL_TEXTURE_2D, m_uiTextureID); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); and then i do: // lod 0 glTexImage2D(GL_TEXTURE_2D,0,GL_LUMINANCE_FLOAT32_ATI, 64,64,0,GL_LUMINANCE,GL_FLOAT,pTemp); // lod 1 glTexImage2D(GL_TEXTURE_2D,1,GL_LUMINANCE_FLOAT32_ATI, 64,64,0,GL_LUMINANCE,GL_FLOAT,pTemp); // lod2 glTexImage2D(GL_TEXTURE_2D,2,GL_LUMINANCE_FLOAT32_ATI, 64,64,0,GL_LUMINANCE,GL_FLOAT,pTemp); // lod3 glTexImage2D(GL_TEXTURE_2D,3,GL_LUMINANCE_FLOAT32_ATI, 64,64,0,GL_LUMINANCE,GL_FLOAT,pTemp); etc... so, can anyone here please tell me if i'm doing something wrong ? thanks in advance! btw - as i said, when i use: gluBuild2DMipmaps(GL_TEXTURE_2D, GL_LUMINANCE_FLOAT32_ATI, iSizeX ,iSizeX, GL_LUMINANCE, GL_FLOAT, pVertexTextureData); everything works ok, and when i tell the cg vertex shader to use lod 3 for example, it really uses it. but i need custom mip maps :/

Share this post


Link to post
Share on other sites
Advertisement
You need to explicitly specify all the possible n mipmap reduction images, OpenGL considers incompleted textures as blank textures. In your particular 64x64 image, the code would look like this:

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 64, 64, 0, GL_RGBA, GL_UNSIGNED_BYTE, mipmapImage64);
glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, mipmapImage32);
glTexImage2D(GL_TEXTURE_2D, 2, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, mipmapImage16);
glTexImage2D(GL_TEXTURE_2D, 3, GL_RGBA, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, mipmapImage8);
glTexImage2D(GL_TEXTURE_2D, 4, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, mipmapImage4);
glTexImage2D(GL_TEXTURE_2D, 5, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, mipmapImage2);
glTexImage2D(GL_TEXTURE_2D, 6, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, mipmapImage1);

mipmapImage1 to mipmapImage64 is the scaled version of the original image in 2^n basis. In case you want to create a mipmapped texture in size 64x16, you need to create 64x16, 32x8, 16x4, 8x2, 4x1, 2x1 and 1x1 scaled images.

Quote:

OpenGL considers incompleted textures as blank textures.


[Edited by - Skeleton_V@T on January 6, 2006 11:02:23 AM]

Share this post


Link to post
Share on other sites
Skeleton_V@T:
hmm... i don't think you realised what i'm trying to do:
i need all mipmaps to be of SAME SIZE - 64x64 (unlike traditional mipmapping)

when i compare my code to yours, the only difference (except from types ofcourse) is that you decrease the size of your mipmaps textures.

so that brings me back to my question, is it possible for ME to choose the SIZE of the mipmap textures? or am i FORCED to use decrementing mipmap texture sizes like in the code you just pasted?



Share this post


Link to post
Share on other sites
Quote:
From section 3.8.10 (Texture Completeness) of the OpenGL 2.0 spec

For one-, two-, or three-dimensional textures, a texture is complete if the following conditions all hold true:
...
• The dimensions of the arrays follow the sequence described in the Mipmapping discussion of section 3.8.8.
...


From section 3.8.8 (Texture Minification) of the OpenGL 2.0 spec

A mipmap is an ordered set of arrays representing the same image; each array has a resolution lower than the previous one. If the image array of level levelbase, excluding its border, has dimensions wb × hb × db, then there are blog2(max(wb, hb, db))c + 1 image arrays in the mipmap. Numbering the levels such that level levelbase is the 0th level, the ith array has dimensions
max(1, floor(wb/2i)) * max(1, floor(hb/2i)) * max(1, floor(db/2i))

until the last array is reached with dimension 1 × 1 × 1.
So mipmap resolution must decrease with each successive mipmap level.

Share this post


Link to post
Share on other sites
if u want to load and use your own mipmaps, use dds, or load a different image for each level.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement