powroupi / blender_mmd_tools

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

How to make a 60fps MMD Camera in blender with MMD_TOOLS? #370

Open gk2qf opened 2 years ago

gk2qf commented 2 years ago

Almost all of MMD producers make 60FPS MMD video. [So I wonder if MMD_TOOLS can set up 60fps camera, I don't see the relevant button.] If I manually set up 60fps, the two keyframes used to switch shots will automatically interpolate, which is likely to give the wrong shot result.

【60 fps wrong result】 01 wrongresult

【60fps right result】 02 rightresult

【Example Why】 1.In 30fps mode: keyframe 172 to 173. ( camera starts at 101) 03 30 172 04 30 173

2.In 60fps mode: keyframe 172x2-1 to 173x2-1, 344 is a interpolated frame. (camera starts at 201) Unfortunately, this interpolated frame will get the wrong result. Maybe it goes into the character's body.It's on the wrong coordinates. 05 60 172x2

3.60fps correction 07

it works well :)

I hope I have expressed the problem clearly. So I hope this process can be automated. My friends and I were frustrated by the complexity of the manual process. :(

nagadomi commented 2 years ago

I have reported the same problem before. If you have some programming experience, the following comments will be helpful. https://github.com/powroupi/blender_mmd_tools/issues/133#issuecomment-465828732

This problem is basically a problem on camera motion side. The same problem also occurs on MMD. To fix it manually, set the Interpolation Mode to Constant for the keyframe before the camera switches.

gk2qf commented 2 years ago

@nagadomi Thank you for that infomation! Emmmm...well, I've modified the code(importer.py) as @powroupi said, and now it works well. :) Emmmmmmmmm, why not integrate this function into MMD_TOOLS and use a Toggle to control it(ON/OFF)? @powroupi

【Importer.py】 g2

【It works!】 g3

【60fps Mode + TimeRemapping 100 to 200】 g4

powroupi commented 2 years ago

The function detectCameraChange is only working for single component/channel detection, so it has some limitations and flaws. For example, the Interpolation Mode of every frame may be set to CONSTANT when importing a baked camera motion, etc.

It's better to calculate delta rotation and delta location between 2 frames to determine the Interpolation Mode in vmd/importer.py#L325-L328. But I'm not sure what formula and threshold values are better, it might be better to take all (x, y, z, rx, ry, rz, dis, fov) in to account. :cry:

  if prev_kps is not None:
      if delta_rotation > 30 degrees or delta_location > 2 units * self.__scale: # something like this...
          for prev_kp, kp in zip(prev_kps, curr_kps):
              self.__setInterpolation('CONSTANT', prev_kp, kp)
      else:
          interp = k.interp
          for idx, prev_kp, kp in zip(indices, prev_kps, curr_kps):
              self.__setInterpolation(interp[idx:idx+4:2]+interp[idx+1:idx+4:2], prev_kp, kp)
gk2qf commented 2 years ago

@powroupi :) I see that. Baked cameras really can't use this function. And this function does need to consider many factors. But I still suggest that it be integrated into the tool as an experimental function and use a toggle to control it. It will show its limitations and flaws to the user to determine whether to use this function. How about MikuMikuDance? When I used it, I found that it had no problem outputting 60fps. It also makes interpolation correction, right?