bladynator

  • 23 апр 2020
  • Регистрация: 25 фев 2020

    Again, i'm not that good with shaders yet 🙂 And it seems like I misunderstood some of your questions..

    First of all: YES, it is fixed by removing the col.rgb *= col.a;

    The shader is correct, but the _Alpha variable is used for some other special effects that I didn't include in my shipit, so it was a bit redundant.

    As for the overrides, I have 2 materials: one that Spine made for me with the Spine shader (mat.shader) and another different material with my own shader (WaveController.Instance.enemyShader)

    Thank you so much for your time, help and extra information! I really appreciate it!

    Ah, alright! I'm really not that good with shaders, so i'm just trying stuff 🙂

    Yes, you understood that correctly. I override every shader in every material that Spine2D makes. (which is currently just 1 material with 1 shader, so the foreach only loops once).
    The shader I currently use has a bunch of effects that you can enable to add them to each other, but I get the same black lines with all of those effects disabled.
    The frag shader that remains is this:

    fixed4 frag (v2f i) : SV_Target
    {
          fixed2 uvRect = i.uv;
          fixed4 col = tex2D(_MainTex, i.uv) * i.color * _Color;
          col.rgb *= col.a;
    
      col.a *= _Alpha;
    }
    

    Removing that last line (col.a *= _Alpha) doesn't change much, and adding your suggested line after it doesn't do much either.
    Multiplying the col.rbg by 2 makes the sprite lighter, so at least I know the shader is still doing SOMETHING 😉

    Sorry, i'm not quite sure I understand your question.
    This is a custom shader, so i'm not sure if it uses your prefered setup. How can I check this?
    I disabled every effect in that shader, but it still gives me the same result.
    I tried adding the "#pragma shader_feature" to my shader, but that didn't do much either.

    So, I tried to change a bunch of stuff and found something that got rid of the black lines.

    You see, I use a CustomMaterialOverride with my own custom shader. Disabling this override gets rid of those black lines. I'll experiment a bit further about what in that shader causes it, but maybe you already have an idea?

    This is the code I use for the override incase it helps:

    Material[] allMats = mesh.materials;
            skel.CustomMaterialOverride.Clear();
    
        foreach (Material mat in allMats)
        {
            Texture sprite = mat.mainTexture;
            skel.CustomMaterialOverride.Add(mat, WaveController.Instance.enemyMat);
            mat.shader = WaveController.Instance.enemyShader;
            mat.CopyPropertiesFromMaterial(WaveController.Instance.enemyMat);
            mat.mainTexture = sprite;
        }
    

    So far, it seems to work for other animations I made with Spine2D, so that's still a bit odd.

    Thank you, that link was very helpful!

    Interestingly, this fixed the problem in the prefab, but not during runtime.

    Thank you for the reply!

    Sadly, this didn't fix the issue. I do however see an error in that component:

    We do use Linear colour space though since all of our shaders are made for that.

    Enabling the "Straight alpha texture" in the material seems to make the black lines worse.

    Hey there!

    We recently started using Spine for our animations and came across an issue.There seems to be more people with this issue, judging by your search system, but none of the fixes there fixed it for us. Hence the new post.

    As you can see, our animation here has these weird small black lines between the different sprites.
    We tried setting the Premultiply alpha and the bleed inside the texture packer settings in the Spine exporter, but nothing seems to help.
    I also tried fiddling with the Unity sprite settings (mipmaps, filters) but still nothing.

    Any suggestions are highly welcome!

    • Изменено