Search Unity

► Advanced Dissolve ◄

Discussion in 'Assets and Asset Store' started by Arkhivrag, Feb 13, 2018.

  1. Deleted User

    Deleted User

    Guest

    Wow thanks i'm not blind (or maybe now after seeing your big RED ARROWS).
    My question was more : how do I control this parameter from the particle system => having the particles dissolve over time using your 'advanced dissolve'. Apologizes.
     
  2. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    From ParticleSystem there is no access to the material and its properties. Neither for Advanced Dissolve, nor any other shader.
    You can adjust visual appearance for all particles at once, but modifying material property individually based on "age" in ParticleSystem is not possible.



    Amazing Assets - YouTube Facebook Twitter
     
    Last edited: Apr 16, 2020
  3. Deleted User

    Deleted User

    Guest

    I'm sorry but ... we do have access to Custom Parameters: TEXCOORD0.z; check this out :
    http://blog.onebyonedesign.com/unity/dissolving-particles-with-custom-vertex-streams/

    No ? Or i haven't grasped the concept ... if so, my questions is 'how' do i plug this into your "Advanced Dissolve" using Shader Graph ?
     
  4. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Vertex stream data can be implemented into any shader, and Advanced Dissolve too. But it is competently up to you,
    you have to manually modify shaders and 'inject' vertex stream data.

    Advanced Dissolve inside shader is calculated in fragment shader part.
    Search for AdvancedDissolveGetAlpha string in shader and adjust any variable before it.
    For example if you already got particle age inside shader and want it to effect cutout, code will look something like this:
    Code (CSharp):
    1. _DissolveCutoff = IN.particleAge;  //   <------  Any modifications have to be done before executing Advanced Dissolve main method
    2.  
    3.  
    4. //Advacned Dissolve calcualtations start here
    5. float4 alpha = AdvancedDissolveGetAlpha(......);    
    6. DoDissolveClip(alpha);



    Amazing Assets - YouTube Facebook Twitter
     
  5. caesuric

    caesuric

    Joined:
    Aug 28, 2017
    Posts:
    4
    Hi there. This asset is truly awesome and works perfectly with minimal trouble for at least some materials. However, I have noticed that when I try to modify the shader of certain materials at runtime and then ramp up the _DissolveCutoff variable to get a fade effect, I get no change for 75% of the effect, a bright orange highlight for the last 24.99%, and then the model disappears from bright orange to invisible at 100%. (note: orange is my DissolveEdgeColor so this at least somewhat makes sense)

    I have been poring over the documentation and cannot figure out what might be causing this. Are there any settings a material requires to make use of these shaders? Thank you!

    EDIT: I have now discovered that if you go into the texture's import settings and set "alpha source" to be "From Gray Scale" it works perfectly. This isn't always a good option, but it's good to know. Would still be curious if there's another way around this, as some of my textures don't display correctly this way.
     
    Last edited: Apr 17, 2020
  6. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    _DissolveCutoff variable cuts texture based on alpha value, if this alpha is smooth, then dissolve is also has smooth transition.

    Almost all cutout shader work the same way. Just provide smooth alpha from texture.



    Amazing Assets - YouTube Facebook Twitter
     
  7. caesuric

    caesuric

    Joined:
    Aug 28, 2017
    Posts:
    4
    Thank you so much for your reply. However, I am not sure how one "provides a smooth alpha from texture." Do I do this by modifying the "Smoothness" slider in the texture, and if so, am I supposed to set it to 1 or something? Or is it something else altogether?

    Also can I do this at runtime, or is it necessary to do it to each individual texture beforehand?
     
  8. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    upload_2020-4-17_22-7-26.png

    Left is smooth alpha. For it cutout process will be smooth and gradual.



    Amazing Assets - YouTube Facebook Twitter
     
  9. caesuric

    caesuric

    Joined:
    Aug 28, 2017
    Posts:
    4
    Thank you for your quick replies, but I don't think that is the issue at all. I am successfully setting the shader and all its settings at runtime, including a gradual cutout texture and custom edge texture. The shader appears checked and all options appear correct. However, the sudden color change still occurs unless I set the shader in the editor.

    If I pause the editor playback and go to the material's shader options, then set the shader to the EXACT ADVANCED DISSOLVE SHADER I already programmatically selected (it appears with a checkmark), the shader suddenly starts working as intended. I don't know if this is a bug in Unity or the shader or what, but it doesn't really make sense to me.

    I guess I can go set every material I intend to use this effect on to the dissolve shader in the editor manually, but there are a lot of materials, so I was hoping to swap it in dynamically as needed.
     
  10. ccthien

    ccthien

    Joined:
    May 16, 2015
    Posts:
    12
    Could you include example screen for Text Mesh Pro?
     
  11. Banksy

    Banksy

    Joined:
    Mar 31, 2013
    Posts:
    376
    I've just purchased A-Dissolve ( works a treat ) :)
    Am considering "Curved World" but.... Does it work with VR ?
     
  12. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Both assets work.



    Amazing Assets - YouTube Facebook Twitter
     
  13. ccthien

    ccthien

    Joined:
    May 16, 2015
    Posts:
    12
    Could you point me to where is the example for Text Mesh Pro? A demo Scene I mean, or a tutorial how to make it. Thanks.
    Also I test on Unity 2019.3.7f, the demo screen show on editor, but game screen is totally black...
    upload_2020-4-19_17-43-7.png
     
  14. ccthien

    ccthien

    Joined:
    May 16, 2015
    Posts:
    12

    This demo please.
     
  15. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Just tested with Unity 2019.3.9 and at my side everything works as expected.
    Scene uses post processing asset, did you import it? Try disable it from camera.

    upload_2020-4-19_15-19-58.png


    As for TextMesh Pro scene: Just create standard TextMesh Pro object with desired settings and change its default shader to VacuumShaders\Advanced Dissolve\TextMesh Pro shader. That's all.
    Shader includes all Advanced Dissolve features and works the same way as on common meshes.

    For example:
    upload_2020-4-19_15-22-21.png



    Amazing Assets - YouTube Facebook Twitter
     
    Last edited: Apr 19, 2020
    ccthien likes this.
  16. caesuric

    caesuric

    Joined:
    Aug 28, 2017
    Posts:
    4
    Unfortuantely, even when I set all of my materials to Advanced Dissolve materials before the scene even starts, it still isn't working. I'm beginning to wonder if this is somehow an issue with my shader settings in Graphics.

    Here's what I am trying to do to animate the effect... maybe I am doing something wrong, but it seems like this is pretty basic and should work:

    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. class MonsterMortal : MonoBehaviour {
    4.     public bool died = false;
    5.     public float fadeOutIntensity = 0f;
    6.     public Shader shader;
    7.     public Texture texture;
    8.     public Texture gradientTexture;
    9.     public float fadeOutTime = 5f;
    10.  
    11.     void Update() {
    12.         if (!died) return;
    13.         fadeOutIntensity += Time.deltaTime / fadeOutTime;
    14.         var renderers = GetComponentsInChildren<Renderer>();
    15.         foreach (var renderer in renderers) {
    16.             foreach (var material in renderer.materials) {
    17.                 material.SetFloat("_DissolveCutoff", fadeOutIntensity);
    18.             }
    19.         }
    20.     }
    21.  
    22.     public void OnDeath() {
    23.         if (died) return;
    24.         died = true;
    25.         var renderers = GetComponentsInChildren<Renderer>();
    26.         foreach (var renderer in renderers) {
    27.             foreach (var material in renderer.materials) {
    28.                 material.shader = shader;
    29.                 material.SetFloat("_DissolveCutoff", 0);
    30.                 material.SetFloat("_DissolveAlphaSource", 1);
    31.                 material.SetTexture("_DissolveMap1", texture);
    32.                 material.SetColor("_DissolveEdgeColor", new Color(1, 0.7f, 0, 1));
    33.                 material.SetFloat("_DissolveEdgeWidth", 0.125f);
    34.                 material.SetFloat("_DissolveEdgeShape", 1);
    35.                 material.SetFloat("_DissolveEdgeColorIntensity", 1);
    36.                 material.SetFloat("_DissolveEdgeTextureSource", 3);
    37.                 material.SetTexture("_DissolveEdgeTexture", gradientTexture);
    38.                 material.SetFloat("_SmoothnessTextureChannel", 1);
    39.             }
    40.         }
    41.         Destroy(gameObject, fadeOutTime);
    42.     }
    43. }
    44.  
    EDIT: Never mind, sorry, I figured it out. For anyone else new to this sort of thing, the KeywordEnum values in the shader settings don't do anything on their own. You have to enable the corresponding keywords like so in this case:

    Code (CSharp):
    1.  
    2. material.EnableKeyword("_DISSOLVEALPHASOURCE_CUSTOM_MAP");
    3. material.EnableKeyword("_DISSOLVEEDGETEXTURESOURCE_CUSTOM");
    4.  
     
    Last edited: Apr 19, 2020
  17. ccthien

    ccthien

    Joined:
    May 16, 2015
    Posts:
    12
    Thank you Arkhivrag, it work now. For the demo and TextMeshPro.
    upload_2020-4-19_23-10-4.png

    Could you share the setting you do on your demo TextMeshPro?
     
  18. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    You mean TextMesh Pro shader settings? I really do not remember them, just created that simple scene for demonstrating that asset it TextMesh Pro compatible.
    As for glow effect, it is achieved with post processing and bloom filter. Adjust edge color emission using Intensity parameter.



    Amazing Assets - YouTube Facebook Twitter
     
  19. ccthien

    ccthien

    Joined:
    May 16, 2015
    Posts:
    12
    Yes Intensity is what I am looking for. Thank you. Will rate 5 stars. :cool:
    output.gif
     
  20. ccthien

    ccthien

    Joined:
    May 16, 2015
    Posts:
    12
    I have another question: Could we do this with a PNG image?
     
  21. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    If image is applied to mesh (plane for example) then yes.
    If you mean GUI image, then mostly no. This shader is not written for GUI elements, but you can try.



    Amazing Assets - YouTube Facebook Twitter
     
  22. ccthien

    ccthien

    Joined:
    May 16, 2015
    Posts:
    12
    Thank you Arkhivrag, it seem to work. Just a little issue: it do not show my original image, just use anpha map.
    upload_2020-4-21_13-35-23.png
     
  23. ccthien

    ccthien

    Joined:
    May 16, 2015
    Posts:
    12
  24. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    ccthien likes this.
  25. XANTOMEN

    XANTOMEN

    Joined:
    Dec 18, 2012
    Posts:
    41
    Hi!

    I've noticed that Unity Nature and SpeedTree dissolve shaders are available for the Standard pipeline, but not for Universal. I was assuming from the Store Description the listed Shaders would be available for the 3 supported pipelines. Is there plans to have those shaders included in the future, or not?

    Also, I am aware this isn't part of the asset, but could I ask, where would I get started if I wanted to make a shader that can dissolve Unity terrain (the base, not the terrain Trees)? (Preferably in Universal, but I'd defer to Standard if that was dramatically easier). I'm using terrains from 2019.3.

    Thank you!
     
    Last edited: Apr 22, 2020
  26. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Will try to update with Terrain and Nature shaders for URP by the end of the week.



    Amazing Assets - YouTube Facebook Twitter
     
  27. XANTOMEN

    XANTOMEN

    Joined:
    Dec 18, 2012
    Posts:
    41

    Woah that would be amazing! Thank you!
     
  28. afterdark1973

    afterdark1973

    Joined:
    Nov 25, 2019
    Posts:
    10
    Hey! this is absolutely perfect for the game I am working on - can you confirm if/when it will work with HDRP 7.3+ please? Its not clear from the documentation.... thanks!
     
  29. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Download new update.


    Will definitionally have HDRP update, but do not expect it until June. Just very busy with my other assets.



    Amazing Assets - YouTube Facebook Twitter
     
    Last edited: Apr 24, 2020
    XANTOMEN and afterdark1973 like this.
  30. XANTOMEN

    XANTOMEN

    Joined:
    Dec 18, 2012
    Posts:
    41
    Thank you for the support! It was a nice surprise!

    I have downloaded it, and unfortunately so far what my tests have resulted on is:

    Terrain shader isnt working well. Here is with Box mask type, which I've tried with most settings, and then just copied the same exact Advance Dissolve settings as in CactusPack material. Unchecking Inverted makes none of the Terrain ever show up.

    https://gyazo.com/5d5bcecc3eb32b1d94c3324a4c3d73b1

    Planar Mask actually brings up a Dissolve effect (as do XYZ, Sphere and Cylinder. However the cut is not following the orientation of the mask object, and seems to just be based on the zero coordinate:

    https://gyazo.com/eb5be1db55c588c78a95552af06006d7

    As for the Nature shaders, I've observed that only SpeedTree shaders are available for Trees, and not the default Unity shaders, such as Tree Creator Bark and Tree Creator Leaves. Besides that, SpeedTree shaders seem to have the same problem with mask. Plane mask only really work in the center of the world, and not based on the Mask Object:

    https://gyazo.com/bae6372b1a60dd4deefd62c52d28461d

    I've tried both in my current project and in an empty project, with only the Advanced Dissolve package as assets. Unity version 2019.3.9f1.

    Thanks.
     
  31. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    To make dynamic masks work with terrain enable Global Control for mask inside material editor and if using included mask controller scripts, turn on Update Global parameter. Same as all nature shaders if they are used within terrain system.

    As for Tree Creator Bark and Tree Creator Leaves shaders, they are not included in Unity URP package, where did you get them?



    Amazing Assets - YouTube Facebook Twitter
     
  32. XANTOMEN

    XANTOMEN

    Joined:
    Dec 18, 2012
    Posts:
    41
    It works! Thank you so much! This will be of great help in my current project!

    As for Tree Creator Bark and Leaves, you are right! I'm sorry, I'm new to URP and I had clicked on Nature instead of Universal Render Pipeline > Nature.
     
  33. lordzeon

    lordzeon

    Joined:
    Jun 1, 2018
    Posts:
    44
    Hi Arkhivrag, i bought your Asset some days ago, i was expecting being able to make appear a spline Road mesh around a sphere world (i want it to appear like travelling the path), but after playing a little with the examples i think won´t be possible... my options would be to make a plane traveling the road, but plane size is not taken into consideration, so it will make appear unintentional sections, using XYZ axis won´t be able to curve with the spline, and also, will make appear roads section ahead of time if there is a curve.. there is any way to make it work with vertex position or something that could work in this case?
     
    Last edited: Apr 28, 2020
  34. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Plane masks has no boundaries. In your case use Box or Sphere masks.



    Amazing Assets - YouTube Facebook Twitter
     
  35. lordzeon

    lordzeon

    Joined:
    Jun 1, 2018
    Posts:
    44
    i've discarded Box and Sphere from the start because i need to gradually scale it, let's say i put a sphere on the start of the road and animate its scale/radius gradually up to the path length, because the road curves in all 3 axis, the sphere could "discover" road sections ahead of the intended length, this could work if the sphere or box "paint" where it passes, leaving it painted after leaving, so the box could be small as the road width, there is something like that implemented?
     
  36. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    I understand what you are trying to achieve - gradient show/hide road path along curved spline.
    Unfortunately it can not be done just by only a shader. You have to somehow make [0, 1] range uv for entire path and have one gradient texture for it or you have to really 'paint' mask value inside texture.
    Or may be Unity line renderer will help more, to create path mesh in runtime.



    Amazing Assets - YouTube Facebook Twitter
     
  37. SpaceRay

    SpaceRay

    Joined:
    Feb 26, 2014
    Posts:
    455
    Hello, I want to buy this asset for making a mobile app

    1 - Please, I want to have simple plain cubes and spheres on the floor and that you can dissolve them just by touching them and that they dissapear with this dissolve effect.
    How would I do it ?
    I have Easy Touch asset and other mobile touch controller if needed.

    2 - Also instead of destroying the object would be possible to simulate the same as it happens in the video when the lights of the ovnis pass over the house and dissolves it, but not destroy the house, I mean that where you touch with your finger would be shown the dissolve effect but only while you touch it and then go back to normal when you do not touch it

    Thanks very much for your help and wish you all the best and that this asset keeps growing and be even more popular each time and more people use it and it keeps being profitable
     
  38. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    1) You can manually control any of the Advanced Dissolve parameters using Unity API: Material.SetFloat() and Material.SetColor(). Very simple code example of dissolve animation on button click:
    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class NewBehaviourScript : MonoBehaviour
    4. {
    5.     public Material dissolveMaterial;     // - - - - - - - -  this is material with Advanced Dissolve shader.
    6.  
    7.     public float dissolveAnimationSpeed = 0.02f;
    8.  
    9.  
    10.     float timer = 0;
    11.     bool isAlive = false;
    12.  
    13.  
    14.     void Update()
    15.    {
    16.       if(isAlive)
    17.       {
    18.          timer += Time.deltaTime * dissolveAnimationSpeed;
    19.  
    20.          dissolveMaterial.SetFloat("_DissolveCutoff", Mathf.Clamp01(timer));    // - - - - - - - - - - Unity default  Material.SetFloat() method
    21.       }
    22.    }
    23.  
    24.     public void OnButtonClick()
    25.     {      
    26.         timer = 0;
    27.         isAlive = true;
    28.     }
    29. }
    30.  

    2) Yes. Advanced Dissolve support dynamic sphere mask. You can control its position in the scene and radius. Simultaneously you can use 4 mask objects.



    Amazing Assets - YouTube Facebook Twitter
     
  39. theloudninja

    theloudninja

    Joined:
    May 14, 2019
    Posts:
    3
    Hi @Arkhivrag. Is there a Baked Lit shader dissolve for URP? Thanks.
     
  40. Dragantium

    Dragantium

    Joined:
    Feb 14, 2015
    Posts:
    34
    It works perfect but I am having trouble animating a text mesh pro. I try to do it through animation but it is impossible.
     
  41. lordzeon

    lordzeon

    Joined:
    Jun 1, 2018
    Posts:
    44
    Sorry for the late reply, i made a shader in amplify shader for it using the Vertex Tex Coord, but well, the disolve effect is not that nice... it could be a good addition in a new version to have that method, like plane, axis, somethig like U/V mapping dissolve
     
  42. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    No. Will include in tomorrow update.


    Bug is in the TextmeshPro source files, not in Advanced Dissolve. Hope Unity will fix it soon.



    Amazing Assets - YouTube Facebook Twitter
     
  43. LookAYeti

    LookAYeti

    Joined:
    Dec 15, 2013
    Posts:
    1
    Loving the asset so far, just ran into something kind of interesting...

    I'm manipulating the color of a dissolving material at runtime, which works perfectly in editor.
    However, when I build to a phone (testing with an iPhone), as soon as I even access
    Code (CSharp):
    1. renderer.material
    the dissolve effect goes away completely. If I use
    Code (CSharp):
    1. renderer.sharedMaterial
    it works (I can manipulate the color and the dissolve effect still works), but I need to be able to change the color on individual objects, so this doesn't really work for me.

    Wondering if you have any ideas why this might be the case?
     
  44. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Does renderer.material has all shader keywords? Try coping them from renderer.sharedMaterial.



    Amazing Assets - YouTube Facebook Twitter
     
  45. theloudninja

    theloudninja

    Joined:
    May 14, 2019
    Posts:
    3
    Thanks for the quick update. Unfortunately I'm not able to get it to work. If I switch my material to use the Lit, Unlit, or Simple Lit they all work with the dissolve. Do you think you could provide a working example and so I have something to test against? I'm using URP 7.21

    Thanks.
     
  46. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    What exactly does not work? At my side I see no problems. Some screenshot for comparison would be very helpful.

    [Edit]
    Just released update for URP. Hope your problem is fixed too.



    Amazing Assets - YouTube Facebook Twitter
     
    Last edited: May 5, 2020
  47. theloudninja

    theloudninja

    Joined:
    May 14, 2019
    Posts:
    3
    The update fixed it. Thanks!!!
     
  48. Melloe

    Melloe

    Joined:
    Feb 22, 2015
    Posts:
    5
    Hi! Thanks for the awesome asset, busy upgrading my project from 2017 to 2019 hdrp. Checking in if I can expect a HDRP version in the next few months or if I should look towards other solutions?

    Cheers!
     
  49. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    "in the next few months" - yes.

    12 of my assets are in queue for URP and HDRP update. Doing my best to finish them as soon as possible.



    Amazing Assets - YouTube Facebook Twitter
     
  50. XANTOMEN

    XANTOMEN

    Joined:
    Dec 18, 2012
    Posts:
    41
    Friendly PSA:

    At risk of being Captain Obvious here, I share this because I feel the problematic setup is probably frequent enough, so maybe it helps someone in the future:

    My problem was:

    I was moving the Sphere that acts as a Mask for my Dissolve around, and I was noticing that the Dissolve was always behind for one frame (in relation to the movement).

    This was producing a visual nuissance, that got linearly worse the faster I'd move such object around, as seen in this video (the glass sphere is my masking object):
    https://xantomen-mail.tinytake.com/tt/NDMxNDY4NF8xMzU3NzM0Mw

    The problem wouldn't manifest if the object is moved on the Editor with the gizmos, which indicated it was related to script execution order.

    My solution was:

    I added the Controller_Mask_Sphere to Project Settings/Script Execution Order to be after Default Time (where every non-listed script executes), or for more certainty, I could add the MoveObject script as well and position it higher. The problem was simply that MoveObject's Update happened to trigger after the Mask_Sphere, when it has to be the other way around (so the Mask will fetch the updated position).

    Without thinking about it a lot, and so maybe I'm very wrong, I think maybe this should be the default execution order of the Mask scripts when importing the asset, as they fetch position from the objects, so anything that alters these object's positions should happen before. And so, having them after Default Time seems like a safe bet that it'll produce more accurate results more often. Am I off here, Davit?

    Cheers!
     
    Arkhivrag likes this.