Using mipmaps with DataTexture?


I am updating an Alpha-only DataTexture on every frame to map a sphere and it doesn’t smooth very well with minFilter = THREE.LinearFilter when the sphere is small in the screen. Plus, I suppose it’s not very optimised to push so many pixels to the GPU at every frame, although the generation itself would not be faster with a smaller texture in my case.

I noticed that generateMipmaps didn’t… generate mipmaps of my DataTexture: The mipmaps property is an empty array at every frame (generateMipmaps is always set to true). I am not so much upset because, since I update the texture at every frame, I would rather update only the one version that is actually used by the GPU instead of updating every mipmap. I am just puzzled about it not working.

I am wondering if mipmaps are really supported with DataTexture. I didn’t have this issue in mind when I wrote my algorithm and I will have to do some refactoring to decouple the output definition before I can try anything.

I am also wondering if, considering my use case, there was any advantage of using mipmaps instead of updating the uniform of my material with a smaller DataTexture. I am having trouble figuring out how to know which texture size is needed, so I thought maybe mipmaps would help but if I need to update just one I need to know which one.

I am currently mapping a sphere, but I was thinking I could drop the sphere geometry altogether, use a plane geometry and handle the spherisation in the fragment shader, because i am planning on adding some projections as well, such as azimutal equidistant, so I guess it would be simpler to have the same geometry for everything. I’m not sure how to know what definition to use depending on the size of the resulting image relative to the screen since the resolution is not the same across the frame due to the deformations. I am not comfortable with this issue

I really hope I am clear. I am looking for advice from more experienced people more than I am looking for technical help.

Thanks in advance.

Yes they are. The following example uses mipmaps for better texture filtering: Edit fiddle - JSFiddle - Code Playground

As the name implies DataTexture is often used to store data. In this case the usage of NearestFilter is the only way to sample the same data you have previously stored in the texture. Any kind of linear filtering would alter it. Because of this .generateMipmaps is set to false per default.

BTW: Texture.mipmaps is always empty unless the user manually specifies mipmaps.

Hi, Thanks for your reply.

I had to convince myself that it was working because in my application I don’t see the difference between LinerarFilter and LinearMipMapLinearFilter. My texture is a lot bigger though and it has sharp bitmap details surrounded by large black areas. I thought I it could look good enough downsampled, but it really doesn’t.

OK, important update : my texture’s dimensions were not square values, that’s why the texture filtering was not applied as expected. There were actually no mipmaps generated. This is a pity because square values reduces the choice of texture sizes but thankfully I have a lot of black areas so I can use a bigger size with no significant penalty.