Search Unity

► Advanced Dissolve ◄

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

  1. ks1993

    ks1993

    Joined:
    Mar 13, 2016
    Posts:
    4
    Hi,
    i want to buy this asset but i have one question does it work wih HoloLens (UWP platform) ?

    thank you
     
  2. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,140
    Have no HoloLens to test.



    VacuumShaders - Facebook Twitter YouTube
     
  3. dajyareo

    dajyareo

    Joined:
    Dec 7, 2014
    Posts:
    7
    Just picked up this shader a few days ago and am loving it. Having difficulties with the Unity Nature integration though... I've got a tree prefab that is using your dissolve Bark/Leaf optimized shaders, and I'm able to see it properly dissolving when I place that in a scene; however, if I place the tree by adding it to the terrain and painting it on, the shader stops working. See below (left is me placing the prefab on directly and right is placed via terrain tree brush, same prefab)

    upload_2019-2-2_12-7-39.png

    What steps am I missing to make this work? I'm on Unity 2018.3. Thanks again!
     
    Last edited: Feb 2, 2019
  4. zh4r0naX

    zh4r0naX

    Joined:
    Oct 30, 2016
    Posts:
    24
    Hello, is there a feature to use this kind of effect pixel perfect ? For a pixel art game for example ?

    Also i would need to know which effects exactly need the post processing.

    Thank you
     
  5. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,140
    Terrain does not use material from prefab (shader yes, but not material).
    Set Global Controller to Mask Only inside material editor of the prefab and update mask parameters globally, if using included Mask_Controller scripts just check Update Global option there.

    ad.gif


    VacuumShaders - Facebook Twitter YouTube
     
  6. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,140
    Is not pixel perfect effect some kind of Unity custom camera script? How this shader can be related to it?
    Advanced Dissolve's cutout effect does not need post processing.



    VacuumShaders - Facebook Twitter YouTube
     
  7. dajyareo

    dajyareo

    Joined:
    Dec 7, 2014
    Posts:
    7
    Worked great, thanks for the quick response!
     
  8. ReniTheGhost

    ReniTheGhost

    Joined:
    Dec 8, 2014
    Posts:
    13
    Hello, how can i change the render mode at run time from opaque to fade, fade to opaque ?
     
  9. zh4r0naX

    zh4r0naX

    Joined:
    Oct 30, 2016
    Posts:
    24
    With pixel perfect i mean dissolve in a pixelated way, i want my sprites like 32x32 pixels to dissolve in a pixelated way. Is this possible ?

    Of course i do have a pixel perfect camera and the game is drawn in pixel art, and thats why so smooth effects dont fit.

    So is it possible to dissolve on a pixel basis ?
     
  10. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,140
    Enable or disable shader keywords and change blending mode parameters.

    Code (CSharp):
    1.     public static void SetupMaterialWithBlendMode(Material material, BlendMode blendMode)
    2.     {
    3.         switch (blendMode)
    4.         {
    5.             case BlendMode.Opaque:
    6.                 material.SetOverrideTag("RenderType", "AdvancedDissolveCutout");
    7.                 material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
    8.                 material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
    9.                 material.SetInt("_ZWrite", 1);
    10.                 material.DisableKeyword("_ALPHATEST_ON");
    11.                 material.DisableKeyword("_ALPHABLEND_ON");
    12.                 material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
    13.                 material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.Geometry;
    14.  
    15.                 if (material.shader.name.Contains("Standard"))
    16.                     material.SetFloat("_Cutoff", 0);
    17.  
    18.                 break;
    19.  
    20.             case BlendMode.Cutout:
    21.                 material.SetOverrideTag("RenderType", "AdvancedDissolveCutout");
    22.                 material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
    23.                 material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
    24.                 material.SetInt("_ZWrite", 1);
    25.                 material.EnableKeyword("_ALPHATEST_ON");
    26.                 material.DisableKeyword("_ALPHABLEND_ON");
    27.                 material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
    28.                 material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.AlphaTest;
    29.                 break;
    30.  
    31.             case BlendMode.Fade:
    32.             case BlendMode.Transparent:
    33.                 material.SetOverrideTag("RenderType", "Transparent");
    34.                 material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
    35.                 material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
    36.                 material.SetInt("_ZWrite", 0);
    37.                 material.DisableKeyword("_ALPHATEST_ON");
    38.                 material.EnableKeyword("_ALPHABLEND_ON");
    39.                 material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
    40.                 material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.Transparent;
    41.                 break;
    42.         }
    43.     }
    44.  
    Make sure to include all shader variants into the build.
    Read more info about shader variants is here.



    VacuumShaders - Facebook Twitter YouTube
     
  11. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,140
    Alpha value used to dissolve pixel is read from texture, you can just try use already pixelated texture, something like this:
    D_9.jpg



    VacuumShaders - Facebook Twitter YouTube
     
  12. ReniTheGhost

    ReniTheGhost

    Joined:
    Dec 8, 2014
    Posts:
    13

    Thank you, working!

    I have a feature idea.
    I'm using your extension to create a clocking effect which looks great but It should be awesome if you can add heat distortion effect option. :)
     
  13. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,140
    Can you share some images or video of the "distortion effect".



    VacuumShaders - Facebook Twitter YouTube
     
  14. ReniTheGhost

    ReniTheGhost

    Joined:
    Dec 8, 2014
    Posts:
    13
    unity example:



    what i try to achieve:


    The image show my current clocking effect. So i want to combine my current effect with some distortion :)
     

    Attached Files:

    • 0.png
      0.png
      File size:
      2.1 MB
      Views:
      152
  15. MakkMarci

    MakkMarci

    Joined:
    Feb 24, 2015
    Posts:
    3
    Hello,

    Is HDRP still not planned?
     
  16. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,140
    HDRP still is very unstable.



    VacuumShaders - Facebook Twitter YouTube
     
  17. astromedia-only

    astromedia-only

    Joined:
    May 13, 2014
    Posts:
    11
    Hi,
    this seems like great utility shader and solution to my problem of cuting objects going through the portal :) ... my concern is if its simple enough and easy to make compatible with other shaders but that will be probably fine ... sadly i work with HRDP too ... so my question is - you have on page "Note, SRP shaders will be released separately (removed from this package) after LWRP leaves preview mode." so i suppose it is true also for HDRP if it ever makes it out so if i need HDRP i should wait and buy that specific shader package after/if it comes out and not the current one?

    This render pipeline stuff is great improvement but now during that "half way out" period it makes huge mess in process of finding right assets for my project :D :/
     
  18. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,140
    Advanced Dissolve can be integrated in custom shaders, but it is completely up to you.
    Asset version for SRP will be released separately and will include shaders for LWRP and HDRP. Can not say when it will happen.



    VacuumShaders - Facebook Twitter YouTube
     
    astromedia-only likes this.
  19. bohdon

    bohdon

    Joined:
    Dec 3, 2013
    Posts:
    1
    Hi, great package!

    I'm having issues with changing certain shader keywords at runtime. I'm currently unable to get changes in mask count (and i believe also mask type e.g. from none, to cone or sphere, and vice versa) to work in a standalone build. Here are the steps I'm using to recreate in a fresh project:

    - Unity 2018.3.6f1
    - New Unity Project
    - Import Advanced Dissolve
    - Set "7. Mask (Cone)" as the first scene in Build Settings (i've also tested the sphere demo scene)
    - Build for Windows x86_64

    In the built game, changing the "Count" property does not cause the other spotlights / cone masks to appear (as it should, and does in the editor).

    Are there any project settings or limitations that I'm missing? I tried messing with shader variant stripping with no success.

    Thanks!
     
  20. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,140
    Unity does not include shader keywords into the final build if they are not used in editor.
    Just create additional materials with desired shader keywords and include them in build.



    VacuumShaders - Facebook Twitter YouTube
     
  21. EstudioVR

    EstudioVR

    Joined:
    Jul 26, 2013
    Posts:
    61
    Is it VR compatible?
     
  22. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,140
  23. haggai1

    haggai1

    Joined:
    Mar 27, 2019
    Posts:
    1
    Hi, are the Fade and Transparency rendering options currently available? Can we possibly achieve a a wide transparency transition on the edges of the "hole"? For example. say I have a round 9 cm diameter hole, so it is fully transparent at the circumference. Could I gradually reduce the transparency until at 12 cm diameter it is fully opaque?
     
  24. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,140
    Fade and Transparency are supported by included Standard shades.
    All other shaders support simple (traditional) Transparency.



    VacuumShaders - Facebook Twitter YouTube
     
  25. matt33315

    matt33315

    Joined:
    Mar 28, 2014
    Posts:
    85
    Looking at this asset for my next project. I especially like the screenshot where the lasers are dissolving parts of the house. Is there any way to effect the collision detection of the building at the same time so the holes wouldn't just be for display purposes but let other objects pass though them?
     
  26. Anoki

    Anoki

    Joined:
    Jul 11, 2013
    Posts:
    6
    Hi, I want to animate the Dissolve slider, can you make a script to animate the float from 0 to 1 over a period of time, example: 3 seconds to disappear or to reappear. I am not a coder and its very hard for me.
    How would you do this?
     
  27. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,140
    Unfortunately shaders can not interact with Physics. Those are two completely different parts of the engine.



    VacuumShaders - Facebook Twitter YouTube
     
    Last edited: Apr 2, 2019
  28. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,140
    Example #1 (for manual dissolve control)
    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class Cutout : MonoBehaviour
    4. {
    5.     [Range(0f, 1f)]
    6.     public float cutoutValue;
    7.  
    8.     Material material;
    9.  
    10.     // Start is called before the first frame update
    11.     void Start()
    12.     {
    13.         material = GetComponent<Renderer>().sharedMaterial;
    14.     }
    15.  
    16.     // Update is called once per frame
    17.     void Update()
    18.     {
    19.         material.SetFloat("_DissolveCutoff", cutoutValue);
    20.     }
    21. }


    Example #2 (animation dissolve on key down)
    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class AnimCutout : MonoBehaviour
    4. {
    5.     public float cutoutAnimLength = 3;
    6.     float cutoutValue;
    7.  
    8.     bool animate;
    9.  
    10.     Material material;
    11.  
    12.     // Start is called before the first frame update
    13.     void Start()
    14.     {
    15.         material = GetComponent<Renderer>().sharedMaterial;
    16.  
    17.         cutoutValue = 0;
    18.  
    19.         animate = false;
    20.     }
    21.  
    22.     // Update is called once per frame
    23.     void Update()
    24.     {
    25.         if(Input.GetKeyDown(KeyCode.Space))
    26.         {
    27.             animate = true;        
    28.         }
    29.  
    30.         if(animate)
    31.         {
    32.             cutoutValue += Time.deltaTime / cutoutAnimLength;
    33.  
    34.             cutoutValue = Mathf.Clamp01(cutoutValue);
    35.         }
    36.  
    37.  
    38.         material.SetFloat("_DissolveCutoff", cutoutValue);
    39.     }
    40. }


    VacuumShaders - Facebook Twitter YouTube
     
  29. Anoki

    Anoki

    Joined:
    Jul 11, 2013
    Posts:
    6
    Thank you
     
  30. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    378
    Hello, I'm not sure if it was already asked (searching didn't give any result): Is there a plan to port the dissolve shader to use with UI? I don't mean Text Mesh pro which works fine, but to replace the UI shader and apply the dissolve effect for example to a UI element (image or else)
    I'm totally not able to code such thing, so maybe it's on the roadmap or already done

    thank you
     
  31. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,140
    Currently not planed. Added to a wish-list.



    VacuumShaders - Facebook Twitter YouTube
     
  32. imagedrealityjake

    imagedrealityjake

    Joined:
    May 8, 2018
    Posts:
    16
    Hi,

    I'm trying to update my scene's Standard Shader materials via script when the scene starts but doesn't look to be working. The Materials update to the Dissolve Shader effect but when I update my Y Offset, only materials that were set to the Advance Dissolve shader before Playing the scene work. I've read through this forum and I'm pretty sure I've enabled/disabled all the keywords I was meant to but perhaps I missed something? Here is my code:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class DissolveTestMemoryFlash : MonoBehaviour {
    6.  
    7.     public Material MaterialToCopy;
    8.  
    9.     public Color EdgeColor = new Color(1,1,1,0.5f);
    10.     public Texture2D DissolveMap1;
    11.     public Texture2D DissolveMap2;
    12.  
    13.     private Renderer[] renderers;
    14.  
    15.     public float yOffset;
    16.  
    17.     // Use this for initialization
    18.     void Start () {
    19.  
    20.         renderers = gameObject.GetComponentsInChildren<Renderer>();
    21.         for(int i = 0; i < renderers.Length; i++)
    22.         {
    23.             ProcessMaterial(renderers[i].material);
    24.         }
    25.     }
    26.  
    27.     private void Update()
    28.     {
    29.         for(int i = 0; i < renderers.Length; i++)
    30.         {
    31.             renderers[i].material.SetFloat("_DissolveMaskOffset", yOffset);
    32.         }
    33.     }
    34.  
    35.     void ProcessMaterial(Material mat)
    36.     {
    37.         mat.shader = Shader.Find("Hidden/VacuumShaders/Advanced Dissolve/Standard/Metallic_SM4");
    38.      
    39.         // Mask
    40.         mat.SetFloat("_DissolveMask", 1);
    41.         mat.SetFloat("_DissolveMaskAxis", 1);
    42.  
    43.         // Cutout
    44.         mat.SetFloat("_DissolveAlphaSource", 2);
    45.         mat.SetFloat("_DissolveNoiseStrength", 1);
    46.         mat.SetTexture("_DissolveMap1", DissolveMap1);
    47.         mat.SetTexture("_DissolveMap2", DissolveMap2);
    48.  
    49.         // Edge
    50.         mat.SetFloat("_DissolveEdgeWidth", 0.04f);
    51.         mat.SetColor("_DissolveEdgeColor", EdgeColor);
    52.         mat.SetFloat("_DissolveEdgeColorIntensity", 1);
    53.      
    54.         // Keywords
    55.         mat.DisableKeyword("_DISSOLVEMASK_NONE");
    56.         mat.DisableKeyword("_DISSOLVEMASK_AXIS_LOCAL");
    57.         mat.EnableKeyword("_DISSOLVEMASK_AXIS_GLOBAL");
    58.         mat.DisableKeyword("_DISSOLVEMASK_PLANE");
    59.         mat.DisableKeyword("_DISSOLVEMASK_SPHERE");
    60.         mat.DisableKeyword("_DISSOLVEMASK_BOX");
    61.  
    62.         mat.DisableKeyword("_DISSOLVEALPHASOURCE_MAIN_MAP_ALPHA");
    63.         mat.DisableKeyword("_DISSOLVEALPHASOURCE_CUSTOM_MAP");
    64.         mat.EnableKeyword("_DISSOLVEALPHASOURCE_TWO_CUSTOM_MAPS");
    65.         mat.DisableKeyword("_DISSOLVEALPHASOURCE_THREE_CUSTOM_MAPS");
    66.  
    67.         mat.EnableKeyword("_DISSOLVEGLOBALCONTROL_NONE");
    68.         mat.DisableKeyword("_DISSOLVEGLOBALCONTROL_MASK_ONLY");
    69.         mat.DisableKeyword("_DISSOLVEGLOBALCONTROL_MASK_AND_EDGE");
    70.         mat.DisableKeyword("_DISSOLVEGLOBALCONTROL_ALL");
    71.  
    72.         mat.DisableKeyword("_DISSOLVEMAPPINGTYPE_TRIPLANAR");
    73.         mat.DisableKeyword("_DISSOLVEMAPPINGTYPE_SCREEN_SPACE");
    74.         mat.DisableKeyword("_MAINTEXCUTOFF_ON");
    75.  
    76.         SetupMaterialWithBlendMode(mat, MaterialExtensions.GetRenderMode(mat));
    77.  
    78.     }
    79.  
    80.     public static void SetupMaterialWithBlendMode(Material material, MaterialExtensions.BlendMode blendMode)
    81.     {
    82.         switch (blendMode)
    83.         {
    84.             case MaterialExtensions.BlendMode.Opaque:
    85.                 material.SetOverrideTag("RenderType", "AdvancedDissolveCutout");
    86.                 material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
    87.                 material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
    88.                 material.SetInt("_ZWrite", 1);
    89.                 material.DisableKeyword("_ALPHATEST_ON");
    90.                 material.DisableKeyword("_ALPHABLEND_ON");
    91.                 material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
    92.                 material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.Geometry;
    93.  
    94.                 if (material.shader.name.Contains("Standard"))
    95.                     material.SetFloat("_Cutoff", 0);
    96.  
    97.                 break;
    98.  
    99.             case MaterialExtensions.BlendMode.Cutout:
    100.                 material.SetOverrideTag("RenderType", "AdvancedDissolveCutout");
    101.                 material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
    102.                 material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
    103.                 material.SetInt("_ZWrite", 1);
    104.                 material.EnableKeyword("_ALPHATEST_ON");
    105.                 material.DisableKeyword("_ALPHABLEND_ON");
    106.                 material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
    107.                 material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.AlphaTest;
    108.                 break;
    109.  
    110.             case MaterialExtensions.BlendMode.Fade:
    111.             case MaterialExtensions.BlendMode.Transparent:
    112.                 material.SetOverrideTag("RenderType", "Transparent");
    113.                 material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
    114.                 material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
    115.                 material.SetInt("_ZWrite", 0);
    116.                 material.DisableKeyword("_ALPHATEST_ON");
    117.                 material.EnableKeyword("_ALPHABLEND_ON");
    118.                 material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
    119.                 material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.Transparent;
    120.                 break;
    121.         }
    122.     }
    123. }
    124.  
    Hope you can help me out? Thanks!
     
    Last edited: Apr 8, 2019
  33. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,140
    Hope this helps:
    Code (CSharp):
    1.         //Mask///////////////////////////////////////////////////////////////////////////
    2.         mat.DisableKeyword("_DISSOLVEMASK_XYZ_AXIS");
    3.         mat.DisableKeyword("_DISSOLVEMASK_PLANE");
    4.         mat.DisableKeyword("_DISSOLVEMASK_SPHERE");
    5.         mat.DisableKeyword("_DISSOLVEMASK_BOX");
    6.         mat.DisableKeyword("_DISSOLVEMASK_CYLINDER");
    7.         mat.DisableKeyword("_DISSOLVEMASK_CONE");
    8.  
    9.         mat.EnableKeyword("_DISSOLVEMASK_XYZ_AXIS");    //<- enable required keyword
    10.  
    11.  
    12.  
    13.         //Mask count/////////////////////////////////////////////////////////////////////
    14.         mat.DisableKeyword("_DISSOLVEMASKCOUNT_TWO");
    15.         mat.DisableKeyword("_DISSOLVEMASKCOUNT_THREE");
    16.         mat.DisableKeyword("_DISSOLVEMASKCOUNT_FOUR");
    17.  
    18.  
    19.  
    20.         //Alpha Cutout Source////////////////////////////////////////////////////////////
    21.         mat.DisableKeyword("_DISSOLVEALPHASOURCE_CUSTOM_MAP");
    22.         mat.DisableKeyword("_DISSOLVEALPHASOURCE_TWO_CUSTOM_MAPS");
    23.         mat.DisableKeyword("_DISSOLVEALPHASOURCE_THREE_CUSTOM_MAPS");
    24.  
    25.         mat.EnableKeyword("_DISSOLVEALPHASOURCE_TWO_CUSTOM_MAPS");  //<- enable required keyword
    26.  
    27.  
    28.  
    29.         //Alpha Cutout Source texture mapping type///////////////////////////////////////
    30.         mat.DisableKeyword("_DISSOLVEMAPPINGTYPE_TRIPLANAR");
    31.         mat.DisableKeyword("_DISSOLVEMAPPINGTYPE_SCREEN_SPACE");
    32.  
    33.  
    34.  
    35.         //Edge Texture Source////////////////////////////////////////////////////////////
    36.         mat.DisableKeyword("_DISSOLVEEDGETEXTURESOURCE_GRADIENT");
    37.         mat.DisableKeyword("_DISSOLVEEDGETEXTURESOURCE_MAIN_MAP");
    38.         mat.DisableKeyword("_DISSOLVEEDGETEXTURESOURCE_CUSTOM");
    39.  
    40.  
    41.  
    42.         //Global Control/////////////////////////////////////////////////////////////////
    43.         mat.DisableKeyword("_DISSOLVEGLOBALCONTROL_MASK_ONLY");
    44.         mat.DisableKeyword("_DISSOLVEGLOBALCONTROL_MASK_AND_EDGE");
    45.         mat.DisableKeyword("_DISSOLVEGLOBALCONTROL_ALL");


    VacuumShaders - Facebook Twitter YouTube
     
  34. imagedrealityjake

    imagedrealityjake

    Joined:
    May 8, 2018
    Posts:
    16
    @Arkhivrag Thank you for the help, yes that has done the trick!

    However, I'm not seeing the effect work in a build? In the editor everything works as expected, but when I animate the YOffset in build there doesn't look to be any change in the dissolve. Any reason why this would happen?

    Thanks, Jake
     
  35. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,140
    Shader keywords used in editor are included into build, all other variants are excluded.
    You have to include them manually, but creating shader variants collection or just create material asset with required keywords and include it into a build.



    VacuumShaders - Facebook Twitter YouTube
     
  36. imagedrealityjake

    imagedrealityjake

    Joined:
    May 8, 2018
    Posts:
    16
  37. Fishing_Cactus

    Fishing_Cactus

    Joined:
    Nov 8, 2014
    Posts:
    11
    Hi, can you help me to achieve this kind of specific double shader? I have Cull off, and I want a different albedo texture for 'inner face'. Or is there a way to plug an Amplify Shader shader, instead of Standard unity shader? thanks in advance for your time
     
  38. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,140
    Effect you are asking for can be achived, but I can not re-write shaders for that specific effect.
    You may try it yourself, search for VFACE semantic and how to use it with shaders.

    As for Amplify Shader integration, check AdvancedDissolve.cginc file. Re-writing all that math using nodes? No, thanks.



    VacuumShaders - Facebook Twitter YouTube
     
  39. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,140
    Just for example:
    Below is copy of Unlit dissolve shader using VFACE semantic.

    Only changes is on line 189,
    Code (CSharp):
    1. fixed4 frag(v2f i, fixed facing : VFACE) : SV_Target
    line 205
    Code (CSharp):
    1. float faceDirection = facing < 0 ? 1 : 0;
    check how faceDirection variable is used to deside render MainTex or Color.


    Code (CSharp):
    1.  
    2. Shader "VacuumShaders/Advanced Dissolve/Unlit"
    3. {
    4.     Properties
    5.     {
    6.         _Color("Main Color", Color) = (1,1,1,1)
    7.         _MainTex("Base (RGB) Trans (A)", 2D) = "white" { }
    8.  
    9.         [Cutout]_Cutoff("   Alpha Cutoff", Range(0,1)) = 0.5
    10.         [NoScaleOffset]_OcclusionMap("Occlusion", 2D) = "white" {}
    11.  
    12.  
    13.         // Blending state
    14.         [HideInInspector] _Mode("__mode", Float) = 0.0
    15.         [HideInInspector] _SrcBlend("__src", Float) = 1.0
    16.         [HideInInspector] _DstBlend("__dst", Float) = 0.0
    17.         [HideInInspector] _ZWrite("__zw", Float) = 1.0
    18.  
    19.  
    20.         [HideInInspector][MaterialEnum(Off,0,Front,1,Back,2)] _Cull("Face Cull", Int) = 0
    21.  
    22.  
    23.         //Advanced Dissolve
    24.         [HideInInspector] _DissolveCutoff("Dissolve", Range(0,1)) = 0.25
    25.  
    26.         //Mask
    27.         [HideInInspector][KeywordEnum(None, XYZ Axis, Plane, Sphere, Box, Cylinder, Cone)]  _DissolveMask("Mak", Float) = 0
    28.         [HideInInspector][Enum(X,0,Y,1,Z,2)]                                                _DissolveMaskAxis("Axis", Float) = 0
    29.         [HideInInspector][Enum(World,0,Local,1)]                                            _DissolveMaskSpace("Space", Float) = 0
    30.         [HideInInspector]                                                                   _DissolveMaskOffset("Offset", Float) = 0
    31.         [HideInInspector]                                                                   _DissolveMaskInvert("Invert", Float) = 1  
    32.         [HideInInspector][KeywordEnum(One, Two, Three, Four)]                               _DissolveMaskCount("Count", Float) = 0  
    33.  
    34.         [HideInInspector]  _DissolveMaskPosition("", Vector) = (0,0,0,0)
    35.         [HideInInspector]  _DissolveMaskNormal("", Vector) = (1,0,0,0)
    36.         [HideInInspector]  _DissolveMaskRadius("", Float) = 1
    37.  
    38.         //Alpha Source
    39.         [HideInInspector][KeywordEnum(Main Map Alpha, Custom Map, Two Custom Maps, Three Custom Maps)]  _DissolveAlphaSource("Alpha Source", Float) = 0
    40.         [HideInInspector]_DissolveMap1("", 2D) = "white" { }
    41.         [HideInInspector][UVScroll]  _DissolveMap1_Scroll("", Vector) = (0,0,0,0)
    42.         [HideInInspector]_DissolveMap2("", 2D) = "white" { }
    43.         [HideInInspector][UVScroll]  _DissolveMap2_Scroll("", Vector) = (0,0,0,0)
    44.         [HideInInspector]_DissolveMap3("", 2D) = "white" { }
    45.         [HideInInspector][UVScroll]  _DissolveMap3_Scroll("", Vector) = (0,0,0,0)
    46.  
    47.         [HideInInspector][Enum(Multiply, 0, Add, 1)]  _DissolveSourceAlphaTexturesBlend("Texture Blend", Float) = 0
    48.         [HideInInspector]                              _DissolveNoiseStrength("Noise", Float) = 0.1
    49.         [HideInInspector][Enum(UV0,0,UV1,1)]          _DissolveAlphaSourceTexturesUVSet("UV Set", Float) = 0
    50.  
    51.         [HideInInspector][KeywordEnum(Normal, Triplanar, Screen Space)] _DissolveMappingType("Triplanar", Float) = 0
    52.         [HideInInspector][Enum(World,0,Local,1)]                        _DissolveTriplanarMappingSpace("Mapping", Float) = 0
    53.         [HideInInspector]                                               _DissolveMainMapTiling("", FLOAT) = 1
    54.  
    55.         //Edge
    56.         [HideInInspector]                                       _DissolveEdgeWidth("Edge Size", Range(0,1)) = 0.25
    57.         [HideInInspector][Enum(Cutout Source,0,Main Map,1)]     _DissolveEdgeDistortionSource("Distortion Source", Float) = 0
    58.         [HideInInspector]                                       _DissolveEdgeDistortionStrength("Distortion Strength", Range(0, 2)) = 0
    59.  
    60.         //Color
    61.         [HideInInspector]                _DissolveEdgeColor("Edge Color", Color) = (0,1,0,1)
    62.         [HideInInspector][PositiveFloat] _DissolveEdgeColorIntensity("Intensity", FLOAT) = 0
    63.         [HideInInspector][Enum(Solid,0,Smooth,1, Smooth Squared,2)]      _DissolveEdgeShape("Shape", INT) = 0
    64.  
    65.  
    66.         [HideInInspector][KeywordEnum(None, Gradient, Main Map, Custom)] _DissolveEdgeTextureSource("", Float) = 0
    67.         [HideInInspector][NoScaleOffset]                                 _DissolveEdgeTexture("Edge Texture", 2D) = "white" { }
    68.         [HideInInspector][Toggle]                                         _DissolveEdgeTextureReverse("Reverse", FLOAT) = 0
    69.         [HideInInspector]                                                 _DissolveEdgeTexturePhaseOffset("Offset", FLOAT) = 0
    70.         [HideInInspector]                                                 _DissolveEdgeTextureAlphaOffset("Offset", Range(-1, 1)) = 0
    71.         [HideInInspector]                                                 _DissolveEdgeTextureMipmap("", Range(0, 10)) = 1  
    72.         [HideInInspector][Toggle]                                         _DissolveEdgeTextureIsDynamic("", Float) = 0
    73.  
    74.         [HideInInspector][PositiveFloat] _DissolveGIMultiplier("GI Strength", Float) = 1
    75.  
    76.         //Global
    77.         [HideInInspector][KeywordEnum(None, Mask Only, Mask And Edge, All)] _DissolveGlobalControl("Global Controll", Float) = 0
    78.  
    79.         //Meta
    80.         [HideInInspector] _Dissolve_ObjectWorldPos("", Vector) = (0,0,0,0)  
    81.     }
    82.        
    83.     //SM 3.0
    84.     SubShader
    85.     {
    86.         Tags { "RenderType" = "AdvancedDissolveCutout" "DisableBatching" = "True" }
    87.         LOD 100
    88.  
    89.         Cull[_Cull]
    90.  
    91.         Pass
    92.         {
    93.  
    94.             Blend[_SrcBlend][_DstBlend]
    95.             ZWrite[_ZWrite]
    96.  
    97.  
    98.             CGPROGRAM
    99.             #pragma vertex vert
    100.             #pragma fragment frag
    101.             #pragma multi_compile_fog
    102.             #pragma target 3.0
    103.             #include "UnityCG.cginc"
    104.  
    105.  
    106.             sampler2D _MainTex;
    107.             float4 _MainTex_ST;
    108.             sampler2D _OcclusionMap;
    109.             fixed4 _Color;
    110.             fixed _Cutoff;
    111.  
    112.  
    113. #pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON
    114.  
    115. #pragma shader_feature _ _DISSOLVEGLOBALCONTROL_MASK_ONLY _DISSOLVEGLOBALCONTROL_MASK_AND_EDGE _DISSOLVEGLOBALCONTROL_ALL
    116. #pragma shader_feature _ _DISSOLVEMAPPINGTYPE_TRIPLANAR _DISSOLVEMAPPINGTYPE_SCREEN_SPACE
    117. #pragma shader_feature _ _DISSOLVEALPHASOURCE_CUSTOM_MAP _DISSOLVEALPHASOURCE_TWO_CUSTOM_MAPS _DISSOLVEALPHASOURCE_THREE_CUSTOM_MAPS
    118. #pragma shader_feature _ _DISSOLVEMASK_XYZ_AXIS _DISSOLVEMASK_PLANE _DISSOLVEMASK_SPHERE _DISSOLVEMASK_BOX _DISSOLVEMASK_CYLINDER _DISSOLVEMASK_CONE
    119. #pragma shader_feature _ _DISSOLVEEDGETEXTURESOURCE_GRADIENT _DISSOLVEEDGETEXTURESOURCE_MAIN_MAP _DISSOLVEEDGETEXTURESOURCE_CUSTOM
    120. #pragma shader_feature _ _DISSOLVEMASKCOUNT_TWO _DISSOLVEMASKCOUNT_THREE _DISSOLVEMASKCOUNT_FOUR
    121.  
    122.  
    123.  
    124. #include "../cginc/AdvancedDissolve.cginc"
    125. #include "../cginc/Integration_CurvedWorld.cginc"
    126.        
    127.      
    128.             struct appdata_t
    129.             {
    130.                 float4 vertex : POSITION;
    131.                 float2 uv0 : TEXCOORD0;
    132.                 float2 uv1 : TEXCOORD1;
    133.            
    134. #ifdef _DISSOLVEMAPPINGTYPE_TRIPLANAR
    135.                 float3 normal : NORMAL;
    136. #endif
    137.            
    138.                 UNITY_VERTEX_INPUT_INSTANCE_ID
    139.             };
    140.  
    141.             struct v2f
    142.             {
    143.                 float4 vertex : SV_POSITION;
    144.                 float2 uv0 : TEXCOORD0;
    145.                 UNITY_FOG_COORDS(1)
    146.  
    147.                 float3 worldPos : TEXCOORD2;
    148.  
    149. #ifdef _DISSOLVEMAPPINGTYPE_TRIPLANAR
    150.                 half3 objNormal : TEXCOORD3;
    151.                 float3 coords : TEXCOORD4;
    152. #else
    153.                 float4 dissolveUV : TEXCOORD3;
    154. #endif      
    155.  
    156.                 UNITY_VERTEX_OUTPUT_STEREO
    157.             };
    158.        
    159.        
    160.        
    161.             v2f vert(appdata_t v)
    162.             {
    163.                 v2f o;
    164.                 UNITY_SETUP_INSTANCE_ID(v);
    165.                 UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
    166.  
    167.  
    168.                 CURVED_WORLD_TRANSFORM_POINT(v. vertex)
    169.  
    170.  
    171.                 o.vertex = UnityObjectToClipPos(v.vertex);
    172.                 o.uv0.xy = TRANSFORM_TEX(v.uv0, _MainTex);
    173.                 UNITY_TRANSFER_FOG(o,o.vertex);
    174.  
    175.  
    176.                 //VacuumShaders
    177.                 o.worldPos = mul(unity_ObjectToWorld, float4(v.vertex.xyz, 1)).xyz;
    178. #ifdef _DISSOLVEMAPPINGTYPE_TRIPLANAR
    179.                 o.coords = float4(v.vertex.xyz, 1);
    180.                 o.objNormal = lerp(UnityObjectToWorldNormal(v.normal), v.normal, VALUE_TRIPLANARMAPPINGSPACE);
    181. #else
    182.                 DissolveVertex2Fragment(o.vertex, v.uv0, v.uv1, o.dissolveUV);
    183. #endif
    184.            
    185.            
    186.                 return o;
    187.             }
    188.  
    189.             fixed4 frag(v2f i, fixed facing : VFACE) : SV_Target
    190.             {
    191.                 //VacuumShaders
    192. #ifdef _DISSOLVEMAPPINGTYPE_TRIPLANAR
    193.                 float4 alpha = ReadDissolveAlpha_Triplanar(i.coords, i.objNormal, i.worldPos);
    194. #else
    195.                 float4 alpha = ReadDissolveAlpha(i.uv0.xy, i.dissolveUV, i.worldPos);
    196. #endif          
    197.                 DoDissolveClip(alpha);
    198.  
    199.  
    200.                 float3 dissolveAlbedo = 0;
    201. float3 dissolveEmission = 0;
    202.                 float dissolveBlend = DoDissolveAlbedoEmission(alpha, dissolveAlbedo, dissolveEmission, i.uv0);
    203.  
    204.          
    205.                 float faceDirection = facing < 0 ? 1 : 0;
    206.          
    207.                 fixed4 col = lerp(tex2D(_MainTex, i.uv0), _Color, faceDirection);
    208.  
    209.                 float alphaFromSurface = col.a;
    210. #ifdef _ALPHATEST_ON
    211.                 clip(alphaFromSurface - _Cutoff);
    212. #endif
    213.  
    214.                 //Albedo
    215.                 col.rgb = lerp(col.rgb, dissolveAlbedo, dissolveBlend);
    216.          
    217.  
    218.                 col.rgb *= tex2D(_OcclusionMap, i.uv0).rgb;
    219.  
    220.  
    221.                 //Emission
    222.                 col.rgb += dissolveEmission * dissolveBlend;
    223.  
    224.  
    225.                 UNITY_APPLY_FOG(i.fogCoord, col);
    226.          
    227.                 return DoOutputForward(col, alphaFromSurface);
    228.             }
    229.             ENDCG
    230.         }
    231.     }
    232.  
    233.  
    234.  
    235.  
    236.  
    237.     CustomEditor "AdvancedDissolveGUI"
    238. }
    239.  


    VacuumShaders - Facebook Twitter YouTube
     
  40. Fishing_Cactus

    Fishing_Cactus

    Joined:
    Nov 8, 2014
    Posts:
    11
    Thanks a lot for your reply, I'll try that.
     
  41. Loderm14

    Loderm14

    Joined:
    Feb 10, 2019
    Posts:
    1
    I am having an issue with the Lightweight pipeline shaders not working with the advanced dissolve. It doesnt convert the shaders over to LWRP materials. they appear as pink textures. any help is appreciated.
     
  42. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,140
    LWRP shaders for Unity 2019 are in development.



    VacuumShaders - Facebook Twitter YouTube
     
    ibyte likes this.
  43. galinhoo

    galinhoo

    Joined:
    Feb 13, 2016
    Posts:
    1
    I am building an application for mobile that puts RA (Vuforia) over a jigsaw puzzle and puts holes where the puzzle is not correct. To make the visual effects I use 1 to 4 boxes working as masks (1 for the animation, 3 for the holes).

    As I was having problems with fps I found out that using more than 1 box reduces the performance considerably, also when used on a simple quad or plane it would affect the performance way more than the animated model.

    So I made it change on the fly how many boxes were being used for the minimum possible. It works perfectly on editor, but when i run it on android the amount of boxes used on the mask don't work, If i start with 1, it ignores if I try to change to 2.

    I tried changing the mask globally, per material and per instanced material, all without success. Is there a correct way to work with changing this value on demand with mobile?

    The code I use to change the value is based on the example

    Code (CSharp):
    1. mesh.sharedMaterials[0].DisableKeyword("_DISSOLVEMASKCOUNT_FOUR");
    2.             mesh.sharedMaterials[0].DisableKeyword("_DISSOLVEMASKCOUNT_THREE");
    3.             mesh.sharedMaterials[0].DisableKeyword("_DISSOLVEMASKCOUNT_TWO");
    4.  
    5.             switch (count) {
    6.                 case 1: break;
    7.                 case 2: mesh.sharedMaterials[0].EnableKeyword("_DISSOLVEMASKCOUNT_TWO"); break;
    8.                 case 3: mesh.sharedMaterials[0].EnableKeyword("_DISSOLVEMASKCOUNT_THREE"); break;
    9.                 case 4: mesh.sharedMaterials[0].EnableKeyword("_DISSOLVEMASKCOUNT_FOUR"); break;
    10.             }
    One easy way to reproduce is with the example scene 5. Mask (Box)

    Edit: unity version 2018.3.6f1
     
  44. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,140
    Script seems to be OK, make sure that all shader keywords are included into build.
    By default Unity includes into build only that keywords that currently are used by material in editor and does not know what you are changing/updating in script.
    As for performance - mobile GPUs are weak working with AlphaCutout shader and cost depends on the screen area those shaders cover.




    VacuumShaders - Facebook Twitter YouTube
     
  45. NocSchecter

    NocSchecter

    Joined:
    Aug 19, 2015
    Posts:
    29
    Hi Arkhivrag, I bought your script, there is a way to add more
    _DISSOLVEMASKCOUNT? I need to work with six but I do not understand very well the operation of shader to be able to add the other two planes that I need
     
  46. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,140
    Shader is very much hand optimized and currently there is no easy way to increase Mask Count.
    May be in future updates.



    VacuumShaders - Facebook Twitter YouTube
     
  47. NocSchecter

    NocSchecter

    Joined:
    Aug 19, 2015
    Posts:
    29
    So currently I can only work with 4 DISSOLVEMASKCOUNT?
    So currently I can only work with 4 DISSOLVEMASKCOUNT? :(
     
  48. Aaron-Meyers

    Aaron-Meyers

    Joined:
    Dec 8, 2009
    Posts:
    175
    Hi @Arkhivrag

    Love this asset! I've been using it on an AR project and it looks fantastic. I am trying to make a modification to one of the shaders and I'm really close to getting it to working right and I could use your advice.

    The idea is to have ground planes that can use an alpha mask texture to fade in and out over the video background (AR). I can't use the alpha channel of the diffuse texture itself because it is tiled a lot and the alpha mask should not be tiled and just take up the whole plane. So I modified the Standard Metallic shader and added an additional texture slot. I'm not sure how your shader gui works so I have to fill the slot when the inspector is in debug mode, but it works!

    Anyway, I added my own little #define in the shader file and then put an #ifdef in fragForwardBaseInternal inside UnityStandardCore.cginc where I sample from the alpha mask with i.tex.zw and multiply s.alpha with the result.

    So far so good!

    Here is where things get complicated: SHADOWS!

    The rendering mode on the material is set to "fade" and I understand that transparent materials in Unity do not receive shadows, but after looking around on the forums, I discovered that if you put the material's render queue to 2500 (i believe this is the Alpha-Test queue), it can actually receive shadows! The floor is the only material in the scene that needs to do this so I don't need to worry about the complexities of how it might interact with other transparent/alpha-test objects.

    So finally, the problem: everything works and looks fine on my Windows DirectX11 machine, BUT when I move into macOS, the darkness of the shadows appear to be multiplied by the alpha value of the fragment. So as the ground texture fades away, the shadows become lighter too and in parts where the ground plane are fully transparent, the shadows are invisible. This is the case also on iOS (the target platform) so it seems to be something to do with Metal. I really need to have the shadows show at a consistent darkness regardless of the fragment's opacity. I couldn't really figure out where in the dissolve shaders that the shadows are being added but I'm hoping there is some kind of solution in the shader and that this isn't something at the lower Metal API level.

    Can you offer any solution? Thanks so much!

    -Aaron
     
  49. mrmcduck

    mrmcduck

    Joined:
    Nov 26, 2015
    Posts:
    14
    Hi,

    great asset. Everything working as intended, however my build times exploded, and it shows that it has to compile thousands of shader variants (16.000+), which was not the case before. "Hidden/Internal-DepthNormalsTexture" is what is taking up the most time. It's not a big issue, but I only use one of your shaders (Standard/Metallic_SM4) on three materials, and I wondered if i can reduce the time again?

    Thanks!
     
  50. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,140
    Standard shaders shadows are calculated in UnityStandardShadow.cginc file (VacuumShaders\Advanced Dissolve\Shaders\Standard folder). All "Advanced Dissolve" related part there is on lines 204-211.


    Try:
    1) Open Internal-DepthNormalsTexture.shader file. It contains multiple SubShaders for various Unity RenderTypes.
    2) SubShaders for Advanced Dissolve render types begin from line 455 ( "RenderType"="AdvancedDissolveCutout" )
    You need only above render type, others are for Tree shaders.
    3) Remove all Advanced Dissolve SubShaders except "RenderType"="AdvancedDissolveCutout".
    4) Save file.

    5) Or check attached file. You can additionally remove unused shader keywords (lines 472 - 479)
     

    Attached Files:

    Last edited: Apr 27, 2019