Chill

hey guys,
i'm trying to make a custom shader with Shader graph and want to integrate that cool tint effect, that you get when modifying the Dark Color from the Spine/Skeleton Tint Shader. i don't know shaders that well yet, the closest i came up with is this:
skeleton tint shader graph.png

it is what i want, but it still has the black lines like when im blending it straight with alpha and not with premultiply. Does anyone have an idea on how to get rid of them? And is there a possibility to render the spine shaders in alpha blending mode without the lines? And thanks a ton for all your great work :)
Non hai i permessi necessari per visualizzare i file allegati in questo messaggio.
Chill
  • Messaggi: 6

Harald

Was your input atlas texture exported with premultiplied alpha (PMA) or straight alpha (bleed)?
Could you perhaps show the (working) Material settings that you used with the Spine/Skeleton Tint shader?

In case you haven't already looked at it, this is the relevant original shader code:
float4 frag (VertexOutput i) : SV_Target {
float4 texColor = tex2D(_MainTex, i.uv);
return fragTintedColor(texColor, _Black.rgb, i.vertexColor, _Color.a, _Black.a);
}

float4 fragTintedColor(float4 texColor, float3 darkTintColor, float4 lightTintColorPMA, float lightColorAlpha, float darkColorAlpha) {

float a = texColor.a * lightTintColorPMA.a;

#if !defined(_STRAIGHT_ALPHA_INPUT)
float3 texDarkColor = (texColor.a - texColor.rgb);
#else
float3 texDarkColor = (1 - texColor.rgb);
#endif
float3 darkColor = texDarkColor * darkTintColor.rgb * lightColorAlpha;
float3 lightColor = texColor.rgb * lightTintColorPMA.rgb;

float4 fragColor = float4(darkColor + lightColor, a);
#if defined(_STRAIGHT_ALPHA_INPUT)
fragColor.rgb *= texColor.a;
#endif

#if defined(_DARK_COLOR_ALPHA_ADDITIVE)
fragColor.a = a * (1 - darkColorAlpha);
#endif
return fragColor;
}
Avatar utente
Harald

Harri
  • Messaggi: 4208

Chill

i got it to work! thank you very much! i previously exported it as PMA and needed to uncheck that in spine and check "Alpha is Transparency" in the unity texture settings, now it works perfectly.

With the PMA export approach i first tried to convert the spine code into shader graph, but ended up with white edges.
skeleton tint shader graph PMA.png

It must be something very simple, an alpha multiplication i'm missing or so, but i couldn't get it to work.

Anyway, would be interesting to know but it doesn't matter that much now, because thanks to your tip it works now with the straight alpha export and an alpha shader :)
Non hai i permessi necessari per visualizzare i file allegati in questo messaggio.
Chill
  • Messaggi: 6

Harald

Glad to hear you've figured it out.

If you're using PMA input textures, then it looks as if you've implemented the subtraction part incorrectly, as you're subtracting from 1 instead of from texColor.a. The code I mean is this section:
#if !defined(_STRAIGHT_ALPHA_INPUT)
float3 texDarkColor = (texColor.a - texColor.rgb); // this is executed in PMA branch
#else
float3 texDarkColor = (1 - texColor.rgb); // this is executed in straight alpha branch
#endif
Avatar utente
Harald

Harri
  • Messaggi: 4208

Chill

oh my god you are right. This is awesome thank you so much! :)
Chill
  • Messaggi: 6

Harald

You're welcome, these things are easy to miss amoung all the nodes and connection lines in the graph. :)
Avatar utente
Harald

Harri
  • Messaggi: 4208


Torna a Unity