Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

► Dynamic Radial Masks ◄

Discussion in 'Assets and Asset Store' started by Arkhivrag, Mar 6, 2020.

  1. ProdigyGamesEntertainment

    ProdigyGamesEntertainment

    Joined:
    Feb 9, 2020
    Posts:
    2
    Hello!
    I can't find the guide to make the dissolve effect (I work in Hdrp), can you plese tell me where to watch?
    Thank you
     
  2. b1gry4n

    b1gry4n

    Joined:
    Sep 11, 2013
    Posts:
    146
  3. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,937
    Dissolve effect is very simple to achieve using ShaderGraph. Just use resultant mask value in AlphaClip slot for the master node (may be it will need to be multiply by 2).



    Amazing Assets - YouTube Facebook Twitter
     
  4. edufurlaneto

    edufurlaneto

    Joined:
    Sep 18, 2017
    Posts:
    16
    Hi.
    I am updating my URP project with the last version and now seems is not possible any more create an Amplify Shader Function selecting Simple Algorithm or Global Scope. Every time I select these options the bottom menu disappears. Unfortunately, my project uses both. I am doing something wrong?
    Thanks
     
  5. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,937
    Unity version? ASE version?



    Amazing Assets - YouTube Facebook Twitter
     
  6. edufurlaneto

    edufurlaneto

    Joined:
    Sep 18, 2017
    Posts:
    16
    Hi. Sorry about the late response, I had to finish another project before return to this one.
    Unity 2020.1.6f1 ASE 1.8.5
    Thanks
     
  7. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,937
    Just tested with Unity 2020.1.8f1 (URP) and ASE 1.8.5 - no problems found.
    Clicking on Amplify Shader Function button, creates ASE function file and it is highlighted in Project window.
    Everything works as expected.
    upload_2020-10-12_21-53-24.png

    Try re-importing Amazing Assets folder.

    Note, source code is fully included. Check DRMEditorWindow.cs file and if you can debug line: 95, here you can find generated file path.



    Amazing Assets - YouTube Facebook Twitter
     
  8. edufurlaneto

    edufurlaneto

    Joined:
    Sep 18, 2017
    Posts:
    16
    You are right.
    I haven`t realized we need to first click on create and only after that the other options will appear.
    All is working fine.
    Thanks for the quick answer.
     
  9. bunnybreaker

    bunnybreaker

    Joined:
    Dec 10, 2013
    Posts:
    23
    What's the licensing regarding making shaders using this asset and then selling/distributing them?
     
  10. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,937
    You can not sell/distribute files from this asset. You can not include them in your asset and sell/distribute them. More info about assets and licenses is here.

    You can create your asset or shader using this asset and then sell/distribute it, but do not include any of files from this package, instead make it this asset dependent.



    Amazing Assets - YouTube Facebook Twitter
     
    bunnybreaker likes this.
  11. TextusGames

    TextusGames

    Joined:
    Dec 8, 2016
    Posts:
    426
    Hello. Can I get a texture of colors instead of only greyscale texture?
    (I mean each object has a separate color) (hoping to use this as some form of stylized multicolor lighting system)
     
    Last edited: Nov 23, 2020
  12. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,937
    Generated result is always float (not the grey-scale texture).
    You use this value inside shader for achieving desired effects. What exactly are you trying to do?



    Amazing Assets - YouTube Facebook Twitter
     
  13. TextusGames

    TextusGames

    Joined:
    Dec 8, 2016
    Posts:
    426
    A custom lighting.
    Imagine each radial mask object also has a custom data like a color (float3). I want to get a result as float4 there xyz is a color and w is a mask. I then can multiply this result with original colors and get recolored (lighted) objects.
    [/QUOTE]
     
  14. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,937
    No, this is not possible.
    Calculated result is not a collection (or array) of separate individual masks, instead it is the one value.

    You can imitate similar effect by using several DRM objects (differentiate by ID) each one with different color mix inside a shader.



    Amazing Assets - YouTube Facebook Twitter
     
    TextusGames likes this.
  15. RafaelGuimaraesBarbosa

    RafaelGuimaraesBarbosa

    Joined:
    Dec 14, 2019
    Posts:
    15
    Can I use another shader material like FlatKit with Dynamic Radial Masks?
     
  16. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,937
    Yes, you can. If you follow instructions described in Manual file and do manual integration of this asset into FlatKit. Shader programing skills and knowledge are required for that.

    If FlatKit shader is based on Amplify Shader Editor or Unity Shader Graph, then no shader programing is required, you just use DRM nodes inside shader graphs.



    Amazing Assets - YouTube Facebook Twitter
     
  17. RafaelGuimaraesBarbosa

    RafaelGuimaraesBarbosa

    Joined:
    Dec 14, 2019
    Posts:
    15
    Perfect, I Buy this, thanks
     
  18. jamesparksart

    jamesparksart

    Joined:
    Dec 1, 2017
    Posts:
    35
    @Arkhivrag - I bought your asset tried following the pdf and well.. I am still confused why I can't get it to work. I have Amplify Shader Editor.. I placed your Function into the editor.

    Steps I did:
    1.) Created Shockwave
    a.) Count 1
    b.) Alg advanced
    c.) Blend Additive
    d.) ID 2
    e.) Scope: local

    2.) Created Amplify Shader

    3.) Placed Function into my shader

    4.) linked mask to my Surface Albedo

    5.) Added Vertex Position to WorldPos

    6.) Built Shader out

    7.) Applied Material to Shockwave Plane

    8.) Changed material in DRM controller to New Material I created

    9.) Adjusted DRM Controller script settings to match the shock wave ID 2 I created.

    9.) Adjusted Shockwave DRM Game object script settings.. nothing happens.


    Sorry, I am not a coder or anything by any stretch of the imagination. I am just a Graphic Designer/3D modeler… so that is probably why this is not working. LOL. I am using the example scene with all of the examples. On Shockwave plane. Do you have a tutorial video on how to set it up? If not I might suggest making one or make a menu for 1 click buttons like 1 click makes the material, scripts, function, amplify shader, etc.. so all you have to do is apply material to your model. Or make it a camera effect or postprocessing effect? That way you don’t use up the material for the model and you can use your own material and just have maybe a script that includes it in the radial mask..? Could you do dynamic radial masks with that? Like on raycast hit collider create hole? That would be cool, so if you shoot like lets say glass you could have a hole in the glass and have a decal to.. mask the mask. So that alpha on the decal would still allow you to see through it, but would be the broken decal on the glass.. I don't know again not a programmer.
     
  19. santax08

    santax08

    Joined:
    Apr 21, 2018
    Posts:
    3
    Hey, I've got a question before I buy you're asset.

    Can i get this kind of visual effect on the ground ? The line that limit the mouvement of the character. And the circle around the character in the middle of the screen.


    Thanks for your reply, by the way, your asset looks very awesome.



    Amazing Assets - YouTube Facebook Twitter[/QUOTE]
     
  20. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,937
    You have to manually integrate DRM into a shader and use it as you want and need.

    To make DRM visible inside material make sure DRMContrller script and DRM node in Amplify Shader have exactly same settings and target material is in the Materials array of the controller script.
    upload_2020-12-10_13-53-42.png

    There are several options (described in Manual file) how to generate DRM data that DRMContrller script sends to a material.
    For example using DRMOnMouseRaycast method. This file creating DRM objects and saves them inside DRMAnimatableObjectsPool.
    upload_2020-12-10_14-4-13.png

    DRMAnimatableObjectsPool script can receive DRM objects from many various scripts. It collects them all and sends to DRMContrller script.
    Make sure DRMAnimatableObjectsPool has assigned DRMContrller script.

    If all this is correctly done, then DRMContrller will send DRM objects data to the material into the required node.
    upload_2020-12-10_14-11-35.png

    Some more tips:
    • Enable Draw In Editor check box in DRMController script - this will draw DRM gizmos in editor and help you check if DRMController script receives any data from Pool scripts.
    • Check Objects In Pool parameter inside DRMAnimatableObjectsPool script - displays total number of DRM objects in pool, sending to DRMController script.
     
    Last edited: Dec 10, 2020
  21. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,937
    Circle around character - yes. Line of the limit - no.

    Note, DRM needs to be integrated into shader. Any kind of meshes requiring DRM shape projection need to have DRM property inside their materials. If you have several 'ground' meshes that character moves on, all materials of those 'ground' meshes needs DRM injection.
    If the only purpose of using DRM in your case is drawing white circle on the ground, may be using post processing or image effect is better option.



    Amazing Assets - YouTube Facebook Twitter
     
    santax08 likes this.
  22. santax08

    santax08

    Joined:
    Apr 21, 2018
    Posts:
    3
    Thx for your reply and advice, I understand how it works now. Thx a lot.
     
  23. Evenir

    Evenir

    Joined:
    Oct 14, 2017
    Posts:
    1
    I'm trying to use the asset with the latest AmplifyShaderEditor (1.8.8), but I'm constantly getting an error from custom functions. Like this: "Custom expression "Read_DynanamicRadialMasks_Torus_32_Advanced-blah-blah-blah..." has a non-void return type but no return instruction was detected." I've already tried recreating the cginc and other files from DRM menu to no avail. Do you know what I'm doing wrong?
     
  24. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,937
    AS bug introduced in the previous versions and it seem it has not been fixed yet.
    I'll try to find workaround.

    [Edit]
    Update with AS v1.8.8 support will be on Monday.



    Amazing Assets - YouTube Facebook Twitter
     
    Last edited: Jan 9, 2021
  25. raxashafique

    raxashafique

    Joined:
    Sep 12, 2015
    Posts:
    6
    Hi! just wanted to ask a quick question.. does it support Lightmaps? Em using bakery for lightmaps in URP workflow and want to create something like the City>Forest video you have posted. Reference Picture is attached for what I want to achieve and if it requires shader editing, I have Amplify Shader Editor.
    Thanks.
     

    Attached Files:

    Last edited: Jan 28, 2021
  26. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,937
    DRM is no a shader, it is an extension that you manually add inside shader. For ShaderGraph and ASE it is a node.
    This node you can use to interpolate one value into another.
    upload_2021-1-29_1-55-44.png

    For example: DRM node here is used for interpolating between BaseColor and its saturated version.
    Effect from screenshot can be created using DRM - it is created for such effects.




    Amazing Assets - YouTube Facebook Twitter
     
    raxashafique likes this.
  27. macube

    macube

    Joined:
    Jul 16, 2017
    Posts:
    37
    Is it possible to use this on unity terrains ? (not on mesh terrains)
     
  28. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,937
    DRM can be integrated in any type of shaders: common shaders, terrain, post processing.
    But note, all integrations are made manually and you need to now how to modify Unity terrain shaders. Package includes example shaders only for common shaders, not terrain.



    Amazing Assets - YouTube Facebook Twitter
     
  29. macube

    macube

    Joined:
    Jul 16, 2017
    Posts:
    37
    Ok, i'm looking into it. Thanks!
     
  30. unleashed1911

    unleashed1911

    Joined:
    Dec 30, 2019
    Posts:
    10
    Hey there,

    Great Asset!

    I want to add another DRMGameObject to the DRMController. The Shape is Heightfield. When i add it to the DRMGameObjectsPool via AddObject it doesn't work. When i put the count of the DRMController to anything higher than 1 nothing works anymore. I'm using the example Scene with the Trees from the Asset.

    Any chance to add another DRMGameObject to the pool on runtime?
     
  31. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,937
    1. You can not add DRMGameObject to the DRMController.

    2. You can add DRMGameObject to the DRMGameObjectsPool (this script collects all DRMGameObjects data and sends them to the DRMController).

    3. Make sure DRMController is setup to receive required amount of DRMObjects (Count parameter), also materials whose DRM properties are updated by DRMController must be using same Count of DRMObjects.

    4. Increase DRM Game Objects array property inside DRMGameObjectsPool script and add required DRMGameObject there (editor window may need to be repainted for the effect to be visible, just update any property inside new DRMGameObject script).

    upload_2021-3-4_19-14-33.png
    In this example scene shaders can use only 4 DRM objects.



    Amazing Assets - YouTube Facebook Twitter
     
    Last edited: Mar 4, 2021
  32. unleashed1911

    unleashed1911

    Joined:
    Dec 30, 2019
    Posts:
    10
    Hey there,

    Thanks for the fast answer!

    Steps to reproduce:

    1. I set the count in the DRMController to 2.
    2. On start there is already one DRMGameObject in the DRMController.
    3. Via script I reference the DRMGameObjectsPool and add another DRMGameObject via AddObject.
    4. Now not even the first mask is working anymore, nor the second.
     
  33. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,937
    Settings in the DRMController must be exactly the same as in materials they are updating.
    You can check those settings directly inside shader node name:

    upload_2021-3-5_15-57-0.png


    If you are using hand written shader, check used method name:
    upload_2021-3-5_16-0-13.png

    Also check documentation chapter 5, page:18.



    Amazing Assets - YouTube Facebook Twitter
     
  34. unleashed1911

    unleashed1911

    Joined:
    Dec 30, 2019
    Posts:
    10
    Allright, i will have a look into it. I was using your material though. Thought that would have been implemented already, my fault.

    Thanks for the prompt help!

    Another small question, i don't even know if it's related to your asset, but it happens since i imported it.

    Is this a known issue maybe? This happens sometimes as soon as I scale up the mask. Its very hard to reproduce, but maybe there is some setting i have to do to prevent this error.
     

    Attached Files:

  35. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,937
    Error is not related to the DRM, pretty sure even not Unity itself.
    You may need to update system libraries. Google will better help you in this case than me.



    Amazing Assets - YouTube Facebook Twitter
     
  36. unleashed1911

    unleashed1911

    Joined:
    Dec 30, 2019
    Posts:
    10
    Allright. Thank you very much!
     
  37. rokert34

    rokert34

    Joined:
    Nov 15, 2017
    Posts:
    3
    Hello, I need to create a wave of a color and when creating the next wave must be of a different color, if wave 1 is blue and I create wave 2 of red also modifies the color of wave 1. How can I do so that each wave has its own color?
     

    Attached Files:

  38. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,937
    Value generate by DRM node is not a collection of separate masks, it is the one value.
    You can not achieve multi-color result using just one node. You have to use several DRM nodes each one for individual color.
    Create several similar DRM nodes with different IDs, add them to a shader and with each node use desired color.
    For updating each node inside shader use separate DRM controller based on its ID.



    Amazing Assets - YouTube Facebook Twitter
     
  39. rokert34

    rokert34

    Joined:
    Nov 15, 2017
    Posts:
    3

    I have duplicated the nodes as you have indicated but I noticed that the terrain sonar color is not multi-color, the result is the same color. Should I apply some other configuration or do you have an example I can base it on?
     
    Last edited: Mar 15, 2021
  40. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,937
    Duplicating DRM nodes inside shader will not work, as they are just the copy of each ones, they will generate the same mask value.
    1) You need to create DRM nodes using editor tool. With similar settings, only ID should be different.
    2) Use those nodes inside shader and multiply each one with desired color. Sum results.
    3) Make sure each individual DRM node is updated using its own controller script (pay attention to the ID property value).

    Here is example of using 4 identical DRM nodes. Each one generates similar Tube shaped mask, but as each one has different ID, they can be used separately.
    upload_2021-3-15_22-46-50.png

    Note, each DRM node inside shader needs it own controller script which updates its data. Property values inside controller script must be identical to the node's settings it updates.
    Node name contains exactly this information.

    Inside shader you can mix any type of DRM nodes.
    Package includes Example_5_MultipleMasks example scene demonstrating how 2 different DRM effects can be mixed inside one shader.



    Amazing Assets - YouTube Facebook Twitter
     
    rokert34 likes this.
  41. rokert34

    rokert34

    Joined:
    Nov 15, 2017
    Posts:
    3
    Perfect! It's just what I need, it works great. Thank you very much!

    upload_2021-3-15_14-42-45.png
     
  42. unleashed1911

    unleashed1911

    Joined:
    Dec 30, 2019
    Posts:
    10
    Hey there,

    is there any chance to get if an object is dissolved or not? i can't figure out which variable i could use for that. I figured maybe alphaclipthreshould but i can't access that directly. Any chance to figure out if an object is visible or not by code?
     
  43. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,937
    Mostly - No.
    Shader is just an inscription for GPU how to draw pixel on screen.



    Amazing Assets - YouTube Facebook Twitter
     
  44. unleashed1911

    unleashed1911

    Joined:
    Dec 30, 2019
    Posts:
    10
    I want to dynamically deactivate a collider based on its visibility. Do you maybe know a way? I kinda want to create a level where there are two seperate worlds with your dissolve shader. For that i need to have colliders dynamically activate and deactivate.
     
  45. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,937
    You can just check radius of the used sphere object and based on this values decide further actions. If radius is big enough to cover entire 'world', then you can make assumption that it is completely dissolved.
    But there is no any real ways for reading data from shader to check if pixels on screen are dissolved or not.



    Amazing Assets - YouTube Facebook Twitter
     
  46. Trixxy

    Trixxy

    Joined:
    Apr 9, 2015
    Posts:
    31
    Hi, I have purchased your asset as there are some really nice features that will help with the visual effects, I have only just started learning to code shaders and wanted a bit of advice to integrate the dissolve feature into a terrain shader, the objective is to place a building and have your asset change the terrain visible under the building. Could you please help with any simple steps to do this?

    Thanks very much
     
  47. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,937
    If you have just started learning shaders I'd suggest to practice DRM implementation into common shaders. After some practice it will be much easier to begin working with terrain shaders.
    Download Unity built-in shaders based on your Unity version (link) and import terrain shaders from DefaultResourcesExtra\TerrainShaders\Splats folder. You have to modify 2 shader files there: FirstPass and AddPass, and their cginc file located in CGIncludes folder.
    With terrain shaders always use Global DRM properties.



    Amazing Assets - YouTube Facebook Twitter
     
  48. Gelatinous3

    Gelatinous3

    Joined:
    Sep 18, 2020
    Posts:
    1
    Hi there, thanks for making such an awesome asset!

    I'm currently trying to solve for using dynamic masks to manipulate collisions, similar to what was responded to in this post - I'm assuming this is the right addon to do so, but not sure where to define the trigger as suggested.

    As an example of what I'm trying to accomplish, using the 'dissolve' example scene between green/dead forests, right now if I apply collision meshes to those forests both exist regardless of which mesh is currently visible. I'm looking to achieve an effect where the mask also controls whether or not those collisions will be ignored.
     
  49. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,937
    You can differentiate meshes and colliders on those two "worlds", for example using tag or layer. And based on condition
    activate or hide them. For example if mesh is inside DRM (sphere collider/trigger) activate its collider and deactivate those ones that are outside.



    Amazing Assets - YouTube Facebook Twitter
     
  50. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,457
    Awesome asset, how performant is this on low-mid level mobile devices?