• Unity
  • Render skeleton multiple times in another location?

Related Discussions
...

I'm working on a re-creating this reflection shader:

I'm trying to figure out how I can render the same skeleton again, flipped upside-down (I'll use scaleY), and at a specific stage in Unity's rendering pipeline (I could use a specific Sorting Layer for the reflections).

I looked at the SkeletonGhost but it didn't seem like I could use that.

Would appreciate any help!


Follow-up Question: In order to achieve the "watery / icy" look of those reflections I have to distort them in the shader. Should I copy the Spine/Skeleton shader, and add the distortion stuff there?

It also needs to use Masking or make use of the Stencil. I see that I can select Mask Interaction on the Skeleton Animation, and that seems to have created and set the Material of the Mesh Renderer to "spine_character_Material_InsideMask". I see that the material has an option for Stencil Comparison. If I want to use the Stencil AND distort the image (the watery/icy look), should I make a modified version of the Spine/Skeleton shader with distortion, and then create a new material with that shader and set the Stencil Comparison appropriately?

Thank you guys 🙂

Regarding the first question:

You could create your own copy of SkeletonGhost and adapt it accordingly so that it always draw the same mesh with a Y-flipped GameObject.
Please note that it spawns N GameObjects which are hidden in the Hierarchy panel, see this line: spine-runtimes/SkeletonGhost.cs at 3.8. You can change it to 0 to see it in the Heriarchy and assign your own Mirrored Ice material to the single flipped instance. You can then ensure to copy the Mesh of the same frame instead of being one frame behind.

Another solution would be to create your own copy of your desired Spine shader, and be sure to decide early which one you will choose: do you need lighting? Other special features of the Spine/Sprite/ shaders?
Then based on this shader, you could add an additional render pass (have a look at the Outline pass at the Spine/Outline/ shaders) to it that renders the mesh flipped vertically at it's origin in the vertex shader.

Regarding the second question:
The simplest way would be to create a copy of an existing Spine shader. There you could easily add your own distorted and colorized fragment shader.
Whether you want to use Unity's built-in masking functionality or set your own custom stencil parameters like this

Stencil {
   Ref [_ReflectionStencilValue]
   Comp Equal
   Pass Keep
}

depends on what else you want to mask in your game. At first I would recommend to use the built-in masking functionality provided by Unity. At your MirroredIce.shader or shader pass you can then set the stencil Ref parameter to always 1 and Comp to LessEqual (Note: UnityEngine.Rendering.CompareFunction.LessEqual = 4) to only draw inside Unity's masks.

Harald wrote

Regarding the first question:

You could create your own copy of SkeletonGhost and adapt it accordingly so that it always draw the same mesh with a Y-flipped GameObject.
Please note that it spawns N GameObjects which are hidden in the Hierarchy panel, see this line: spine-runtimes/SkeletonGhost.cs at 3.8. You can change it to 0 to see it in the Heriarchy and assign your own Mirrored Ice material to the single flipped instance. You can then ensure to copy the Mesh of the same frame instead of being one frame behind.

Another solution would be to create your own copy of your desired Spine shader, and be sure to decide early which one you will choose: do you need lighting? Other special features of the Spine/Sprite/ shaders?
Then based on this shader, you could add an additional render pass (have a look at the Outline pass at the Spine/Outline/ shaders) to it that renders the mesh flipped vertically at it's origin in the vertex shader.

Regarding the second question:
The simplest way would be to create a copy of an existing Spine shader. There you could easily add your own distorted and colorized fragment shader.
Whether you want to use Unity's built-in masking functionality or set your own custom stencil parameters like this

Stencil {
   Ref [_ReflectionStencilValue]
   Comp Equal
   Pass Keep
}

depends on what else you want to mask in your game. At first I would recommend to use the built-in masking functionality provided by Unity. At your MirroredIce.shader or shader pass you can then set the stencil Ref parameter to always 1 and Comp to LessEqual (Note: UnityEngine.Rendering.CompareFunction.LessEqual = 4) to only draw inside Unity's masks.

(Not sure why the youtube video isn't embedding - here is the direct link: Reflection shader test 1 - YouTube)

@Harald thanks so much for the help!

I set up a modified version of the SkeletonGhost that flips the "ghost" upsidedown, and applies a material that has a custom copy of the Spine/Skeleton shader (with Stencil Comparison = LessEqual) and adds the distortion effect.

Seriously appreciate the in-depth response!

Looks very cool, glad you got it working so quickly!
And thanks for the kind words, glad it helped! 🙂