EsotericSoftware / spine-runtimes

2D skeletal animation runtimes for Spine.
http://esotericsoftware.com/
Other
4.41k stars 2.91k forks source link

[unity] Add fadeout example scene #1337

Closed HaraldCsaszar closed 2 years ago

HaraldCsaszar commented 5 years ago

Status: There are multiple questions on the forum regarding how to render a Spine character with proper translucency, without back parts shining through.

Forum postings: http://esotericsoftware.com/forum/Help-plz-How-do-I-make-my-character-translucent-in-Unity-11829 http://esotericsoftware.com/forum/Unity3D-11776

Possible Solutions: a) Cutout shader with depth test / depth write, sacrifices nice border alpha - according to Nate this is not an option. b) Render to texture - render a character to it at 100% opacity, then render the properly composited result to scene at desired opacity. c) Dither-dissolve fade-out - use a dithering pattern to dissolve a character pixel-wise. Might be suitable at some art styles.

This example scene should show at least solution (b), would be nice to show also (c).

elringus commented 4 years ago

Hey, I've recently made a render to texture for Live2D models to handle a similar issue by rendering each individual mesh with Unity's Graphics API: https://github.com/Elringus/NaninovelLive2D/blob/master/Assets/NaninovelLive2D/Runtime/Live2DCharacter.cs#L207

I wonder if Spine SDK for Unity can do something similar out of the box, so that I can just provide a render texture and it'll render the character to it? If not, the Live2D implementation above could be useful for making this fadeout example.

havudk commented 3 years ago

@HaraldCsaszar Thanks for your hard work. is there ticket finish? where can I get example scene? Best regards.

HaraldCsaszar commented 3 years ago

@havudk Unfortunately we did not yet get to implement this ticket, therefore you can see the status as Open, when it's finished it's status is Closed.

elringus commented 3 years ago

In case anyone is interested, I've implemented the same stuff for Spine as well: https://github.com/Naninovel/Spine/blob/main/Assets/NaninovelSpine/Runtime/SpineDrawer.cs It'll draw Spine model to a render texture, which you can then fade or apply other shader effects.

HaraldCsaszar commented 3 years ago

@Elringus Awesome! Thanks a lot for sharing, this is very much appreciated! You rock! 👍 🥇

HaraldCsaszar commented 2 years ago

A new example component SkeletonRenderTexture has been added to the repository, alongside with a fadeout example scene named 'RenderTexture FadeOut Transparency'. This commit has been pushed to 4.0, it will be merged to 4.1-beta soon.

A new 4.0 spine-unity unitypackage is available for download.

HaraldCsaszar commented 2 years ago

Thanks again @Elringus for sharing your existing code, it really helped me save the time to look up a lot of API reference pages :).

Alexees commented 2 years ago

@HaraldCsaszar we're still relying on 3.88 due to all the spine animations that we would need to convert. Is this SkeletonRenderTexture hard to use there?

HaraldCsaszar commented 2 years ago

The 4.0 components should be usable as-is in 3.8, so you can copy over the respective .cs files and the example scene. See this forum thread: http://esotericsoftware.com/forum/I-made-an-animation-of-a-character-disappearing-in-Unity-17156?p=75457#p75457