Based on my knowledge, achieving perfectly superimposed semi-transparent and opaque versions without visual doubling is challenging due to how alpha blending works in rasterization.
Understanding the Core Issue
When you have two semi-transparent meshes overlapping, even if they're identical, the alpha blending will cause the colors to blend together, creating that "double" appearance you're trying to avoid. This is a fundamental limitation of how the rasterizer and z-buffer work with semi-transparent materials.
Potential Solutions
Here are a few approaches you might consider:
1. Conditional Rendering with Material Swapping
Instead of having two overlapped versions constantly visible, you could:
- Keep a single skeleton instance
- Swap between a normal opaque material and your semi-transparent Lit material based on occlusion state
- This avoids the overlapping issue entirely since only one version exists at any time
2. Render Texture Approach
For proper semi-transparent rendering without the overlapping artifacts, you can:
- Render your character to a RenderTexture at full opacity
- Then composite that RenderTexture to your scene at the desired semi-transparent opacity
This is the cleanest solution for achieving proper semi-transparent edges. You can use the provided SkeletonRenderTexture and SkeletonRenderTextureFadeout components as a reference. There's a demonstration in the example scene Spine Examples/Other Examples/RenderTexture FadeOut Transparency.
3. Shader-Based Depth Testing
For the occluded visibility effect specifically, you could write a custom shader that:
- Renders with a flat color when the depth test fails (object is behind something)
- Renders normally when visible
- This can be done with opaque colors to avoid the semi-transparent overlapping issue
This would require creating a shader variant that checks depth and adjusts rendering accordingly.
Important Note
The RenderTexture solution does have a performance cost, but it's the standard approach for achieving clean semi-transparent fadeout effects without overlapping artifacts. Consider whether the visual quality improvement justifies the performance impact for your specific use case.
Would any of these approaches work for your needs, or would you like me to elaborate on a specific solution?