Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

► Dynamic Radial Masks ◄

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

  1. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    3,008
    Each mask requires 6 - 20 mathematical operations, depending on the shape and type. On any device you can use as many masks as device can handle.



    Amazing Assets - YouTube Facebook Twitter
     
    Last edited: Jun 18, 2021
  2. badrs

    badrs

    Joined:
    May 30, 2018
    Posts:
    1
    Is there a video of how to use it?
    Do you
    exist
    Video
    explained
    to use
     
  3. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    3,008
    Here is Manual file describing how tool works and how integrate mask calculations into shader.



    Amazing Assets - YouTube Facebook Twitter
     
    Last edited: Apr 30, 2023
  4. ExcellencyHong

    ExcellencyHong

    Joined:
    Aug 9, 2016
    Posts:
    33
    is it possible to use in VFX Graph? such as position map....
     
  5. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    3,008
    With VFX Graph - no.
    Shader Graph and Amplify Shader Editor - yes.



    Amazing Assets - YouTube Facebook Twitter
     
  6. NikoBay

    NikoBay

    Joined:
    Aug 15, 2018
    Posts:
    39
    Is this asset mobile friendly?
     
  7. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    3,008
    This asset has nothing to do with mobiles, consoles or PC. It is just a collection of methods (nodes) that you manually add to a shader for calculating radial shape masks. Each mask needs several arithmetic operations or instruction count (more info in the Manual file) and you can use as much those masks inside a shader as target GPU can handle.



    Amazing Assets - YouTube Facebook Twitter
     
    Last edited: Apr 30, 2023
  8. JJRivers

    JJRivers

    Joined:
    Oct 16, 2018
    Posts:
    137
    Not sure what he meant with the latter part about position maps in relation to DRM mask unless he wants some super random positions, but i'm using DRM masks in VFX shaders in it's original intent with no issues. Is there some reason i ought not to or missed the discussions point?
     
  9. rwanim8or

    rwanim8or

    Joined:
    Jan 22, 2017
    Posts:
    18
    My apologies, I'm definitely a noob when it comes to shaders. I came across this and fell in love with all the possibilities it offered, and tried to implement it in a mobile VR game I'm working on. Unfortunately, the performance with even the most "barebones" example shader made it impossible for me to use. Has anyone used this successfully on a mobile project? Could they provide guidance towards the simplest "Dot" or "Shockwave" shader that supports 1 lit texture with color tint?
     
  10. JJRivers

    JJRivers

    Joined:
    Oct 16, 2018
    Posts:
    137
    Are you implementing it as a global feature or limited? You could go with local and only use it on stuff that is actually affected by it.
     
  11. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    3,008
    If you are using Amplify Shader Editor or Unity Shader Graph, I would suggest to check several video tutorials how to create simple basic shaders there.
    After that, adding DRM node and adjusting it for your needs will not be a problem.
    upload_2021-11-25_14-25-19.png



    Amazing Assets - YouTube Facebook Twitter
     
    Last edited: Nov 25, 2021
  12. rwanim8or

    rwanim8or

    Joined:
    Jan 22, 2017
    Posts:
    18
    I'll give it a shot, thanks!
     
  13. rwanim8or

    rwanim8or

    Joined:
    Jan 22, 2017
    Posts:
    18
    I was using it local, but some of the objects I was using it on were fairly large (like buildings)
     
  14. JJRivers

    JJRivers

    Joined:
    Oct 16, 2018
    Posts:
    137
    I was planning on using DRM masks in a compute shader to update a Texture2DArray of all active masks on any given frame on the GPU and have the project materials then sample those in our shaders ( a collection of around 10 monolithic shaders that render nearly the entire projects geometry, characters etc ) instead of calculating the masks individually for each and every set pass in the scenes.

    I have some limited experience in creating such, considering the DRM functions are designed to take absolute world positions as inputs, i'm wondering how i'd go about converting those into a version where each mask would write to a 2048x2048 texture instead that i intend to sample twice (horizontally and vertically).

    My intention here is that despite pretty vastly increasing the number of texture samples in the shaders, in most cases it should still be quite a bit faster than calculating say 6-12 global masks individually for each and every rendered object so long as i balance the texture samplers evenly across all samplings.

    Any thought's that come to mind regarding such or any other ideas that come to mind you could recommend?

    We love your asset, i'd just like to go even more wild with it without impacting performance negatively, we're at 6 global advanced masks but that's the limit of our frame budget for these and we want more.
     
  15. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    3,008
    So you are asking a solution to render shader effect (requiring mesh pixels world space position) into a texture? o_O
    May be there are some methods and techniques, but I am not aware of them.



    Amazing Assets - YouTube Facebook Twitter
     
  16. CutToTheChase

    CutToTheChase

    Joined:
    Nov 26, 2017
    Posts:
    3
    Hey I have a quick question!

    So I'm dealing with an issue where the dissolve shader is causing some weird artifacting on overlapping objects. We wanted to have it where we have our player going back and forth between past and present, so there are city buildings that will more or less be occupying the same space, just with slightly different/more dilapidated looking models.

    I'll have one version of the object on an inverted dissolve and the other on a normal dissolve, and it makes either one or the other (Depending on if I turn Recieve SSR and/or Recieve Decals on/off on the shader, not sure why) do this static-y looking zig zag pattern all over the object. I've tried slightly resizing and offsetting the conflicting objects, but this issue still occurs to some degree, and I'd like objects to stay in their relative place between switching back and forth .

    I'm sure it's something I'm doing wrong, possibly with render settings, I'm just not sure what. I'm currently using the High Definition Render Pipeline. I've attached a gif of the issue on a test world I made just to show what I'm talking about.
     

    Attached Files:

  17. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    3,008
    It looks like some setting problem in your shade.
    Do included example scenes have the similar problem?



    Amazing Assets - YouTube Facebook Twitter
     
  18. CutToTheChase

    CutToTheChase

    Joined:
    Nov 26, 2017
    Posts:
    3
    Yeah, the problem also happens with the example scene. I put down a box, duplicated it, and gave one the Dissolve Green and one the Dissolve Brown from your example materials. Now I did realize when they are right on top of each other, the box will just glow completely with one of the materials, and if I offset it just a little bit it will create the effect I showed you. I've included another gif to show that.
     

    Attached Files:

  19. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    3,008
    I was able to reconstruct that artifact at my side. It looks like some kind of ZWrite or ZTest problem in ShaderGraph for HDRP. No problems in URP.
    Need to make some research, if it is possible to fix directly from ShaderGrpah.



    Amazing Assets - YouTube Facebook Twitter
     
    Last edited: Jan 22, 2022
  20. CutToTheChase

    CutToTheChase

    Joined:
    Nov 26, 2017
    Posts:
    3
    Ah ok I gotcha! Yeah I just converted everything over to URP and just like you said no issues. That is incredibly strange, but thankfully I didnt really need the project to be in HDRP.

    Really appreciate the quick response! Been loving the asset so far and its got a lot of nifty features that I can't wait to try out
     
  21. kojiMarunouchi

    kojiMarunouchi

    Joined:
    Sep 25, 2019
    Posts:
    8
    Hi,

    Firstly thank you for offering the very stylish and useful radial mask asset.

    There is one qustion for the asset. I am looking for radial screen transition effect like this in the link below (at 6, 12 and 21 seconds in the video). https://www.youtube.com/shorts/w26igBKcS20

    By using Dynamic Radial Masks asset, can I implement a similar radial wipe transition towards multiple UIs on Canvas for screen change?

    Environment is...
    Unity 2020.3.22f
    A progect with universal render pipeline.

    Thank you for checking. bb
     
  22. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    3,008
    Yes, it is possible, if UI element uses sprite shader (tested with ShaderGraph).
    DRM.gif

    Note, package does not include example shaders for UI elements, but integrating DRM into sprite shader is the same as for common 'mesh' shaders.



    Amazing Assets - YouTube Facebook Twitter
     
  23. Binary42

    Binary42

    Joined:
    Aug 15, 2013
    Posts:
    209
    Hi,

    there is chapter 6. Calculate Mask Using Script in manual wich i find a little misleading since it is about getting the mask.
    But how can i set the mask (per frame) from another shader or script?
    I am calculating a fov with shadows and like to set that as a mask for the handwritten version.
     
  24. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    3,008
    You set mask properties inside DRMContoller script and based on that settings DRM is calculated inside a shader or in the run-time CPU method that is described in the Manual.
     
    Last edited: Apr 30, 2023
  25. luarpro

    luarpro

    Joined:
    Feb 24, 2020
    Posts:
    1
    If I want to change DRMAnimatableObjectsPool setting value in runtime, e.g. Life Length
    how can I do it in script?
     
  26. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    3,008
    DRMAnimatableObjectsPool script has no settings. It just animates list of DRMAnimatableObject, based on their settings.
    DRMAnimatableObject has public property lifeLength, you can adjust it from script.
     
  27. RespiroUnit

    RespiroUnit

    Joined:
    Nov 11, 2022
    Posts:
    2
    Hi, Sorry I don't know about shaders. I am using "liquid (Displace)" material. I want to change the base color with script but I don't know how. can you help?
     
  28. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    3,008
    Check property's reference name and then modify it using SetColor method.
    upload_2022-11-12_11-41-42.png
     
  29. RespiroUnit

    RespiroUnit

    Joined:
    Nov 11, 2022
    Posts:
    2
  30. Nirvan

    Nirvan

    Joined:
    Nov 16, 2013
    Posts:
    134
    There is no amplify shader node for URP?
     
    Last edited: Apr 30, 2023
  31. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    3,008
    All render pipelines are supported.
     
    Last edited: Apr 30, 2023
  32. Nirvan

    Nirvan

    Joined:
    Nov 16, 2013
    Posts:
    134
    Yeah but when I am trying to use "DynamicRadialMasks_Torus_16_Advanced_Normalized_ID1_Local"
    (not included in the "Universal.unitypackage" but in Standard)
    in universal Lit shader by amplify shader editor, it always produces error in shader code like:

    Code (CSharp):
    1. Shader error in 'AmplifyRadialTest': undeclared identifier 'DynamicRadialMasks_Torus_16_Advanced_Normalized_ID1_Local_float' at line 561 (on d3d11)
    When trying to use this node on standard pipeline like that (the only ASE node available in package):
    upload_2023-4-30_10-26-37.png
    on the liquid demo, nothing happens on the plane (I am changing shader of Liquid demo material to use the same references for components etc.)

    Edit: Aaah ok, the Window -> Amazing Assets -> Dynamic Radial Masks window can generate ASE nodes
     
    Last edited: Apr 30, 2023
  33. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    3,008
    Which Unity version are you using?
    Just tested with 2020.3 and 2021.3 LTS versions and everything works correctly at my side.
     
    Last edited: Apr 30, 2023
  34. Nirvan

    Nirvan

    Joined:
    Nov 16, 2013
    Posts:
    134
    Sorry, I got confused and I was using just the ASE node included in the examples package.
    I found I can generate ASE nodes in the Window -> Amazing Assets -> Dynamic Radial Masks Window
    and it works right now! (unity 2022 URP 14)
     
    Arkhivrag likes this.
  35. starwarrior516

    starwarrior516

    Joined:
    Apr 4, 2021
    Posts:
    1
    How would this work with terrain in HDRP?
     
  36. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    3,008
    If you integrate DRM inside terrain shader, it will work as you want.
     
  37. diegopandrade

    diegopandrade

    Joined:
    Sep 14, 2013
    Posts:
    2
    Tessellation is now available on the HDRP, but it seems that the vertex displacement is happening before the tessellation takes effect. Any idea on how to make it work?
     
  38. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    3,008
    Instead of adjusting Position input, use Tessellation Displacement.
    upload_2023-8-28_16-43-24.png

    If you want to add tessellation to the package included vertex displacement example shader, it may not work correct as you will have to adjust vertex displacement math there too.
     
  39. Krooq

    Krooq

    Joined:
    Jan 30, 2013
    Posts:
    196
    I'm struggling to get multiple material instances to work.
    I've got the bullet hole scene but duplicated the doors and assigned instances of the materials at runtime instead of using the shared one.
    I modified the raycast script a little to get it to add to the right pool, depending which door i click on.
    upload_2024-2-6_18-43-36.png
    The result is that only one door works.

    The strange thing is that the other door works sometimes, depending on the camera angle or when I mouse over the inspector. Which after some fiddling actually appears to be related to whether or not the other door was culled i.e. if you can only see one door then it works.
    Is this a limitation of DRM????
    upload_2024-2-6_18-46-53.png

    I'm using Unity 2022.3.18 LTS
    DRM 2023.1
    HDRP 14.0.10
     

    Attached Files:

  40. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    3,008
    Confirm, instancing doesn't work. And here is why:

    Each DRM class, with all its variables and used methods is declared inside its own separate cging file:
    upload_2024-2-7_13-37-26.png


    For the instancing to work, DRM class variables needs to be manually moved from its cginc file inside main shader file's CBUFFER:
    upload_2024-2-7_13-38-47.png

    Unfortunately currently Unity doesn't allow extending CBUFFER variables inside separate cginc file and requires all of them be inside main shader file.

    I have to write some tool that automates this process by generating new shader file with all required adjustments applied.
     
    Krooq and hopeful like this.
  41. Krooq

    Krooq

    Joined:
    Jan 30, 2013
    Posts:
    196
    Ah that's unfortunate, really limits the capability.
    Thankyou for taking the time to explain it, I appreciate it.
     
  42. qkrwjdtlrz

    qkrwjdtlrz

    Joined:
    Mar 12, 2021
    Posts:
    1
    Hello. I need your help. I'm trying to add functionality to an existing shader graph using Amplify Shader Editor. The feature I want to add is a disappearing feature, and I've brought it in to use it. Could you tell me what I need to connect at this stage to apply it? I'm a programming developer, not a shader developer, so I don't know much. I need your help.


    The existing shader graph functionality is from the Vegetable Engine. I want to add a disappearing feature to this functionality.
     

    Attached Files: