Search Unity

[Best Tool Asset Store Award] Amplify Shader Editor - Node-based Shader Creation Tool

Discussion in 'Assets and Asset Store' started by Amplify_Ricardo, Sep 13, 2016.

  1. Organism-Studios

    Organism-Studios

    Joined:
    Oct 22, 2013
    Posts:
    7
    Thank you for your reply, let me rephrase my question.

    I've created a shader that blends two normal maps on an object with two UV sets.
    - The (first) main normal map uses the built-in tangent basis based on UV0, no problem here.
    - The (second) detail normal map is created to use the tangent basis based on UV1 but uses UV0 by default too, so this results in incorrect normals.

    Question: Is there a way to set the secondary normal map to use the tangent basis based on UV1?

    From reading it's description, I was under the impression that the "Derive Tangent Basis" function could be used for normal mapping for UV1, but I'm not sure if I understand it correctly.

    DeriveTangentBasis.JPG

    Thanks!
     
    Last edited: Jul 14, 2020
  2. Amplify_Ricardo

    Amplify_Ricardo

    Joined:
    Jul 19, 2013
    Posts:
    2,389
    Sorry, maybe it's a terminology misunderstanding on our end, we're not fully sure that we understand the issue here.

    If the second normal map is using UV0 instead of UV1, you'd simply change its sample UV value, that would map it correctly.


    (yes, 0 is 1 there, that's Unity for you ;) )
     
  3. Organism-Studios

    Organism-Studios

    Joined:
    Oct 22, 2013
    Posts:
    7
    I was a little slow with editing my previous post. :0
    The texture sampler we use for the detail normal map was already set to 2 (UV1 in Unity), but it uses the tangents calculated in mikktspace based on UV set 1 (UV0 in Unity).

    The description of the Derive Tangent Basis function node literally describes the problem and the solution, but I don't know how to use it's output.
     
  4. Amplify_Ricardo

    Amplify_Ricardo

    Joined:
    Jul 19, 2013
    Posts:
    2,389
    Got it, we just wanted to make sure we were referring to the same thing.

    Use the Derive Tangent Basis node like this(Texture Sample node set to UV2):
     
  5. Organism-Studios

    Organism-Studios

    Joined:
    Oct 22, 2013
    Posts:
    7
    That's exactly what I was looking for :) I just need to change the normals from world space to tangent space, but I think I can figure that out.

    Thank you so much for the example!
     
    Amplify_Ricardo likes this.
  6. o1o101

    o1o101

    Joined:
    Jan 19, 2014
    Posts:
    639
    Edit: solved, used a world position from depth instead.
     
    Last edited: Jul 15, 2020
  7. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,362
    Thanks Ricard, this is very valuable. I'll switch to disabling individual components.
    2. optimizing. As I remember back in the days, surface shaders are quite sub optimal already, the preference on mobile games used to be writing your own cg shaders, which is a pain, and which was 7 years ago.
     
  8. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,362
    How do you do a deferred wraplambert?
    One that doesn't revert to forward...
     
  9. Beauque

    Beauque

    Joined:
    Mar 7, 2017
    Posts:
    61
    Hi @Amplify_Ricardo, I come for the object space normal triplanar mapping issue. Have you got some news on your side? Will this require to wait for an update of ASE?.
    I reproduced the triplanar sampler node by node in my original shader, would there be a fix I can implement directly in there?
     
  10. Amplify_Ricardo

    Amplify_Ricardo

    Joined:
    Jul 19, 2013
    Posts:
    2,389
    Cool, the transform nodes could help. It's not really something I've tried my self so do let us know if you run into any problems, our devs would be happy to assist.


    Nice!


    No problem, happy to share any details. Our game has no loadings so we learned that the hard way, we had to create a system to stream in the objects as they were causing stuttering, regardless of complexity. I forget the full details but this is due to how it's handled on the main thread, which could be avoided. The folks from Inside actually found a way to bypass this problem on their game, not necessarily related to the Switch, makes for an interesting GDC presentation.

    If you can, avoid using Surface Shaders all together.


    Hey there, your support ticket is still on our queue. One of our developers will provide some additional insights soon.

    When a fix is made available, you'll have to re-save your shader to update.

    Apologies for the inconvenience.
     
  11. Amplify_Ricardo

    Amplify_Ricardo

    Joined:
    Jul 19, 2013
    Posts:
    2,389
    Much like custom lighting, that's not going to be possible without actually changing Unity's built-in deferred shading. Deferred lighting means that lighting calculations are made later, and not by object, you can't do that by object if it's not in Forward.

    The problem with changing those internal shaders is that it's then "wraplambert" would be applied to everything, assuming it worked, there's no way to filter it out unless you have a specific system in place.

    I would say that this is an advanced subject beyond the scope of our editor.
     
    laurentlavigne likes this.
  12. Beauque

    Beauque

    Joined:
    Mar 7, 2017
    Posts:
    61
    Oh sorry I see, thank you !
     
  13. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,362
    no problem, I'm changing the deferred lighting shader so it'll work ok eventually, but why does outline on toggles mode to forward?
     
  14. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,362
    how do i do that with amplify editor?
     
  15. Amplify_Ricardo

    Amplify_Ricardo

    Joined:
    Jul 19, 2013
    Posts:
    2,389
    Good luck there, hope it works well!

    Our basic outline is forward only.

    Use one of the Vert/Frag templates available or create your own.

    Just to be clear, I'm not saying that you shouldn't use Surface Shaders on the Switch; I mean that, if you're worried about that level optimization, you can avoid using them.

    We use quite a few Surface Shaders on our game and it's far from being our bottleneck; physics and draw calls are more concerning.
     
  16. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,362
    when I figure out with BRDF3_Unity_PBS is *actually* being called, it'll be easy :rolleyes:
    I'll benchmark it more.
    Since drawcalls are more of a concern, do you guys use the deferred path?
    About outline, is it not doable with the builtin deferred?
     
  17. Amplify_Ricardo

    Amplify_Ricardo

    Joined:
    Jul 19, 2013
    Posts:
    2,389
    Yes, our game in Deferred.

    I suppose but I don't really have any pointers for the outline there, might as well look into screen based outlines.
     
    laurentlavigne likes this.
  18. Pepe-Hoschi

    Pepe-Hoschi

    Joined:
    Feb 27, 2016
    Posts:
    8
    Any updates regarding the missing Sampler State feature?
     
    Beauque likes this.
  19. Amplify_Ricardo

    Amplify_Ricardo

    Joined:
    Jul 19, 2013
    Posts:
    2,389
    Yeah, just putting on some finishing touches and it's ready to roll.

    Can't guarantee it for today's update but it's very near.
     
    Pepe-Hoschi and Beauque like this.
  20. franky_li

    franky_li

    Joined:
    Aug 8, 2016
    Posts:
    163
    I had a strange issue with Amplify Shader editor. I added an asset:
    https://assetstore.unity.com/packag...dscapes/photoscanned-moutainsrocks-pbr-130876
    to my project, got while importing an error message from Amplify Shader Editor that I have some legacy stuff in a folder and if this stuff should be removed. I clicked 'yes' (how stupid I was) and afterwards my whole asset folder was deleted and the '.plastic' folder from Plastic scm. How is this possible?
     
  21. Amplify_Ricardo

    Amplify_Ricardo

    Joined:
    Jul 19, 2013
    Posts:
    2,389
    Sounds scary. I don't think that we have any messages like that, nor does ASE delete any folders/files. We could use some additional details.
     
  22. Trecool182

    Trecool182

    Joined:
    Aug 30, 2018
    Posts:
    10
    Hi amplify team

    I am trying to achieve an effect based on the distance between the object's transform and the camera's transform. Having inconsistent result, i am now doing the following test shader : I'm trying to display the object black when distance = 0, white when distance = 1, and shades of grey in between. To better visualize the range limits, I added 2 conditions to output pure red when outside of the range.

    Here is the graph :
    upload_2020-7-16_19-46-10.png
    http://paste.amplify.pt/view/raw/caaae859

    My observations :
    urOBqouXCB.gif
    - The result is always red if i don't set the offset somewhere below 0.
    - Setting the offset to -1 does seem to work with the minimum range (can't trigger the red color by getting too close), but it only becomes red when the camera is further than about 1.7 units.
    - Setting the "RangeMIN" to 0.01 seems to make the actual threshold be much further than 0.01 units
    - I also tried using an actual camera at runtime instead of viewport camera, results were identical
    - I have tried converting the result from linear to gamma space, as expected it makes the color transition better, but the range remains the same.
    - Expected result would be that with an offset of 0, it would only be black when exactly in the object, and becomes red when camera is exactly at y=1 (or less if there is horizontal offset, but never more).

    What gives?
    Thanks
     
  23. Pepe-Hoschi

    Pepe-Hoschi

    Joined:
    Feb 27, 2016
    Posts:
    8
    It seems I run into an issue using the triplanar sampler node together with a texture array on HDRP 7.4.1.
    The console tells me: unrecognized identifier 'topTexMap' (on d3d11)
    Which is in this line:
    inline float4 TriplanarSamplingSFA( ASE_TEXTURE2D_ARRAY_ARGS( topTexMap ), ...

    Just a few lines above topTexMap is declared. I named the parameter of the Texture Object "topTexMap" and exposed it to the UI:
    TEXTURE2D_ARRAY( topTexMap );
    uniform SAMPLER( samplertopTexMap );

    It works when I remove the argument from the function, as the sampler and texture lies within the scope of the function. I don't have a clue why the compiler throws this error. The shader generated code looks fine to me so far.
     
  24. Amplify_Ricardo

    Amplify_Ricardo

    Joined:
    Jul 19, 2013
    Posts:
    2,389

    Seems good on our end, please try updating to the latest ASE version from our website. If the problem persists, please send us a small sample for further examination.

    Thanks!
     
  25. Amplify_Ricardo

    Amplify_Ricardo

    Joined:
    Jul 19, 2013
    Posts:
    2,389
    Greetings!

    One problem might be that you're plugging a Vector4 output to the distance with a Float3, you should use a Component Mask or Swizzle to make sure that you input a Float3 there.

    Our devs recommend something as the image below instead of using the IF's.



    Let us know if it helps, we would be happy to assist.
     
  26. Amplify_Ricardo

    Amplify_Ricardo

    Joined:
    Jul 19, 2013
    Posts:
    2,389

    Hey folks, we got a new sample for you, this time we went with Vector Displacement Mapping. We took advantage of HDRP but you can very well convert it to other renderers with out editor, it's as easy as changing the shader type and saving.

    It's already available via our website and should be at the Asset Store as soon as the update is made available there; as a reminder, you can always get the latest versions of our products via our site.

    Get it here: http://amplify.pt/download
     
    petersx and hopeful like this.
  27. Trecool182

    Trecool182

    Joined:
    Aug 30, 2018
    Posts:
    10
    It works! I can't believe it didn't see that. It makes perfect sense. I've been banging my head quite a while on this.
    No worries about the IF's, it's just something i threw together just to visualize the range, and i understand it's quite un-optimized, but thanks for the tip.

    Thanks a lot!
     
  28. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    883
    I've updated to the latest version and now I have a compile error in console:

    (Unity 2019.4.2, substance plugin installed)

    Assets\AmplifyShaderEditor\Plugins\Editor\Nodes\Textures\SubstanceSamplerNode.cs(1144,52): error CS0117: 'TemplateHelperFunctions' does not contain a definition for 'CreateUnpackNormalStr'
     
  29. Novez

    Novez

    Joined:
    Jun 3, 2014
    Posts:
    14
    I extracted the HDRP samples but in all the scenes a lot of prefabs are missing. It says I've imported everything?
     
  30. Amplify_Ricardo

    Amplify_Ricardo

    Joined:
    Jul 19, 2013
    Posts:
    2,389
    Awesome, glad it works!

    That's odd, did you have the Substance plugin in your project? It shouldn't be a problem, I just want to confirm it.

    Do you see the same error in a new empty project?

    You should use the Import screen instead of importing them directly from the package, we changed this somewhat recently.

    Go to Window > Amplify Shader Editor > Start Screen and presse the HDRP Samples button.

    upload_2020-7-20_9-18-49.png
     
  31. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    883
    Yes, I have the Substance plugin in the project. I've added missing method (copied it from the git history) for now. I will look if the problem appear in the empty project later. Thanks.
     
  32. Amplify_Ricardo

    Amplify_Ricardo

    Joined:
    Jul 19, 2013
    Posts:
    2,389
    Sorry, kinda lost you there. You copied what from where? =P

    In any case, that's not supposed to happen. We will run a few tests with latest Substance Plugin version.

    What's your current renderer?
     
  33. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    883
    I use HDRP. The plugin version is 2.5.1
    I copied missing method CreateUnpackNormalStr into TemplateHelperFunctions.cs from the perviuos version of Amplify and the error gone away.
     
  34. Amplify_Ricardo

    Amplify_Ricardo

    Joined:
    Jul 19, 2013
    Posts:
    2,389
    Ah, you mean you git repo, got it.

    We already have an incoming update, thanks for bringing this up.
     
  35. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    883
    Thank you!
     
  36. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,362
  37. craigjwhitmore

    craigjwhitmore

    Joined:
    Apr 15, 2018
    Posts:
    135
    Just had a look at a shader made with Amplify, it has this nice and expensive chain assignment:

    Code (CSharp):
    1. half lerpResult233_g36 = lerp( 1.0 , Base_Extras_RGB213_g36 , Element_Intensity56_g36);
    2. half temp_output_9_0_g82 = lerpResult233_g36;  //totally redundant
    3. half sRGB8_g82 = temp_output_9_0_g82;             //totally redundant
    4. half localGammaToLinearFloatFast8_g82 = GammaToLinearFloatFast( sRGB8_g82 );
    These variables aren't used anywhere else in the shader at all. This type of thing seems to happen quite regularly in more complex shaders.

    I don't know much about shaders, however this doesn't look very optimal, just an educated guess.
     
  38. Ariana1920

    Ariana1920

    Joined:
    Oct 22, 2019
    Posts:
    3
    When I imported the HDRP samples and URP samples into my Unity, all the material is pink. I don't know how to make it right I am beginner please help. Everything in Built -in samples look right.
     
  39. Amplify_Ricardo

    Amplify_Ricardo

    Joined:
    Jul 19, 2013
    Posts:
    2,389
    We don't really implement any custom solutions there, it works as Unity does depending on the shader type; as with manually coded shaders, you can adjust them if needed, even add your own #pragma directives.


    If you can share your shader with us, I'm sure our developers would be happy to provide some feedback/insights. Do keep in mind that the compiler does a lot of the heavy lifting.


    Happy to help!

    Can you confirm that HDRP or URP are working before moving to ASE?

    I recommend checking this video if you're getting started:

     
    laurentlavigne likes this.
  40. Amplify_Ricardo

    Amplify_Ricardo

    Joined:
    Jul 19, 2013
    Posts:
    2,389
    Hey folks, new VDM example, this time with a short guide.



    We would love to see this applied to other stuff, go crazy with the HDRP TV Vector Displacement Sample included with ASE. Small note, the HDRP VDM sample can easily be converted to other pipelines, including for the built-in renderer.

    Here's how you can create a full asset using Mudbox, Substance Painter and Amplify Shader Editor.

     
  41. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Would it be possible to do a speedtree-like transparency with ASE?
     
  42. gozdagb

    gozdagb

    Joined:
    Feb 23, 2014
    Posts:
    71
    Hello
    Does anyone know how to make a shader like "StencilExample" where the "window" object will be a mask behind which you will not see the wall?
    Thanks
     
  43. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Also is there a tutorial for using multiple passes? I couldn't figure it out from the example.
     
  44. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    This is such a long shot, but I am trying to implement GPUInstancing variation buffer using GPUInstancer Asset, and it tells me that I need to do :

    https://wiki.gurbu.com/index.php?ti...tances_to_have_Material_Variations_on_them.3F

    But having to manually edit shader text file everytime is not a feasible way to work with Amplify Shader Editor because it would overwrite it every time.

    Any Idea on how this may be accomplished?
     
  45. Amplify_Ricardo

    Amplify_Ricardo

    Joined:
    Jul 19, 2013
    Posts:
    2,389
    Dithering? You can do that. Not familiar with the underlying SpeedTree technique, please do elaborate on what exactly you're looking for.

    Something like this?

    upload_2020-7-27_9-45-37.png


    Try the attached sample.

    Any specific issue building it off the sample based on the available documentation?
     

    Attached Files:

  46. Amplify_Ricardo

    Amplify_Ricardo

    Joined:
    Jul 19, 2013
    Posts:
    2,389
    We actually just mentioned this a few posts ago, if you're looking to use StructuredBuffer without editing the actual template, you might be able to do it using a Custom Additional Directive; the code is not going to look pretty but it should work, just be sure to input the code there without "newlines", each line is a new entry.

    This assumes SRP, there's a few extra steps for the built-in renderer.



    With built-in rendering, it can work with templates(vert/frag) but not with Surface Shaders. You're going to need some additional work in order to get it working with Surface Shaders as they won't generate the code correctly without it.

    As an example:


    Can be replicated with:

    ("//sa" just in case of duplicates)
     
  47. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Oh, ok.. thanks.

    But how do I get access to the _Colors? Just create float4 node with name _Colors ?

    I need to do things like :

    The input struct:


    1. struct Input {
    2. float2 uv_MainTex;
    3. float4 colorVariation;
    4. };

    We use the variation buffer to modify the colorVariation property of the input struct in the vertex function:


    1. void colorVariationVert (inout appdata_full v, out Input o) {
    2. UNITY_INITIALIZE_OUTPUT(Input, o);
    3. o.colorVariation = _Color;
    4. #ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED
    5. uint index = gpuiTransformationMatrix[unity_InstanceID];
    6. o.colorVariation = colorBuffer[index];
    7. #endif
    8. }
     
    Last edited: Jul 27, 2020
  48. gozdagb

    gozdagb

    Joined:
    Feb 23, 2014
    Posts:
    71
    @Amplify_Ricardo Yes, exactly, but this work only on Forward Rendering Path, it is possible to make this for deferred?
     
    Last edited: Jul 27, 2020
  49. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Oh nevermind, I realized I have to use 3d noise for it. Is 3d perlin noise expensive on the GPU?
    I'm planning to blur the dithered edges with another pass on top of it but I couldn't figure out how to add the second shader pass. Is there a tutorial for it?
     
    Last edited: Jul 28, 2020
  50. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    @Amplify_Ricardo ,

    I have tried to implement what I need using custom expression node but I think I have found a bug within the Amplify Editor.

    Can you please contact me by saehoon@pixellore.com so I can send you the bug report?

    The bug is basically, when you do this :

    upload_2020-7-27_19-36-46.png

    You get generated code like :

    float2 uv0_MainTex = uv0 * _MainTex_ST.xy + _MainTex_ST.zw;
    In058 = uv0_MainTex;
    localMyCustomExpression58 = MyCustomExpression58( In058 );
    vertexToFrag57 = localMyCustomExpression58;

    which is an error because uv0 does not exist. It should be v.uv0.

    The same bug happens with vertex texture node, and the input becomes uv = 0 instead of uv = v.uv0