powroupi / blender_mmd_tools

mmd_tools is a blender addon for importing Models and Motions of MikuMikuDance.
GNU General Public License v3.0
1.8k stars 277 forks source link

Wiki correction #206

Closed Uradamus closed 5 years ago

Uradamus commented 5 years ago

This is in regards to the MMD unit page by @Hogarth-MMD: https://github.com/powroupi/blender_mmd_tools/wiki/1-MMD-unit-in-real-world-units

Blender has always been 1 Blender unit = 1 meter. It's been that way as far back as I can remember (12+ years) and probably since it's creation. In fact as of 2.8 they have the metric markings on by default, though they have always been available to toggle on in the scene tab on older versions, by just changing the length drop down from None to Metric. This is something anyone can test and verify.

I was just doing some testing and there is little doubt in my mind that an MMD unit is meant to be exactly 8cm. Keep in mind that official character heights don't include shoes nor the default bit of floating above the ground that MMD models tend to have built in by default. The official Miku model, when she is brought down so that the edge running along the top of her shoes' heels is at 0 on the z axis in Blender, with a 1.0 import scale, is pretty much exactly 19.75m tall. Which is the same as 19.75 MMD units, and when you do the math that works out exactly to her expected 158cm when multiplied by 8cm.

In order to get her scaled properly, I just used a value of 0.08. Again, after dragging her down to the same edge on her shoes as in the above example, she ends up with the top of her hair at pretty much exactly 158cm.

So that page should be updated to remove a lot of the inaccurate guessing about Blender units and confirm the suspected 8cm per MMD unit conversion. It would also make sense to include something about 0.08 being the proper scale value to get accurate imports that match officially published character heights.

ptrthomas commented 5 years ago

@Uradamus I've always wondered about this - so thanks for the info

@powroupi always recommends an import scale of 0.2 - which I started using recently and I thought ended up as 190 cm or something like that. which gave okay-ish results for me when doing FBX --> Unreal Engine - @powroupi any comments ?

Uradamus commented 5 years ago

Hmm, 0.2 would put Miku at 3.95m (~155.5 inches, almost 13 feet) after adjusting for the float and shoes like in my above examples. It's probably close enough to get decent physics results, but more than double what she should be for an accurate scale.

Uradamus commented 5 years ago

For what it's worth, exporting would need a scale of 12.5 to get from real world metric sizes to MMD units. For the sake of completeness, heh.

ptrthomas commented 5 years ago

@Uradamus ok here is my workflow because of unreal engine being my target. for best results I have to first set blender unit presets to Metric (Meters ?) and Unit Scale 0.01

then I import MMD models at a scale of 10. (not the default 1)

then I see the height being approx 1.9 m (which is too tall, but not by much)

in a hurry - and haven't thought through the reasons and why and what not - but thought of posting this info for your reference / analysis

Uradamus commented 5 years ago

UE4 uses a 1cm per unit scale. So 100 of those to each 1m Blender unit. Which is why you have to go with 0.01 as your scalar. When you are importing from MMD at 10, that is the equivalent to 0.1 in standard BUs. If you want to go for accuracy, then try 8 instead, that would be equivalent to the 0.08 I was suggesting with my OP here. It isn't far from what you are using already, but obviously off by enough for you to be able to notice that models are too tall. In fact that was the same scale I was using as well, before I started looking into this deeper this evening when I was also feeling they were coming in a bit taller than I suspected they should be, heh.

ptrthomas commented 5 years ago

@Uradamus thanks - this helps and I agree. will try 8 next time

powroupi commented 5 years ago

