• RuntimesUnity
  • I want to know how to use SkeletonGraphicFill in a skeleton graphic.

This is version 4.1 of SPINE.

I want to know how to use SkeletonGraphicFill in a skeleton graphic.

Does it simply replace the material in the skeleton graphic?

If I do this, my character just keeps coming out all white.

I want it to flash white briefly only in certain situations (ex. getting hit).

Related Discussions
...

To use the SkeletonGraphic Fill shader in Spine version 4.1 for a skeleton graphic, you can indeed replace the material on the SkeletonGraphic component with one that uses the SkeletonGraphic Fill shader. This approach is confirmed to work with version 4.1, as mentioned in the forum post where it was stated that you can use the previous version of the SkeletonGraphic Fill shader with 4.1.

For your specific use case, where you want the character to flash white briefly only in certain situations (like getting hit), you might consider using a different shader or technique for that effect. The SkeletonGraphic Fill shader is not designed for temporary effects like flashing. Instead, you could use the Spine/Skeleton Tint Black shader or manipulate the color of the SkeletonGraphic directly in code to achieve a flashing effect. For example, changing the color to white and then back to its original color over a short duration. Remember, direct manipulation of the color property or using a shader that supports tinting might be more appropriate for temporary effects like flashing.

@chashkim Spinebot is basically correct. For a flashing effect it is indeed tint black coloring which is recommended. For SkeletonGraphic it's the respective Spine/SkeletonGraphic Tint Black shader which we would recommend using.

However, the reason why you have seen a white skeleton with the SkeletonGraphic Fill material no matter what Color you set at SkeletonGraphic is as follows:
The Inspector Color (now called Skeleton Color) property of SkeletonGraphic sets the skeleton's vertex color (the primary color), not the Fill Color, which is the secondary color which defaults to white. This Fill Color has to be set at the respective Material. Now unfortunately with CanvasRenderer (which SkeletonGraphic uses) things are a bit clumsy to edit: You have to duplicate e.g. the SkeletonGraphicFill material and assign your custom settings at this copy, like e.g. settings the Fill Color to red and Fill Phase to 0.5 for a semi-transparent red fill. Now the bad part is that the CanvasRenderers using this Material don't automatically update, so the best way is to use CTRL+S to save the modified assets which also immediately triggers the scene to update and show your changes.

Similar rules apply when setting the secondary color Black at a SkeletonGraphic Tint Black material.

Do you have an example implemented as a skeleton graphic?

I noticed in the 'SpineGauge' example scene that it is implemented in the 'HurtFlashEffect' code.

This is how I used to do it with SkeletonAnimation, but I don't quite understand how to do it with SkeletonGraphic.

@chashkim Sorry, there is no SkeletonGraphic variant of the HurtFlashEffect script available, because CanvasRenderer works differently and does not support MaterialPropertyBlock or setting material parameters. Instead you would create a single Flash material and assign this material when the flash color should be shown, and afterwards re-assign the normal material.

  • chashkim ответили на это сообщение.

    Harald

    I found the problem!

    I had previously configured the code to swap Materials for about 0.1 seconds, but it didn't make a difference.

    I was using a Skeleton Graphic Render Texture on an object created with SkeletonGraphic, so it didn't change (I used that component to make it disappear naturally when adjusting transparency).

    When I accessed the quad of the SkeletonGraphicRenderTexture and replaced the Material in this area, it drew correctly.

    I have an additional question.

    If I use the SkeletonGraphicRenderTexture, does the SkeletonGraphic's Material not get applied?

    Since the Material is not applied, there is a slight difference in the character drawn with and without the SkeletonGraphicRenderTexture component.

    Do I need to manually assign a Material to it during initialization when I first create it?

    Or am I using it incorrectly? My process is as follows

    1. create a SkeletonGraphic object
    2. add a SkeletonGraphicRenderTexture component.
    3. Set up the above object as a prefab.
    4. Instantiate and use it in the scene when needed.

    We are using the above.

    Should I use the SkeletonGraphicRenderTexture with enable=true only when needed, for example only for Fade In/Out.

    Thanks for your help.

    All questions are being translated using deepl.

    There may be some strange translations. I apologize.

    • Harald ответили на это сообщение.

      chashkim When I accessed the quad of the SkeletonGraphicRenderTexture and replaced the Material in this area, it drew correctly.

      Replacing the material of the quad is not the recommended way to do it. The RenderTexture is intended to be rendered to the scene without any special shaders. The recommended workflow is to set up the skeleton as desired with any special material settings and render it to the RenderTexture. Then this RenderTexture shall be rendered without any special material settings, only optional transparency, to the scene buffer.

      SkeletonGraphicRenderTexture works in a slightly special way and does not directly use the SkeletonGraphic's current material since that unfortunately can't be used (only non-CanvasRenderer materials can be used when rendering to a RenderTexture). SkeletonGraphicRenderTexture uses the materials assigned at the property meshRendererMaterialForTexture instead when rendering to the RenderTexture. So you need to set the SkeletonGraphicRenderTexture material property meshRendererMaterialForTexture to your desired material. Note that it has the skeleton's standard materials (the ones from the assets folder of the skeleton) pre-assigned when the component is created. There you would need to create a copy of the skeleton_Material asset and name it e.g. skeleton_FlashRed and assign this to SkeletonGraphicRenderTexture.meshRendererMaterialForTexture when the flash effect shall be displayed. After it shall no longer be displayed, re-assign the previous material at the same property.

      • chashkim ответили на это сообщение.

        Harald

        1. so how do I implement the Sparkle effect?
          (Using the Skeleton Graphic RenderTexture)

        To use Sparkle without touching the Quad of the RenderTexture, should I disable the RendeurTexture Component normally and only enable it when fading in/out?

        1. Currently when using Skeleton Graphic RenderTexture, some shaders are not applied (Spine/Blend Modes/Skeleton PMA Additive, Spine/Blend Modes/Skeleton PMA Multiply).

        The settings for the SkeletonGraphic are the default with only Multiple CanvasRenderer enabled. (Screenshot below)

        I created the Spine as a SkeletonAnimation and verified that the two missing shaders above are applied correctly and drawn to the screen when the object is created with a Skeleton Render Texture.

        1. Is it correct to use a regular Skeleton Animation instead of using a Skeleton Graphic?

        I wanted to use SkeletonGrpahic to make everything work on top of Canvas, but it doesn't seem to work well (maybe my understanding is off).

        • Harald ответили на это сообщение.

          chashkim To use Sparkle without touching the Quad of the RenderTexture, should I disable the RendeurTexture Component normally and only enable it when fading in/out?

          It would be good to not use the RenderTexture when it's not necessary, since the RenderTexture workflow is costly performance-wise. That might however lead to twice as much setup effort.

          chashkim Currently when using Skeleton Graphic RenderTexture, some shaders are not applied (Spine/Blend Modes/Skeleton PMA Additive, Spine/Blend Modes/Skeleton PMA Multiply).

          Yes, since SkeletonGraphicRenderTexture.meshRendererMaterialForTexture corrently only allows assigning a material per texture, but not per texture and blend-mode. Note that SkeletonGraphicRenderTexture is just an example component, these can never support the full feature set of all possible combinations. You could create your own subclass or class based on the code and modify it accordingly if you need additional functionality.

          chashkim Is it correct to use a regular Skeleton Animation instead of using a Skeleton Graphic?

          I wanted to use SkeletonGrpahic to make everything work on top of Canvas, but it doesn't seem to work well (maybe my understanding is off).

          Yes, if you need the full feature-set of multiple blend modes, using SkeletonAnimation for rendering to the RenderTexture is easier and recommended.