- Home /
How to make discontinuous UVs?
I'm making a voxel world in which terrain is made up of cubes. I grouped these cubes into meshes to be efficient, but if I want the sides of cubes to be mapped to a different texture than the rest, how would I do so? As in, I want more than one png to be mapped to a single mesh, or be able to map UV's without lines being showed. (If you don't know what I mean: [Lines at cube borders and darkened at a certain distance][1]).
UVs weren't ment to be used that way, so how can I have multiple pngs on a single mesh without having to generate a custom texture each time (Though a viable solution, I'm trying to conserve memory)
(If you need a specific piece of code, I'll post it) [1]: https://dl.dropboxusercontent.com/u/138461102/Untitled.png
Answer by Eric5h5 · Jan 07, 2014 at 03:26 AM
Add padding around each section in the texture, or turn mipmapping off (not recommended, looks bad).
I've tried both, but turning off mipmappping doesn't fix it and padding could work but its must more complex to extract the UV coordinates from 0f to 1f if there are intermediate pixels. If I don't have other options I'll resort to padding.
Had the same Problem and solved by setting Filter$$anonymous$$ode=Point, which actually fits the theme. $$anonymous$$ipmapping shouldn't be a problem if you use powers of two for your tilesize. If you add padding to fix the Filtering problem, this would actually introduce problems for mipmapping, but the padding will fix those problems again, so Padding fixes Filtering- and $$anonymous$$ipmap-Problems if you dont want to go the Filter$$anonymous$$ode=Point route.
Just to make sure because you are ambiguous in talking about multiple pngs - are we talking mulitple materials here or selecting different tiles by UV (what i think)?
@Happy$$anonymous$$oo I have the filter mode set to point, but in the far distance I can see seams because it is scaling down the textures. $$anonymous$$ipmapping is off. What I originally ment was multiple materials, but since that wasn't really possible I select tiles by UV. I even tried undershooting, not using the entire texture and it still grabs a little color from surrounding pixels unless I'm a full pixel away, which is essentially padding.
Well... now that you say it, maybe I have such artefacts in the distance too and I just didn't see them - I just played with it for 2 days to see if I could do it http://i.imgur.com/ZIA4Cxj.jpg
What I would try first is putting the UVs in the middle of the pixel, not around the edge, so if your tiles are 32x32, set your UVs to select the 31x31 px you get when you go 0.5px in from the edge. Now, I would only do this because these are blocks and you don't see half a px on all sides with point filtering anyway - however, if you go for a Bilinear Filter later, you need to pad more.
@Happy$$anonymous$$oo Taking a look at your gameobject list, I'd suggest you have 9 (or 16) meshes for the chunk you're standing on, and any chunks bordering it, and 1 large mesh for everything else. 10 meshes max, that way you don't have a huge cascade of gameobjects, with wasted draw calls and such. Btw, I got around the issue with padding on runtime, so the texture supplier doesn't know about the padding.