Hello, I’m facing an issue with texture handling in three.js and need some assistance. Here are the details:
- I have a texture, a material, and a mesh.
- The mesh is square because I’m dealing with map tiles.
- The texture contains both black and transparent areas for no data.
- The transparent data is getting manipulated by
magFilter
, which I’ve set toNearestFilter
, andwrap
, which I’ve set toClampToEdgeWrapping
. Any other settings make it worse. - However, I need to make the black pixels in the texture (indicating no data) also transparent, which exacerbates the issue with
magFilter
and wrapping. - There seems to be no way to set
magFilter
to none at all; it always defaults toNearestFilter
. The same goes for wrap, which defaults toClampToEdgeWrapping
; there seems to be no way to disable wrapping entirely. - I’ve tried several approaches using the
fragmentShader
of the material, and I can easily select the entire area I want to make transparent. However, when I set those areas to transparent, the problem withmagFilter
and wrapping gets worse again. - I’m looking for any solution, and I’m even willing to modify three.js itself if necessary.
- An interesting note: if I set the material to
wireframe: true
, it follows the exact edges I want. As you can see in the images above, with the wireframe on, the artifacts caused bymagFilter
and wrapping do not occur. Maybe this insight could lead to a solution.
Thank you for your help!
How I wish it would look (without the wireframes ofc, but no artifacts)
Original image, top texture, bottom height info
How it looks, this changes when I set magFilter to linear, but the problem still exists.