Chill

Hello everyone,
my character is drawn with lines, base color and shading like this:

and i want to be able to change the color of these 3 later in unity. So seperate color for the line, the base color and the shading. To do so i need to make a grayscale image and have access to these parts of every layer. But it seems i cannot put them in one slot, because then i can only show one at a time and have to build three meshes. So is this possible in spine to have all three layerparts in kind of a folder to build one mesh on and access the colors later in unity? Thanks in advance :)
Chill
  • Mesajlar: 6

Harald

You can share and re-use a single mesh by using what is called "linked meshes" in Spine:
Mesh attachments - Spine User Guide: Linked meshes
You don't have to use meshes of course, you could also use multiple normal region attachments. You would then attach each pair or image-triple to the same bone.

A different approach would be to write your own fully customized shader for Unity where you could e.g. mark the separate regions in a separate additional "region-classification" input texture which you then use to shift colors of the main texture around. This would however require some shader programming.
Kullanıcı avatarı
Harald

Harri
  • Mesajlar: 3996

Chill

Thanks a lot !
I think i will try the linked mesh approach first, though the shader approach sounds cleaner. Id love to do that but i know how hard it is to write one. And im not sure how to access the seperate regions in a shader. But Thanks very much for your help i will give definitely it a try ! :)
Chill
  • Mesajlar: 6

Harald

You're welcome. :) Actually the linked mesh approach could yield a cleaner, easier-to-control result with a bit more flexibility, as the shader-based region-colorization approach is just an optimization of it, which always comes with some limitations.
Kullanıcı avatarı
Harald

Harri
  • Mesajlar: 3996

Chill

I don't know if this will be read, but i tried the shader approach and its too rough around the edges. But maybe i did it wrong, because i just tried to replace the color. So the linked mesh approach would be cleaner for me, but my problem is that linked meshes are bound to one slot. Which means only one mesh can be visible at a time, but i need all three visible at once. Does someone have a solution for this?
Chill
  • Mesajlar: 6

Harald

Chill yazdı:But maybe i did it wrong, because i just tried to replace the color.
How exactly did you replace the color? Please note that the shader code will need to handle the "transition texels" as well where e.g. the black outline and yellow trouser regions meet, there they mix e.g. 50/50 to a darker brown tone in some texels. If you only replace exact 100% color matches of black and yellow you will get jaggy staircase artifacts (similar to antialiasing artifacts) where your colors meet.

In the shader code you would then calculate the color distance of the tested texel to your classification color (e.g. yellow for trousers) and then apply your replacement colors with the respective weights. The color distance can either be calculated as distance in RGB space, or in a hue-based color space such as YCoCG or YUV if RGB does not separate your parts cleanly. You might also get away by just calculating the hue distance and (if it's close enough) replace the hue with the replacement color's hue. This way you could leave the black outline as-is and just cycle the color hue of trousers, shirt and body around.

A different, much simpler solution would be to prepare the input textures so that you don't have any unclear texels that don't match the colors to begin with.
So the linked mesh approach would be cleaner for me, but my problem is that linked meshes are bound to one slot. Which means only one mesh can be visible at a time, but i need all three visible at once
Oops, sorry, my fault - admittedly I haven't thought this through!
Kullanıcı avatarı
Harald

Harri
  • Mesajlar: 3996


Dön Runtimes