@Uradamus, thanks for the info, I think 0.08 is the correct scale of the conversion, and feel free to update/correct wiki pages (I'm relying the power of the community). :smile:

The reason why I recommend an import scale of 0.2 is just because it's the original default value, and the reason the current default scale is changed to 1.0 is to prevent/minimize the precision error in import/export cycles.

So the following recommendation should be better now:

  1. Use import scale 0.08 if you want to play/render animation (and physics simulations) in Blender using Metric unit.
  2. Use import/export scale 1.0 if you want to edit a MMD model. (hmm, tweaking settings of rigidbody/joint objects could be troublesome :cry:)
Uradamus commented 5 years ago

That makes sense, always nice to have a direct translation option with no scaling at all. Though I wonder how bad precision errors could be? As long as you also use the appropriate scale for exporting when you are done (12.5), they should be too small to be noticeable. I mean Blender tends to have like at least 5 or 6 significant places right of the decimal. Which should be plenty to avoid such problems. Usually those sorts of problems creep in when you are dealing with insanely large values and older/smaller floats that are prone to start eating into the decimal precision, which doesn't seem like it would be a common scenario for most MMD model use cases, or even really a possibility with doubles in all but the worst of edge cases.

It really doesn't matter much to me what the defaults are though, as I've already saved the changed value into my own startup file. But I will say that bringing in finished models is probably the much more common use case for most situations, so it might make some sense to favor defaults that lean in that direction. Plus it's a lot less likely people will know the 0.08 and 12.5 values off the top of their head, while it's trivial to type in 1 for both of those when a straight value translation is desired. Just my take on the matter though as a lazy bystander who doesn't have to get his hands dirty over this, heh, so do what you think is best.

I've got to get to bed now, way passed due at this point. But if no one beats me to it, I'll have a go at updating that wiki page later. Wasn't sure if it was open for public edits and it seemed like a worthwhile topic to bring to folks attention anyhow, so figured this ticket would be a better starting point. It also gave me a chance to get some feedback first to see if there was any consensus for my findings before pushing them to the wiki.

Uradamus commented 5 years ago

Ok, did a quick pass update to the mentioned wiki page. Everything should be fine now. @powroupi If you've got a moment, please feel free to take a look at the page and see if it seems alright to you. If all is good, this issue can then be closed.

powroupi commented 5 years ago

@Uradamus, thanks for the updates, it is getting better. :smile:

Sorry, I'm not sure how bad precision errors could be? Haven't tested it. But keeping the imported values the same as exported values would be the best reason of scale=1.0. :)

And I noticed the physics is a little unstable when importing model with scale 0.08. I could get better result using scale=1.0 and gravity=-9.8/0.08. Not quite understand the physics in MMD and Blender. :cry: (ideally, there should be a way to perform similar result without scaling)

Uradamus commented 5 years ago

Ya, unfortunately there is no real standards for approaches to physics simulation. Everyone seems to do things a bit different so results rarely ever carry over well from one solution to another unless you are going between engines that each use the same 3rd party physics engine. I imagine this is in part due to the Japanese love for reinventing the wheel when it comes to anything programming related, Blender is using Bullet which is quite mature, well tested and reasonably physically accurate. But if I had to guess MMD is almost certainly using their own physics solution that they probably rolled themselves and just kept tweaking until they got something that worked for their needs. Nothing wrong with that, other than the huge waste of time it tends to be, but it does mean their physics setup is likely a big ball of duct tape and chewing gum that just barely manages to hold itself together, heh.

I haven't done much with MMD directly, as I've been on Linux since long before I even discovered it and MMD never really played well with Wine. So I can't say I know all that much about what the intended results should be like. My gut reaction though is to assume it isn't likely all that accurate to begin with, so there is no reason to try and stick very closely to realistic values in terms of gravity and such. It's one of those things where you would likely just need to take some creative license and follow your gut with tweaks until things feel right, with little concern for physical accuracy. We are talking about dancing cartoon characters after all, heh. Style will always trump realism in this situation.

nagadomi commented 5 years ago

MMD also uses Bullet Physics Library, but is a very old version. Ideally, I think the size of the rigid body should match the usage of the MMD's Bullet Physics Library. But no one knows the proper settings for MMD.

I usually use scale=0.2 with steps_per_second and solver_iterations on rigidbody_world increased, it does not look so strange.

Uradamus commented 5 years ago

Huh, so it does use Bullet? I was looking around for a while earlier and I couldn't find mention of any 3rd party physics engines, everyone just kept referring to it as MMD's physics engine all over the place. Even taking a look around the actual package, there are no library files that I could find and just that one tiny executable which seems entirely too small to contain an embedded 3rd party physics engine. I mean last time I checked just the source files alone for Bullet are like 80-90MB zipped, while the MMD exe is like under 2MB.

