• RuntimesUnity
  • Adding a new Shader Graph animation/material in Unity

I'm using spine for my characters for my visual novel game (I'm also using naninovel), and wanted to make a glitch effect that I can enable and disable at will. So, I try and learn to create it on Unity's Shader Graph. (I tried to create it in "Sprite lit shader", in case this affects anything)

From the tutorials that I found, it seems that I need a material for each shader graph. I have tested this on normal sprite and it works just fine.

Problem is, I can't seem to add a new material in the Mesh Renderer. I've read some related post in this site, but being new to both shader graph and spine, I'm not sure where to start.

Any help would be appreciated, thanks!

    Related Discussions
    ...

    Hi and welcome to Spine! 😎

    AzkaRenata From the tutorials that I found [..]

    Which tutorials do you mean?

    [..] it seems that I need a material for each shader graph.

    This sentence sounds a bit like you're not fully accustomed how meshes, materials and shaders work.
    A Mesh uses one Material per submesh. A material uses a single shader and provides shader parameter values (like textures, float values, etc). Shader graph is a node-based editor to create shaders.

    AzkaRenata Problem is, I can't seem to add a new material in the Mesh Renderer. I've read some related post in this site, but being new to both shader graph and spine, I'm not sure where to start.

    See the spine-unity documentation on why you can't directly change materials at a SkeletonRenderer MeshRenderer:
    https://esotericsoftware.com/spine-unity#Materials

    The question is what problem do you want to solve, why do you want to add materials to the MeshRenderer's material array?

      Harald

      Thanks for the reply!

      Which tutorials do you mean?

      Several tutorials on how to make effects with shader graph. On those they create new material for each shader graph and assign it to the SpriteRenderer to apply the effect.

      This sentence sounds a bit like you're not fully accustomed how meshes, materials and shaders work.

      Yeah, I' m still really new about this topic. That's why I got confused and don't really follow other similar post here since it seems it needs some basic understanding that I don't know yet

      The question is what problem do you want to solve, why do you want to add materials to the MeshRenderer's material array?

      Basically I want to know how can I apply the glitch effect I made in Shader Graph on a Spine GameObject, and also able to toggle it from script.

      I assume I need to attach the material (which the shader graph attached to) to the GameObject. So I'm currently stuck here since I don't know how.

        AzkaRenata Basically I want to know how can I apply the glitch effect I made in Shader Graph on a Spine GameObject, and also able to toggle it from script.

        I assume I need to attach the material (which the shader graph attached to) to the GameObject. So I'm currently stuck here since I don't know how.

        Did you check out the documentation section I mentioned in my previous posting?
        https://esotericsoftware.com/spine-unity#Materials
        It describes how you can achieve that.

          6 dias depois

          Harald Sorry for the late reply

          Did you check out the documentation section I mentioned in my previous posting?
          https://esotericsoftware.com/spine-unity#Materials
          It describes how you can achieve that.

          Yes, I tried replacing the material like in the documentation. It got replaced as intended, but the sprite is all broken.

          I think maybe the correct approach is to somehow apply the Shader not adding/replacing the material? Still haven't figured out the correct way to do that though

            AzkaRenata Yes, I tried replacing the material like in the documentation. It got replaced as intended, but the sprite is all broken.

            Then you should fix the material which replaces your default material. Likely some parameters are not setup properly or the wrong texture is assigned at the Material.

            AzkaRenata I think maybe the correct approach is to somehow apply the Shader not adding/replacing the material? Still haven't figured out the correct way to do that though

            The correct approach is to do as the documentation says 🙂.

            In general it's always recommended to get familiar with the normal Unity workflow first, how Materials, Shaders and ShaderGraph work, before adding a layer of complexity by using it all in combination with a Spine skeleton.

              Harald

              Then you should fix the material which replaces your default material. Likely some parameters are not setup properly or the wrong texture is assigned at the Material.

              I see... I'm currently learning more about the parameters to see if anything was set wrong. I tried setting it like in the documentation.

              The result is somewhat better, but still isn't quite right.

              The reason I think maybe I should apply the shader directly, is because I'm using Naninovel, and the settings allow us to set shader directly.

              I tried that and It works. But there's no way to access it directly, so I can't toggle it on/off.

                AzkaRenata The result is somewhat better, but still isn't quite right.

                Please note that we don't know your game, and what your scene is expected to look like. It's pretty hard to tell which parts look as desired and which are off, and in which way they are wrong (distorted, wrong color overlay, etc).

                AzkaRenata The reason I think maybe I should apply the shader directly, is because I'm using Naninovel, and the settings allow us to set shader directly.

                Please note that if you're using thirdparty assets, you might need to adjust the respective Naninovel code to switch materials or apply shaders accordingly.

                I tried that and It works. But there's no way to access it directly, so I can't toggle it on/off.

                I'm not sure I understand what you mean by "to access it directly" and why you can't turn the effect off as a consequence. Please in general always describe your issue as precisely as possible - what you are doing and what exactly is causing you problems in code. Otherwise we will need to ask a lot of questions and unnecessary writing back and forth.