Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[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. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,221
    How do i define a texture that's only accessible via SetGlobal but doesn't show up in inspector?
    And is it faster to send to the GPU a texture as an influence map (mask map between 3 textures) or an array of int or float or whatever defines 3 values?
     
  2. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,221
    missing: tooltips in texture sample parameters
    upload_2020-9-14_23-47-20.png
     
    syscrusher likes this.
  3. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,221
    unity 2020.1.4
    camera set in forward or deferred
    following the doc i turned on instanced terrain on the master node but it's glitching with and without outline
    upload_2020-9-15_15-38-55.png
    upload_2020-9-15_15-39-7.png
    without instanced terrain on the terrain component:
    upload_2020-9-15_15-39-53.png
     

    Attached Files:

  4. Roman-Ilyin

    Roman-Ilyin

    Joined:
    Oct 9, 2013
    Posts:
    29
    upload_2020-9-16_18-53-5.png Hello. Could you please explain how to use texture array (Albedo + Normal + AO/Height/Roughness) with Triplanar Sampler? (height based splatmap blending for terrain) I would like to blend 4 layers.

    What I'd like to do is reuse the same sampler with multiple textures in texturearray.
    I'm working on a custom triplanar Terrain shader.
    I can set Texture Samplers' Mode to Reference, but it doesn't works with Triplanar Samplers.
     
    Last edited: Sep 17, 2020
  5. Amplify_Ricardo

    Amplify_Ricardo

    Joined:
    Jul 19, 2013
    Posts:
    2,387
    Thanks for the details but unfortunately we're unable to replicate the issue on our side.
    Can you forward us a simple project sample(full project, can be a new one with just ASE) to support@amplify.pt

    Might not support SSR, what shader type is this?

    Thanks, we appreciate any tips!

    We're due for a wiki update, I'll make note of that.

    By default, it shouldn't appear on your Inspector; what do you have on your side?

    I suppose with the texture you have an extra sampler, go with other existing values if that's something that works for your specific case.

    Well, they aren't missing, their just aren't any :p

    Press F1 with the node selected to open the appropriate wiki page.


    For reference, what doc did you follow?

    The shader you shared is not a Terrain shader, it just has the Instanced Terrain option toggled; how are you using this?

    Sorry for the confusion, but that's not possible; the Triplanar Node only takes in Texture Object nodes.

    That node is there for your convenience, it does not support all possible triplanar aplications. For full control, you will have to set it up manually; we include a built-in sample for this called TriplanarProjection.

    Hope it helps!
     
    syscrusher likes this.
  6. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    1,123
    What is the idea behind Additional Options at the top of the shader for URP shaders? You can edit the surface type, Two Sidedness, etc... but It seems like these options just drive the properties bellow.

    This is a one way relationship, so you end up in situations where you edit the properties bellow, but now it does not reflect the set values in Additional Options. Ie Additional Options > Two Sided set to Cull Front, but then scroll down and set Sub Shader > Cull Mode to Back. Now they are out of sync.

    This is confusing and error prone? The intent isn't clear. And when I open up a shader that a colleague has worked on, it's not clear what their intention was. Which is the correct value?
     
  7. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,792
    It's a Standard Surface. I think it's the transparent not working with SSR, when I use opaque I can kinda see it but it's not very visible. I have to figure out how to make the effect more intense but I guess I might have to do that by resorting with a trick perhaps. If you have any leads or tips I would like to know them :) Overall my water shader is satisfactory.
     
  8. Amplify_Ricardo

    Amplify_Ricardo

    Joined:
    Jul 19, 2013
    Posts:
    2,387
    Our apologies for the confusion, you've actually stumbled onto a sort of transitional change in ASE due to the ever changing nature of URP and the other SRP's.

    Those additional options are there to offer you common toggles similarly to some of the parameters offered by Shader Graph. What's going to happen in the future is that the options below will be removed or adapted, they are a remnant of our original template.

    Most users don't dig down but we intend to remove those duplicates in order to avoid any confusion; sadly it's not a simple manner of changing the UI or adding a few flags, it's a bit more involved.


    Sorry, not really sure as it should work out of the box. Can you send a sample to support@amplify.pt?

    Thanks!
     
  9. Amplify_Ricardo

    Amplify_Ricardo

    Joined:
    Jul 19, 2013
    Posts:
    2,387

    Apologies for the delay, here's our dev insight:

    What happens is exactly what you're describing. The shadowcaster pass is rendered with different camera parameters, like having a camera from the light's point of view. So the Object To Clip Pos node will generate a clip position is regards to the shadowcaster and not the main camera thus the final screen position will be incorrect.

    Something that might work is to calculate the model view projection matrix ( object to clip ) of the main camera over a c# script and send it to the shader. Over there, it calculates the clip position using that matrix thus resulting on a screen position value relative to the main camera.

    The c# script would be something like this:
    Code (CSharp):
    1. using UnityEngine;
    2. public class AphaClipParams : MonoBehaviour
    3. {
    4. private Camera m_mainCamera;
    5. private MeshRenderer m_meshRenderer;
    6. private Transform m_transform;
    7. void Start()
    8. {
    9. m_mainCamera = Camera.main;
    10. m_meshRenderer = GetComponent();
    11. m_transform = transform;
    12. }
    13. void Update()
    14. {
    15. Matrix4x4 mat = m_mainCamera.projectionMatrix * m_mainCamera.worldToCameraMatrix * m_transform.localToWorldMatrix;
    16. m_meshRenderer.material.SetMatrix( "_CustomMVP", mat );
    17. }
    18. }
    19.  
    20.  
    Regarding the shader, it should be something like this:
     
  10. b1gry4n

    b1gry4n

    Joined:
    Sep 11, 2013
    Posts:
    146
  11. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,792
    Sent to the support email, ignore the pm, I didn't notice the email link at first! :)
     
  12. _6__

    _6__

    Joined:
    Jul 13, 2015
    Posts:
    11
    Is there a way to get access to the final real-time ShadowMap texture? Apparently there is a _ShadowMapTexture that can be used, but the output is just grey for me.
     
  13. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Is it possible to view a mesh in Unity with its surface as it appears on its flat UVs like this?
    Someone suggested I rewrite vertex shader using UV positions as so:
    o.vertex = float4(v.uv.x-0.5, -v.uv.y+0.5, 0, 0.5);
    But I have no idea how to do that in ASE.

     
    Last edited: Sep 21, 2020
  14. Amplify_Ricardo

    Amplify_Ricardo

    Joined:
    Jul 19, 2013
    Posts:
    2,387
    That looks really nice, do you have a Twitter account we can follow?

    Thanks, we will check it as soon as possible.


    You can access those texture by setting your Texture Sample node to Global; _ShadowMapTexture use requires additional steps. As this is beyond our editor, I would recommend examining additional resources such as the guide or post below.

    Guide: https://catlikecoding.com/unity/tutorials/rendering/part-7/
    Reference post: https://forum.unity.com/threads/access-_shadowmaptexture-in-surface-shader.619369/


    I think you need to manipulate the actual mesh with additional C#, do you have a reference we can look at so we can get a better idea of what you're looking to achieve?

    Thanks!
     
    florianalexandru05 likes this.
  15. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    It will work as a display to show the light/shadow information as well as the environment reflection of a models entire surface on its UV space.
    For example on spherical models like earth it looks like this.
     
  16. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    It's ok I figured it out.
     
    Amplify_Ricardo likes this.
  17. Amplify_Ricardo

    Amplify_Ricardo

    Joined:
    Jul 19, 2013
    Posts:
    2,387
    Additional scripts?
     
  18. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Nope, just 2 nodes actually. And the inbuild ASE option for absolute vertex positions.
     
  19. Amplify_Ricardo

    Amplify_Ricardo

    Joined:
    Jul 19, 2013
    Posts:
    2,387
    Ah ok, good to know that method worked, I was a bit reluctant to recommend something like that.
     
    Cactus_on_Fire likes this.
  20. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,104
    I have a couple of questions about the APIs (I'm still refining those custom nodes I've been working on -- I have one almost done now).

    To add a preview to my custom nodes, I've been examining the code for standard nodes, and I see that there is a GUID for the preview shader. This doesn't seem to be documented on the Wiki (or else I've overlooked it), but as best I can discern from examining the code, the GUID value for a new node is not the Unity GUID of an asset file in the project, but rather in this case is just a UUID that has a statistically-insignificant probability of collision with any existing or future nodes. In other words, the UUIDs in the existing nodes are randomly-generated unique hashes that do not act as search keys to any other entity. Is that a correct assumption on my part?

    Also, is there a standard C# compile-time flag that ASE defines, which I can use for conditional compilation inside my code to allow the rest of my code to compile even on a system where ASE is not installed? Or will I need to make a separate assembly definition and isolate the part of my code that interacts with ASE?

    EDIT: Please ignore the remainder of this post for the moment -- I just noticed a bug in my code, and I'll fix that and see if my question is no longer needed. :)

    Finally, I have observed that all (or nearly all) of the standard nodes include this code fragment:

    Code (CSharp):
    1. public override string GenerateShaderForOutput(int outputId,
    2.     ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar)
    3. {
    4.     if (m_outputPorts[0].IsLocalValue(dataCollector.PortCategory))
    5.     {
    6.         return GetOutputVectorItem(0, outputId,
    7.             m_outputPorts[0].LocalValue(dataCollector.PortCategory));
    8.     }
    9.     // ... my custom method body goes here ...
    10. }
    I've replicated that into my custom nodes, but in testing I have found that the condition is always false, and the rest of my generate method is executed every time. What testing conditions should I create that would cause the conditional expression to evaluate true? Does having it always false indicate I have a problem elsewhere in my code, or is this statement handling an edge case that may simply not be occurring in my testing so far? Furthermore, are there any situations in which a node should not include this logic?

    This may nor may not be relevant, but I notice that my generate method is being invoked for each shader pass (including META). Should it have been retrieving the generated code from cache, or is it normal for ASE to generate each node for each pass because the resulting code might not always be the same?

    Below is a stub implementation of this method in my node. When I mentioned my node is "almost" done, what I mean is, the rest of the node is working in the ASE user interface, and I have the shader code itself fully debugged in a hand-coded shader -- the remaining work is to migrate my shader code into this method so the node can generate it. In my shader, the code is always there and conditional logic determines the execution path, but in ASE I can further optimize by not even generating code for situations where some input ports can never influence the output (i.e., "If the user sets ABC option in the node parameters, that means only input ports 0 and 3 determine the output, and inputs 1 and 2 are ignored" -- that sort of thing).

    For context, the output of my node is always representing a color, although as with other such nodes it can adapt to present RGB, RGBA, FLOAT3, or FLOAT4 depending on what's connected to its outputs. Also like other ASE color-generating nodes, the node always provides the R, G, B, and A components (or X, Y, Z, and W, as appropriate) as output ports 1 through 4 inclusive.

    Code (CSharp):
    1. public override string GenerateShaderForOutput(int outputId,
    2.     ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar)
    3. {
    4.     if (m_outputPorts[0].IsLocalValue(dataCollector.PortCategory))
    5.     {
    6.         Debug.Log("Local value found -- generate logic skipped");
    7.         return GetOutputVectorItem(0, outputId,
    8.             m_outputPorts[0].LocalValue(dataCollector.PortCategory));
    9.     }
    10.  
    11.     string result = String.Empty;
    12.     string localVarName = "myCustomNodeNameVar" + UniqueId;
    13.     // Populate the value for port 0 (the Color or Vector4 combined
    14.     // result) if not already done
    15.     if (!m_outputPorts[0].IsLocalValue(dataCollector.PortCategory))
    16.     {
    17.         // STUB -- just returns a uniform color
    18.         result = "float4(0.5, 0.5, 0, 1)";
    19.         result = UIUtils.AddBrackets(result);
    20.         // END STUB
    21.         dataCollector.AddLocalVariable(UniqueId, CurrentPrecisionType,
    22.             m_outputPorts[0].DataType, localVarName, result);
    23.          Debug.Log("Generated port 0 result:\n" + result);
    24.     }
    25.  
    26.     if (outputId == 0)
    27.     {
    28.         // Just return the variable we defined
    29.         result = localVarName;
    30.     }
    31.     else
    32.     {
    33.         // These will be the individual RGBA components from the main port
    34.         result = GetOutputVectorItem(0, outputId, localVarName);
    35.     }
    36.  
    37.     Debug.Log("Retrieved port " + outputId + " result from port 0:\n" + result);
    38.     return result;
    39. }
    In any case, my plan to optimize the code generation is why this method is currently a stub, as I needed to get the UI working first. :)

    The shader code I generate looks like this after ASE has embedded it:

    Code (HLSL):
    1. float4 myCustomNodeNameVar25 = ( float4(0.5, 0.5, 0, 1) );
    2. surfaceDescription.Color = myCustomNodeNameVar25.rgb;
    In my test shader, my custom node is #25. My node is connected to the Color input on an HDRP Unlit master node. Trivial as this stub may be, although I was expecting that boilerplate conditional to sometimes evaluate true and skip my logic, the generated code is as I expect and the shader (such as it is) correctly renders as a uniform color.

    P.S. -- I love ASE, as you know, but it would be nice to have some brief comments in code to state the purpose of important data members and methods. Since the Wiki itself indicates the API page is outdated, and there are few in-code comments, developers are forced to trace through unfamiliar code to discern this basic info on our own.

    Thanks!
     
  21. tonycoculuzzi

    tonycoculuzzi

    Joined:
    Jun 2, 2011
    Posts:
    301
    hey all, just ran across an issue:

    it appears as if the Indirect Diffuse Light node ignores all Normal/World Normal input values. No matter which value I input, the result stays the same with no visual/output indication that normal calculation has changed.

    An empty input looks the same as an input of 0, which looks the same as an input of 1, etc
     
  22. b1gry4n

    b1gry4n

    Joined:
    Sep 11, 2013
    Posts:
    146
    I was able to implement basic signed distance field raymarching in urp with a custom render pass, amplify, and custom nodes! I setup a system that updates gameobject transform matrix in the shaders so these objects can move/rotate. The shape is a non uniform scaled sphere with noise applied! Pretty new to raymarching/shaders in general, but its pretty cool it works in conjunction with amplify


     
    Last edited: Sep 23, 2020
    Squize, syscrusher and Cactus_on_Fire like this.
  23. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    thats awesome!
     
    b1gry4n and syscrusher like this.
  24. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,104
    Looking at the inset screen shot of the two elongated groupings, I wonder if this system could be adapted to render realistic clouds?
     
  25. b1gry4n

    b1gry4n

    Joined:
    Sep 11, 2013
    Posts:
    146
    That is my end goal that Im aiming for. I wanted a way to be able to shape and position raymarched clouds, but also be able to easily modify the output of the raymarch in amplify. What I am starting to realize is that it could be used for more than clouds especially if you consider the possibility of baking sdf into texture3d. You could use CSG tools to combine and bake a mesh to keep its mesh collider, then bake that into a sdf file, disable the mesh renderer, and let the raymarching render it while also having physics interaction with the underlying mesh collider. I just tested it with amplifys triplanar node and it works out nicely

    Heres a video showing more of it if youre interested: https://www.reddit.com/r/Unity3D/comments/iyhax6/basic_implementation_of_ray_marched_signed/
     
    Last edited: Sep 23, 2020
  26. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Can it capture the SDF of skinned meshes in realtime too? You can make crazy things like liquidy or dough looking characters.
     
  27. b1gry4n

    b1gry4n

    Joined:
    Sep 11, 2013
    Posts:
    146
    I was going to experiment with this. IDK about capturing in real time, but Im guessing you could bake out a set of tex3d "frames" using a SDF baking tool (like this: https://github.com/xraxra/SDFr) and then play them back like a flipbook, frame by frame. Not sure about how well that would perform or if there might be a better way, but it was one idea that popped up. You obviously wouldnt be able to use IK and stuff on the animation. It would be most similar to baking animations for gpu instancing. For simple things it might look pretty cool. If it works you for sure could make doughy liquid characters, or even volumetric characters
     
  28. Amplify_Ricardo

    Amplify_Ricardo

    Joined:
    Jul 19, 2013
    Posts:
    2,387

    Hello there,

    As we mentioned via PM, we've been a bit overloaded hence our delayed reply. One of our devs has already started to improve the available documentation. Let us know if there's any other point you'd like to see covered first, we can definitely try to go in that direction.

    http://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Shader_Editor/API#Adding_previews


    How are you using it? (screenshot or shader)

    That's really cool, nice work!
     
  29. MechaWolf99

    MechaWolf99

    Joined:
    Aug 22, 2017
    Posts:
    293
    Hello,
    I have been trying to make some stylized grass, I am having a problem where my grass normal and terrain normal seem to diverge as the angle of the terrain gets steeper.

    To be more specific, I am using instancing to spawn grass on a mesh that I use as the terrain. The the points where the grass is instanced are gotten through raycasting the terrain mesh. The grass shader has a vector3 instance property "UpVectorNormal", that is set to the normal of the terrain at the raycast hit point (RaycastHit.normal).

    If I plug the World Normal of the terrain shader in to it's Albedo (and have no other nodes connected to the master node), and then connect the "UpVectorNormal" to the grass shader's Albedo (again with nothing else connected). It looks as expected, both being the exact same color. But when the terrain is at a slight angle, the collors become slightly different.

    I'm not sure how to solve this. If more info is needed or something please let me know.

    I should also mention incase I am wrong about something, this image demonstrates what I am trying to solve (grass is different color than terrain in some spots). I believe that the solution to this is to get the normals to be the same, thus this comment.
     
  30. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    340
    Hi, any idea what this purple "AxisSign" node is? Thanks!
     

    Attached Files:

    • C1.png
      C1.png
      File size:
      975.1 KB
      Views:
      319
  31. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,104
    Terrific response! I've been reviewing the new documentation, and although you refer to it as preliminary, it already has improved my understanding considerably. Thanks!
     
    Amplify_Ricardo likes this.
  32. b1gry4n

    b1gry4n

    Joined:
    Sep 11, 2013
    Posts:
    146
    Axis sign is a custom node. Input world normal, output float3

    axisSign = worldNormal < 0 ? -1 : 1;

    I learned about it when I was learning triplanar mapping from BGolus : https://github.com/bgolus/Normal-Mapping-for-a-Triplanar-Shader

    If you just use sign it can potentially output 0

    If you look at the graph, that part isnt even connected. I disconnected it and forgot to delete it before posting the image.

     
    Last edited: Sep 26, 2020
  33. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,221
    [REQUEST] tooltip in the output node and every other inspector
    because it's 2020
     
    syscrusher likes this.
  34. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,221
    how do i make an object or its shader so it's lit by vertex lights?
    like for example a nearby fire which light is set to Not Important, it should at least light up the polygons of the terrain or even the rock instances

    What I find is that vertex lights are very dim so I'm wondering if there is a way to write a shader that takes that into account and boosts the light
     
    Last edited: Sep 27, 2020
  35. Amplify_Ricardo

    Amplify_Ricardo

    Joined:
    Jul 19, 2013
    Posts:
    2,387
    Not really sure what could be happening on your side, it's not something I've done so I wont be able to assist you. Perhaps someone on our Discord channel can help out: https://discord.gg/83GRuw

    Sorry about that, definitely something we should add at some point; sadly core dev just eats up our time like there's no tomorrow.


    Sounds very specific, what exactly are you asking? Shaders have limited access to information, I suppose it depends on what we're talking about.
     
  36. Amplify_Ricardo

    Amplify_Ricardo

    Joined:
    Jul 19, 2013
    Posts:
    2,387


    By the way, don't forget to check the latest package on our website, we include a sort of cross section sample; it was requested a while back if I'm not mistaken.
     
  37. rboerdijk

    rboerdijk

    Joined:
    Aug 4, 2018
    Posts:
    96
    Hello,

    I have an asset with a ShaderGraph-shader intended for use in builtin which I'd like to try and switch to URP:
    upload_2020-9-28_19-7-52.png

    So my first step is switching to URP/PBR...
    upload_2020-9-28_19-5-17.png

    ... which however results in an error "Shader error in 'xxx': redefinition of 'uv_Albedo' at line 498 (on d3d11). " which is factually correct, as the generated shader looks like this:

    upload_2020-9-28_19-2-4.png

    The marked lines are identical (and it does redefine uv_Albedo), but it doesn't look like 'inbetween' code could influence the result, so recalculating it seems senseless (and even if, then it could do without redefining)...
    Removing the 2nd line manually 'solves' the error, but changing anything else causes the shader to be regenerated so the error returns. Any tips why this is happening?

    Using shadergraph 1.8.5 and Unity 2019.4.8f1.
    Warning: ShaderGraph newbie here.
     
  38. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,221
    In short: in shaders, what control do we have over vertex lighting?
     
  39. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,104
    First, are you using ShaderGraph or are you using Amplify Shader Editor? ASE is a third-party tool (and IMO a good one, else I wouldn't use it), whereas ShaderGraph is from the Unity folks and is supported on its own forum threads. :)

    Assuming you're using ASE: I've seen this occasionally in my shaders, usually due to me having some stray nodes in the graph that don't contribute to the output. If you can share your node graph, I can take a look here in a sandbox project. Alternatively, try cleaning up any stray nodes you added just to try things out. Normally that's okay, but on rare occasions I've seen ASE's code generator get confused and replicate a variable.

    Also check any variables you define (with "Register" nodes, or with the auto-register checkbox in input nodes) to make sure you don't actually have a doubly-defined variable that somehow slipped through the error-checking logic in the node editing tool.
     
    Amplify_Ricardo likes this.
  40. rboerdijk

    rboerdijk

    Joined:
    Aug 4, 2018
    Posts:
    96
    Yeah, I mean Amplitude Shader Editor :) (I was so careful to list the correct versions, and ended up with the wrong name - woops)

    When you switch to Universal/URP the "Translucency Color" becomes disconnected, so additionally I enabled the checkbox in the master-node, and then reconnected it. That didn't solve the issue though. I moved all nodes around a bit to see if anything was disconnected but didn't spot anything.

    I tried looking through all nodes to see if any had "Auto-Register" checked but didn't spot any either. Not entire sure how to check for "Register nodes" - as said, newbie with ASE.

    Thanks for your kind offer, the shader is attached. I'll also continue looking to see if I can figure something out.
     
    Last edited: Sep 30, 2020
  41. Amplify_Ricardo

    Amplify_Ricardo

    Joined:
    Jul 19, 2013
    Posts:
    2,387
    You can run your calculation and plug them into a Vertex To Fragment node, however they'll be interpolated. On of our devs notes that we can actually make a small adjustment to this node to improve this on the future.

    http://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Shader_Editor/Vertex_To_Fragment

    As always, if you need absolute customization, you will eventually have to dig into Shader Templates.
     
  42. Amplify_Ricardo

    Amplify_Ricardo

    Joined:
    Jul 19, 2013
    Posts:
    2,387
    Hey there, welcome aboard!

    I tested your shader and I'm not seeing the same error. Would it be possible to test the faulty version you took the screenshot from?

    Thanks!
     
  43. RegdayNull

    RegdayNull

    Joined:
    Sep 28, 2015
    Posts:
    65
    Hi.
    If I wanna add some custom fog in amplify shader. How can I do it? In Unity surface shader I have directive finalcolor, but I can't find somethhing like that on Amplify Wiki.
     
  44. Amplify_Ricardo

    Amplify_Ricardo

    Joined:
    Jul 19, 2013
    Posts:
    2,387
    Hey there, what exactly do you need?

    Perhaps our Terrain Sample can point you in the right direction.
    upload_2020-9-29_13-55-25.png
     
  45. rboerdijk

    rboerdijk

    Joined:
    Aug 4, 2018
    Posts:
    96
    Sure, to be clear, the shader attached to my previous post was before switching to URP (which does work without error). Only after switching does the error occur. Changed it URP now and reposting it in this attachment.

    Update: removed the shader, as there is a workaround. If it was still needed for an official investigation by anyone from ASE let me know and I'll supply via PM.
     
    Last edited: Sep 30, 2020
  46. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,104
    I'm looking at your shader now in a URP project, and the error does replicate for me.

    One thing I've noticed, which may or may not be a problem but which strikes me as unusual, is that the vertex output data structure doesn't contain any member with the NORMAL semantic, but the VertexInput does. That's surprising to me because you are using the output of the normal map sampler as an input to the master node, but I'll defer to the Amplify folks on whether this is a problem or simply a result of some internal optimization where ASE doesn't need it here (perhaps because it's already in one of the standard UNITY includes).

    Code (HLSL):
    1.             struct VertexOutput
    2.             {
    3.                 float4 clipPos : SV_POSITION;
    4.                 float4 lightmapUVOrVertexSH : TEXCOORD0;
    5.                 half4 fogFactorAndVertexLight : TEXCOORD1;
    6.                 #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
    7.                 float4 shadowCoord : TEXCOORD2;
    8.                 #endif
    9.                 float4 tSpace0 : TEXCOORD3;
    10.                 float4 tSpace1 : TEXCOORD4;
    11.                 float4 tSpace2 : TEXCOORD5;
    12.                 #if defined(ASE_NEEDS_FRAG_SCREEN_POSITION)
    13.                 float4 screenPos : TEXCOORD6;
    14.                 #endif
    15.                 float4 ase_texcoord7 : TEXCOORD7;
    16.                 UNITY_VERTEX_INPUT_INSTANCE_ID
    17.                 UNITY_VERTEX_OUTPUT_STEREO
    18.             };
    19.  
    Back to your original error, it doesn't look to me as if you have anything incorrect, so I wasn't able to quickly solve the problem -- but I do have a possible workaround for you. Adding an explicit texture coordinates reference to your node graph (see screen shot below) makes it compile cleanly for me. The defaults for that node should be retrieving the corresponding data from the template/inspector. Note that the Reference dropdown does not choose the _Albedo input, but rather remains at the default. (BTW, ignore the fact that I renamed _Albedo to _Albedo_ZZZ in my testing -- I was checking to make sure it wasn't a name conflict with a predefined variable from the template or a Unity URP include file.)

    upload_2020-9-29_12-50-18.png
     
    rboerdijk likes this.
  47. rboerdijk

    rboerdijk

    Joined:
    Aug 4, 2018
    Posts:
    96
    That works... !

    After changing it, I also noticed the original shader does an alpha cutout, so I connected the Albedo-alpha to output-Alpha and that seems to be another way to avoid the error (also without the Explicit Textures Node!).

    Thanks for taking the time look into this!
     
    syscrusher likes this.
  48. MechaWolf99

    MechaWolf99

    Joined:
    Aug 22, 2017
    Posts:
    293
    I did some more testing, and when I display the normal of the terrain that is set per grass instance, while in the standard lighting model. I get the expected result, with the normal displayed in the grass matching the terrain.



    But when I switch to custom lighting, the normal is displayed differently.


    Why is it different in the two lighting models?

    Maybe my real question would be more along the lines of how do you set the normal used for lighting in the shader?
     
  49. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,104
    That's interesting -- I'll do some further testing here.
     
  50. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,792
    I've been trying to replace the terrain grass shader "Waving Double Pass" and it works but the problem is it only works for one texture. If you add a new grass texture to the terrain it uses the same texture. Does anyone have any idea how the terrain grass works? It would be awesome if I could replace it with my own shader! I suspect it's some texture array or maybe got to do hard coding?

    Replacing the shader is easy, just name any shader "Hidden/TerrainEngine/Details/WavingDoublePass"

    Screenshot_15.jpg