Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Spine 4.0 Plugin Support #85

Merged
merged 11 commits into from
Sep 15, 2023
Merged

Add Spine 4.0 Plugin Support #85

merged 11 commits into from
Sep 15, 2023

Conversation

epreston
Copy link
Contributor

@epreston epreston commented Sep 14, 2023

Add Spine 4.0 Plugin Support

  • Add media and examples for Spine 4.0 runtime
  • Update build system to create 4.0 plugin
  • Add prebuilt plugin
  • Update docs, minor tool adjustments
  • New Owl demo is kinda fun.

Replaces: #78

Fixes a gap in the support matrix.

I confirm I have read the contributing guidelines and signed the Contributor License Agreement.

@epreston
Copy link
Contributor Author

epreston commented Sep 14, 2023

@mvaligursky had to redo the PR so it was up to date with the 4.1 support.
Nearly have it working except 4.0 demos will not display. No errors.
I think it might have something to do with the texture.

@epreston epreston changed the title Add spine 4.0 dependency alias Add Spine 4.0 Plugin Support Sep 14, 2023
@epreston
Copy link
Contributor Author

epreston commented Sep 14, 2023

Raptor 4.0 should look identical to Raptor 4.1 demo. Nothing displays for 4.0
Owl 4.0 demo should look like the following. I hope to use the owl so each version has a unique looking demo. Currently, nothing displayed for 4.0 but everything loaded, no errors.

OwlDemoEndState

@epreston
Copy link
Contributor Author

epreston commented Sep 14, 2023

If I modify the json file version of the owl demo and use 4.1 library, the owl demo works without modification. If I use the 4.0 library, no errors, but nothing displays.

CPT2309150706-450x356

To reproduce, modify spine40/demos.json, 4th line:

    "spine": "4.1.23",

In the owl40.html modify the 43 nd line:

new pc.Asset("playcanvas-spine.4.1.js", "script", { url: "../build/playcanvas-spine.4.1.js" }),

Make the owl track the cursor position.
@epreston
Copy link
Contributor Author

epreston commented Sep 15, 2023

For version 4.0, it looks like textures are accessed through the "page" property. For RegionAttachment and MeshAttachment we need to make the following adjustments.

The following:

// create / assign material
if (attachment.region && attachment.region.texture) {
    const texture = attachment.region.texture.pcTexture;

Becomes:

// create / assign material
if (attachment.region && attachment.region.page.texture) {
    const texture = attachment.region.page.texture.pcTexture;

To support 4.0, textures are stored under the page property.
Update version support details and provide more information.
@epreston
Copy link
Contributor Author

Ready for review, please be sure to check out the Owl demo.

If two raptor demos is confusing, I can remove the 4.0 version.

@epreston epreston marked this pull request as ready for review September 15, 2023 01:59
@epreston
Copy link
Contributor Author

epreston commented Sep 15, 2023

One area of improvement that needs an engine / graphics expert. The grey outline makes me think the pre-multiplied alpha is wrong. The plugin just assumes this is:

material.blendType = pc.BLEND_PREMULTIPLIED;

I've seen data files that have a "pma" attribute for textures, which we could read and honour. Thing is, this is something that I get wrong all the time. It could just be that its on a grey background. I don't know.

The first screenshot above is from the original spine demo, outlines are nice and crisp. In that demo they are using an alphaTest threshold of 0.5, I don't know what the equivalent or how that is achieved in PlayCanvas Engine.

Copy link
Contributor

@mvaligursky mvaligursky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Top contribution, much appreciated!

@mvaligursky mvaligursky merged commit 02557e1 into playcanvas:main Sep 15, 2023
1 check passed
@epreston epreston deleted the spine-40-support branch September 15, 2023 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants