castle-engine / castle-engine

Cross-platform (desktop, mobile, console) 3D and 2D game engine. Powerful visual editor. Support for glTF, X3D, Spine and more. Fast clean code using modern Pascal. Free and open-source.
https://castle-engine.io/
Other
960 stars 127 forks source link

Sprite rotation issue #464

Closed RAT-Daddy01 closed 1 year ago

RAT-Daddy01 commented 1 year ago

Any idea as to why when importing the spine json, the sprite rotation is messed up when in CGE but example gif export works just fine? Humonid.zip

michaliskambi commented 1 year ago

Opening the Spine JSON file in view3dscene (you can do this by double-clicking in CGE editor on the file) shows a warning that explains the issue:

Spine ..../Sprite1Human.json: Atlas region is rotated, and is used for mesh attachment. This is not supported (texture will most likely be applied incorrectly), export atlas again with "Rotate" turned off.

Following the advise and exporting with "Rotation" unchecked fixes the issue.

I would also recommend to use "Power of Two" = true, otherwise (with "Power of Two" = false, default in Spine texture export settings), CGE will resize the image to be power-of-2, making the edges blurry. Exporting with "Power of Two" = true means you can have even nice pixel-art look if you set texture filtering to Nearest.

Here's a screenshot showing recommended "Texture Packer Settings" and a recording of properly exported Spine JSON :)

spine_human_ok

https://user-images.githubusercontent.com/1076978/225485254-a2224014-5ef1-4d76-be3e-175c0e460636.mp4

To make it better for future:

  1. I improved the message: Atlas region used for mesh attachment is rotated. This is not supported, texture will be applied incorrectly. Export with "Rotation" turned off in "Texture Packer Settings".
  2. I changed the default texture behavior in Spine, to not resize to power of 2. So you can ignore my advice "I would also recommend to use "Power of Two" = true" above, in new CGE versions :)