Mineways icon indicating copy to clipboard operation
Mineways copied to clipboard

Merge adjacent block faces

Open roket333 opened this issue 4 years ago • 2 comments

It would be really helpful in some cases if there was an option for the faces of adjacent blocks of the same type to be merged into one. For example, if you have a 2X2 of dirt next to obsidian, the dirt blocks go from what would be 32 faces to 12 faces, which would be especially helpful when exporting a Minecraft scene to be used in a mod for different games.

roket333 avatar Jun 12 '20 22:06 roket333

I know what you mean, and this process is call "decimation" or "mesh simplification." I've debated adding it to Mineways for years. With your 2x2 example, the concept is to put two triangles on each face, for a total of 12 triangles. Other than exporting to other games, such a feature could - in some cases, vastly - reduce triangle count, which is generally a nice thing for any modeling system.

This is a tricky one on a few levels. First, it absolutely requires that you use "tile" output instead of the one large texture that is default, since the tile must be repeated across the larger triangles formed. There is also a question of whether or not to allow T-vertices. That is, if the 2x2 block is next to a different type of block, such as obsidian, if I don't maintain the "interior edge" vertices where the two types of blocks meet, this can lead to cracking artifacts. I suspect I could ignore the T-vertices problem, but I'm not sure (if I can't, then I need to add yet another parameter set for whether to avoid them or not).

Finally, it's a lot of work! I think it's possible, and an interesting problem, but it's a lot more record keeping that would have to be added as an optional dataset atop the mesh. If the option was not used (as it wouldn't be, 99+% of the time) it would have to cost no additional memory - Mineways already strains memory limits on some PCs. This is a pretty daunting set of requirements for a program already creaking under the load.

That said, someday I may still add it as an option (and ignore the T-vertices constraint), just because it'd be interesting to program it up. I was thinking "well, there should be programs out there that already do this sort of work," such as MeshLab. But I don't think they'd know about the connectivity between adjacent block faces with seemingly different UV coordinates on the shared edged. For example, one block would have (0,1), the other would have (1,1) at the same vertex, and you'd have to figure out if these texture coordinates are truly the same or not, by also tracking whether the texture is going the same direction or not (i.e., is the texture repeating?).

One other minor headache is that blocks like terracotta don't repeat, so care would have to be taken there to avoid trying to merge these. Oh, a bigger headache, and one that makes me go "nope, won't even try" is the fact that grass blocks now do not repeat their pattern. Each grass block's top face is rotated randomly in Minecraft, and in Mineways. Look carefully and see how each tile below is (usually) different than its neighbors in orientation. image

It's not just grass that has this random rotation: dirt, bedrock, netherrack, sand, mycelium, and grass path tiles also have it (and maybe more, that I haven't noticed yet).

Anyway, I'm rambling on, but decimation's a feature I've thought about adding for awhile. However, it's a bit daunting. More importantly, it's a feature that I suspect wouldn't get used much (me, I'd prefer the randomized grass block rotation, as it breaks up the repetitive look of the tile), so that makes me hesitant to spend much time on it.

erich666 avatar Jun 14 '20 14:06 erich666

Oh, and just to show what a difference random rotation makes, here's the grass from farther away.

Random rotation: rotate

No rotation: norotate

erich666 avatar Jun 14 '20 14:06 erich666

The more I think about this feature, the less interested I am in implementing it. I'm hoping that Blender's Decimate system and similar will solve this problem.

erich666 avatar Jan 06 '23 17:01 erich666

Ah, fun: I just noticed that jmc2obj does decimation, by default. Cool! The downside is that the grass has to repeat in order for them to do this simplification (see above for why). I don't like the look. But, it does make me a bit more interested in decimation as an option. Short answer: if you want decimation, try jmc2obj! They also support more objects, such as frames and whatnot. Here's a decimated grass plain from jmc2obj: image

erich666 avatar Jan 28 '23 23:01 erich666

Added in Mineways 10.10, with the limitation that textures then cannot be randomized in their orientation. See https://www.realtimerendering.com/erich/minecraft/public/mineways/mineways.html#simplify

erich666 avatar Feb 25 '23 00:02 erich666