EDIT: After digging around a bunch more specifically for MMD and bullet together, it seems it does in fact use it. They must have stripped it right down to the absolute essentials though to keep that exe so darn small, heh.

nagadomi commented 5 years ago

yea, it is described in MikuMikuDance_v926/readme.txt.

■物理演算モード■ 物理エンジンにはBullet Physics Engineを使用しています。 (http://www.bulletphysics.com/wordpress/ )

MMD uses Bullet Physics Engine for physics engine.

Ver.5.13(2009/09/15) ・物理エンジンBullet Ver.2.75 正式版公開に伴いBulletバージョン更新

Bullet Ver.2.75: Bullet version updated for official release.

Uradamus commented 5 years ago

I haven't done much with any MMD models yet. I tend to like to grab them to pick apart and see what sort of solutions people came up with for geometry flow and rigging. So I've barely touched the physics stuff at all so far. I did just play around a bit with one or two of the default models I grabbed out of the MMD package just now to see how things worked, and they were really jittery and I noticed that some of the bones weren't properly anchored to anything so their base would float around causing troubles. I did however find that playing with the values in the Rigid Body World section of the Scene tab seemed to help calm things down some. But everything was still obviously full of issues that would need to be manually cleaned up. It could be because of the scale, but I tend to think MMD just does things in a really complicated way that doesn't really cleanly translate to Blender in any sort of automated fashion. Though maybe I should give a go with a more recent and higher quality model. Those official example models are pretty ancient at this point after all.

Hogarth-MMD commented 5 years ago

Blender allows the measurement of its units to be customized. 1 Blender unit does not necessarily equal 1 meter in Blender. And the people who make 3D character models, including the Rigify armature which is also an official Blender standard, basically ignore the official 1 unit = 1 meter. In actual practice Blender and some other softwares have 2 units as the approximate height of a character, while MMD has 20 units as the approximate height of a character. But all characters do not have the same height, so there is always a margin of error when converting 3D models. All measurement guidelines end up being approximations only.

Uradamus commented 5 years ago

While Blender does give you the tools to adjust the scale of their units, the official default has always been 1 BU = 1 meter. It doesn't matter if people ignore that fact or not, that doesn't make it untrue. I've got 2.49, 2.79, and 2.8 all installed right now and they all default to that unit scale.

You can easily switch between the display units and check the size value of the default cube. None and Metric will retain the exact same numerical values when you switch between them (2.0 in each dimension), while Imperial will properly scale the values to the equivalent (6.56'). This holds true for all 3 versions mentioned above and every other one that has been released in the past 12+ years that I've been using Blender.

Also, none of the MMD characters are 20 units tall. In Japan character heights are almost always from the base of their bare feet to the top of the head (often including the hair in most situations). As I said in the first post, when you take these into consideration and adjust the vertical position of the Miku model, her height works out almost perfectly to 19.75 units, which matches exactly to the published 158cm when you do the math with 1 MMD unit = 8cm. It seems clear to me that the MMD dev was being very exact with their model dimensions to stay true to the official heights. There is little if any ambiguity when you stop relying on guess work and actually measure things.

As a few other examples from the models included with MMD:

The derivative character models tend to be a little taller than their official heights, but it could be that the heights were retroactively given after these models were created, as one possible explanation. It could also be they aren't including the hair in the height for these, it's hard to say.

As you can see, most are really close to their official heights, with the worst being off by only about 4cm (or about an inch and a half). All of these scaled heights are comfortably within the realm of realistic heights and well within the range of heights seen among the officially recognized Vocaloid characters (125-193cm for the ones I've been able to find that can be considered normal human figures).

EDIT: In regards to the rigify rig. It is generally assumed you will scale it to match your model, so it's default height means nothing at all. I would hazard to guess it is 2m tall to stick with the standard dimensions used by Blender's primitive mesh shapes, which pretty much all tend to be brought in with a default 2m/bu value for their dimensions.