Generating Mimap Manually
-
thomascheah
- Posts: 77
- Joined: Sat Jul 08, 2006 5:55 am
- Location: Cyberjaya, Malaysia
Generating Mimap Manually
I know this question is a bit unusual, but is there any way to generate Mipmap of a texure manually?
The main reason is I wish to apply a vectorized image (in WMF) as texture, which obviously Irrlicht does not support directly. I know I can convert the WMF file into a bitmap image and set it as the texture. But I don't want to use the default Mipmap behavior as its pixel resample tends to make my vectorized image blury, which in fact I can avoid it, if only I can generate the Mipmap manually, by rendering the WMF file into a set of textures of different scales, the texture will remain crisp and sharp most of the time.
Any ideas? Thanks in advance.
p/s: Just for your info, the WMF file contains a bunch of lines that make up some schematic drawings. Thus my goal is to render it on a 3D plane as sharp as possible.
The main reason is I wish to apply a vectorized image (in WMF) as texture, which obviously Irrlicht does not support directly. I know I can convert the WMF file into a bitmap image and set it as the texture. But I don't want to use the default Mipmap behavior as its pixel resample tends to make my vectorized image blury, which in fact I can avoid it, if only I can generate the Mipmap manually, by rendering the WMF file into a set of textures of different scales, the texture will remain crisp and sharp most of the time.
Any ideas? Thanks in advance.
p/s: Just for your info, the WMF file contains a bunch of lines that make up some schematic drawings. Thus my goal is to render it on a 3D plane as sharp as possible.
My guess would be that you'd need to alter the source of irrlicht to do this...
You could definetly do it by having a new version of the texture creation function where you pass in an array of images instead of just one and then use each one to define each level of mipmap required. In OpenGL this would be really simple and i imagine it would be in DX as well so if you feel up for editing the source then it shouldn't be hard!
You could definetly do it by having a new version of the texture creation function where you pass in an array of images instead of just one and then use each one to define each level of mipmap required. In OpenGL this would be really simple and i imagine it would be in DX as well so if you feel up for editing the source then it shouldn't be hard!
-
thomascheah
- Posts: 77
- Joined: Sat Jul 08, 2006 5:55 am
- Location: Cyberjaya, Malaysia
Thanks JP! I am not familliar with OpenGL. But can anyone point me some lights on how this works under DirectX SDK? I might then try to modify Irrlicht source once I get to know how.
BTW, my main objective is to render a vectorized image (in my case, a WMF file) on a plane that looks crisp and sharp at most distance. The method that I wrote above is one that is on top my mind. If anyone has other creative "out of the box" ideas in achieving this, I will greatly appreciate!
BTW, my main objective is to render a vectorized image (in my case, a WMF file) on a plane that looks crisp and sharp at most distance. The method that I wrote above is one that is on top my mind. If anyone has other creative "out of the box" ideas in achieving this, I will greatly appreciate!
I don't have any experience with DX but i should think it will be pretty much exactly the same way as OGL but with different function names and slightly different parameters.
OGL:
What that does is generate num_mips mipmap levels for the currently bound texture, reading from an array of images named pixels. So all you'd have to do there is set pixels to your array of mipmap images you've rendered.
Irrlicht may do the mipmap creation differently using a function called something like glBuildMipMaps which creates the mipmap images automatically instead of being fed in the scaled down versions so you'd have to switch that with this.
You should be able to google for the DX mipmap creation techniques.
OGL:
Code: Select all
for (uint32_t i = 0; i < num_mips; i++) {
glTexImage2D(GL_TEXTURE_2D,i,GL_RGBA,width,height,0,GL_RGBA,GL_UNSIGNED_BYTE,pixels[i]);
width/=2; height/=2;
if (width == 0) width = 1;
if (height == 0) height = 1;
}Irrlicht may do the mipmap creation differently using a function called something like glBuildMipMaps which creates the mipmap images automatically instead of being fed in the scaled down versions so you'd have to switch that with this.
You should be able to google for the DX mipmap creation techniques.
-
thomascheah
- Posts: 77
- Joined: Sat Jul 08, 2006 5:55 am
- Location: Cyberjaya, Malaysia
This might help. But I don't know if the mipmap generated is sharp enough for your needs.
http://msdn2.microsoft.com/en-us/library/bb206251.aspx
http://msdn2.microsoft.com/en-us/library/bb206251.aspx
My company: https://kloena.com
My profile: https://zhieng.com
My co-working space: https://deskspace.info
My game engine: https://kemena3d.com
My profile: https://zhieng.com
My co-working space: https://deskspace.info
My game engine: https://kemena3d.com
-
hybrid
- Admin
- Posts: 14144
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Yes, the link is good. You simply have to change the third parameter to the mipmap level you need. Please have a look at the d3d9texture.cpp source. You will find the manual mipmap creation code there. It scales down the texture and sets the next mipmap level. At least for opengl you will have to set all levels or the texturing won't work at all (or set a higher LOD).
A proper interface for Irrlicht might use setMipMap(level, image) or something like that, adding to the ITexture interface. I did not yet think about the actual methods.
A proper interface for Irrlicht might use setMipMap(level, image) or something like that, adding to the ITexture interface. I did not yet think about the actual methods.
-
thomascheah
- Posts: 77
- Joined: Sat Jul 08, 2006 5:55 am
- Location: Cyberjaya, Malaysia
Just curious, is there a way to switch off the automatic generation of mipmaps in Irrlicht? Not sure it will give me a better result without hacking through the code of implementing the manual access to mipmaps in Irrlicht. But I guess it is worth trying if Irrlicht can allow me to disable the mipmaps generation.
-
thomascheah
- Posts: 77
- Joined: Sat Jul 08, 2006 5:55 am
- Location: Cyberjaya, Malaysia
IMO, you don't need a mipmap for the skybox. Because it will remain the same distance even if your camera is moving around.
Correct me if I'm wrong.
Correct me if I'm wrong.
My company: https://kloena.com
My profile: https://zhieng.com
My co-working space: https://deskspace.info
My game engine: https://kemena3d.com
My profile: https://zhieng.com
My co-working space: https://deskspace.info
My game engine: https://kemena3d.com
