Texture LOD request

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply
belfegor
Posts: 383
Joined: Mon Sep 18, 2006 7:22 pm
Location: Serbia

Texture LOD request

Post by belfegor »

From the DX SDK help:
IDirect3DBaseTexture9::SetLOD is used for level-of-detail control of managed textures. This method returns 0 on nonmanaged textures.
IDirect3DBaseTexture9::SetLOD communicates to the Direct3D texture manager the most detailed mipmap in the chain that should be loaded into local video memory. For example, in a five-level mipmap chain, setting LODNew to 2 indicates that the texture manager should load only mipmap levels 2 through 4 into local video memory at any given time.
More specifically, if the texture was created with the dimensions of 256x256, setting the most detailed level to 0 indicates that 256 x 256 is the largest mipmap available, setting the most detailed level to 1 indicates that 128 x 128 is the largest mipmap available, and so on, up to the most detailed mip level (the smallest texture size) for the chain.
I would propose to add this to irrlicht (don't know equivalent for OpenGL), to the ITexture:

Code: Select all

virtual u32 setLOD(u32 Lod) = 0;
and in C3D9Texture def. something like:

Code: Select all

u32 C3D9Texture::setLOD(u32 Lod)
{
    if(IsRenderTarget)
    {
        return 0;
    }
    else
    {
        if(!HasMipMaps)
            createMipMaps();
        u32 LevelCount;
        LevelCount = getDX9Texture()->GetLevelCount();// hopefully this does what i think
        if(Lod >= LevelCount || Lod < 0)
            Lod = 0;
        return getDX9Texture()->SetLOD(Lod);
    }
}
Small FPS demo made using Irrlicht&NewtonDEMO
InfoHERE
Its at very early stage but i think im crazy enough to finish it all alone.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

First question: What do you need this for? I alsways wondered why one would need it. But yes, I already saw this feature, it's also available for OpenGL, so it might go into the core library.
But, why into the texture and not into the material? This would allow for different mipmap depth for the same texture.
omaremad
Competition winner
Posts: 1027
Joined: Fri Jul 15, 2005 11:30 pm
Location: Cairo,Egypt

Post by omaremad »

If you are using shaders (which i know you do) you can set the mipmap bias during the texture read, thats the qucik way if you dont want to modify irrlicht.

Btw do you just want to set LOD? or are you going to use this for memory conservation? i think the text says it also has some memory savings by not loading higher lods.
"Irrlicht is obese"

If you want modern rendering techniques learn how to make them or go to the engine next door =p
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

Last edited by Spintz on Mon Dec 10, 2007 1:53 pm, edited 1 time in total.
belfegor
Posts: 383
Joined: Mon Sep 18, 2006 7:22 pm
Location: Serbia

Post by belfegor »

Sory for big delay(gonna lose internet for some time very soon) :cry:

Text that caught my eye
>>omaremad
the most detailed mipmap in the chain that should be loaded into local video memory
as i understand this i can control how much video memory will be used.

>>spintz
i think this is fast. tried it on a press of a button.

>>hybrid
why into the texture and not into the material?
I think this will fit better in texture and because i like shorter lines:

texture->setLOD(2);

instead

mesh->getMaterial(0).Textures[0]->setLOD(2);

better? :wink:
Small FPS demo made using Irrlicht&NewtonDEMO
InfoHERE
Its at very early stage but i think im crazy enough to finish it all alone.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Your last line means still it's in the texture class, not in the material. But I guess it might be reasonable to require a diofferent LOD for other meshes. With LOD in the texture you would change the LOD for a texture in all meshes at once.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

I agree with Hybrid. If there's any point in having this then it would be so you could set the LOD for different meshes or different uses of the texture, not for the single texture for all uses in the app as then what would the point be, you might as well just load the texture at that specified LOD instead and save on loading time and memory as you would never be using any of the higher LODs presumably.

What reason would you be using this for? Would you want to change the LOD of all uses of the texture at some point for some reason? Maybe when doing some multi-pass effects it might be useful to cut down the LOD if it wasn't required to be high quality and then you'd want to have it in the texture so you could just do it once. So maybe you could have it in both the texture and the material and the texture one overrides the material or something.

Just thought of one way you might want to use this is in a settings menu. You could allow the user to choose high, medium or low quality textures in order to speed up the game for them.
Image Image Image
belfegor
Posts: 383
Joined: Mon Sep 18, 2006 7:22 pm
Location: Serbia

Post by belfegor »

hybrid wrote:Your last line means still it's in the texture class, not in the material
Yeah, i realized that later during the day :oops:
so didnt have chance to edit post, lapse of concretation.
Put it (if you wish) anywhere you whant.
JP wrote:Just thought of one way you might want to use this is in a settings menu. You could allow the user to choose high, medium or low quality textures in order to speed up the game for them.
thats exacly what was i am trying to explain why i need it.
Small FPS demo made using Irrlicht&NewtonDEMO
InfoHERE
Its at very early stage but i think im crazy enough to finish it all alone.
belfegor
Posts: 383
Joined: Mon Sep 18, 2006 7:22 pm
Location: Serbia

Post by belfegor »

When i give further thought, i dont see how this can work as you
proposed as same texture is loaded only once i memory but can be used
by many different nodes..gui elements?
Small FPS demo made using Irrlicht&NewtonDEMO
InfoHERE
Its at very early stage but i think im crazy enough to finish it all alone.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Even if you have two same meshes you might want to have the texture LOD different, e.g. because one is far away. But you can also have other occasions where textures are shared, e.g. buildings which have common roofs or things attached to the fronts. Plants are also a good example for texture reuse. You might want to have three levels of detail in your scene.
belfegor
Posts: 383
Joined: Mon Sep 18, 2006 7:22 pm
Location: Serbia

Post by belfegor »

I know all that and it sounds great, but can you do it as i cant see how?
Small FPS demo made using Irrlicht&NewtonDEMO
InfoHERE
Its at very early stage but i think im crazy enough to finish it all alone.
Post Reply