I tried to play around with setting different repeat values for hours but the texture either appears cropped, misaligned or otherwise blurry. I get the best results without setting the repeat value at all.
I use alpha maps on different parts of the mesh for hair but they are not planes and it works well. I have one more mesh part that is a plane (eyelashes) and they appear blurry as well but they are so small that itās almost invisible and it doesnāt bother me that much.
The map resolution is 2048x2048 and I even tried to increase the size with no effect. I believe the UV mapping is done correctly as it looks fine in blender. I donāt mind the occasional stretching but the texture canāt be blurry (altough I understand there may be some limitations in the resolution).
Meshopt does a lot of stuff under the hood with the goal of making it smaller. It may be converting/downsampling your textures. It may be quantizing your UV coordinates.
What meshopt parameters are you using?
Can you try loading the model without running it through meshopt and see if the problem goes away?
I tried to set up a pen but I struggle importing the file due to crossorigin issuesā¦ I never made a codepen with glb files before so I donāt know of good places to host modelsā¦
The pen is here, take a look, but itās a blind copypasta from my local setup. Itās highly possible there are some mistakes or missing code as I canāt see what Iām doing. Thanks!
Maybe try in chrome, make a free account on glitch, then go to this link?
Your code is in test.js and I uploaded your assets to the āassetsā tab, and grabbed their URLs for loading in test.js
To make it look like what you wanted, I had to add:
alphaMap.repeat.set(1, 4); //Make the texture repeat 4x on the V axis
alphaMap.wrapS = alphaMap.wrapT = THREE.RepeatWrapping; // Enable repeat wrapping on texture, otherwise it will only repeat the edges of the texture...
By the way, you may not have to set this stuff up manually and instead, you can export the GLB with the textures and UVs set up in your modelling tool. What modeller are you using? Blender supports exporting GLB with textures embedded etc.
Looks like I wasnāt patient enough playing with different values as I interpreted all of them as ābadā - in my setting te camera is more zoomed out and it it didnāt occur to me that it would be a good idea to zoom in to actually see whatās going on. So now it looks very good when zoomed in and weird when zoomed out, so Iāll probably rethink the implementation.
Anyway thank you very much for your time and help. I really appreciate it!
yeah I tried some different filtering for āminFilterā which is what happens when a texture is zoomed out, but NearestFilter looked really weird. There are some other things worth trying like disabling mipMapping or using custom mipmaps.
Are you trying to duplicate a reference image from a 3d model?
Yes, I try to match the materials in three as much as possible to the look of the model in blender. Iām aware of some limitations and your suggestions for little tweaks are helpful.
alphaMap.generateMipmaps = false
seems to help a little but I decided to go for a different alpha map with slightly thicker hair strands and it looks a little better.
Thank you!