Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Dissolve Shader without Texture?

Discussion in 'Shaders' started by ysleungrockman, May 24, 2018.

  1. ysleungrockman

    ysleungrockman

    Joined:
    Mar 16, 2014
    Posts:
    32
    Hi, I'm a newbie in the area of shader. I'm currently doing a project that uses a toon shader for my model that the material only uses unicolor instead of texture. Then I want to add dissolve effect to my model so I started to find dissolve shader that I can take reference on to change my toon shader. However, I can't find any shader that uses only color to dissolve. Now the question is, is it possible to only use color to dissolve? If yes, how?
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,329
    What exactly do you mean when you say dissolve. Can you show an example of the kind of effect you're looking to achieve?

    When I think of a dissolve shader I think of an object that fades out in a non uniform way, usually based on some Perlin noise, and maybe additionally in some direction across the object or dissolving radially. The main piece is needing the noise itself, and the easiest way to do that is with a noise texture and UVs.

    But you can generate noise in the shader too. And you could use a 3D noise to avoid the need for UVs as well. If you search for noise shader you'll find several examples, though this project by Keijiro is a nice compilation of a common one translated for use with Unity.
    https://github.com/keijiro/NoiseShader

    Note that this is fairly expensive, especially compared to using a texture.
     
  3. ysleungrockman

    ysleungrockman

    Joined:
    Mar 16, 2014
    Posts:
    32
    Yes, what I mean is like you said, the object can fade out (or fade in) in a non uniform way:


    Since I want my model to be able to dissolve, I search up some dissolve shader on the Internet. But most of them need the model to have a main texture to do so, like this one: http://wiki.unity3d.com/index.php?title=Dissolve_With_Texture
    I want to have a shader that can use just color to dissolve. It is okay to use a noise texture. But I don't know how to connect it with just color and without main texture. Do you have any clue on how to do that?
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,329
    The dissolve portion of the shader you linked to is a single line in the shader code (ignoring the properties and uniform declaration for the "slice" variables).

    If you mesh has UVs it's basically as simple as copying the clip() line and the _Slice* lines into your shader. With out knowing more about what your toon shaders look like I'm not sure how more anyone can direct you apart from maybe start reading up on general shader tutorials?
     
  5. ysleungrockman

    ysleungrockman

    Joined:
    Mar 16, 2014
    Posts:
    32
    The toon shader I use was bought from the asset store: https://assetstore.unity.com/packages/vfx/shaders/anicel-14911
    But since you need to purchase this, I think it's no way for me to post the code here...
    If that's the case, maybe I'll just make some unicolor texture for the UV instead, since there's not much time left...