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

VertExmotion [Released]

Discussion in 'Assets and Asset Store' started by kalagaan, Oct 30, 2014.

  1. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,498
    You could also try to add a secondary sensor on the skin, with an small inflate factor (-.1) to avoid the clipping.
     
  2. Hexer_

    Hexer_

    Joined:
    Aug 25, 2016
    Posts:
    94
    Hi! Can I use VertExmotion with HDRP?
     
  3. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,498
    Yes,
    VertExmotion is compatible with HDRP,
    you'll have to use Amplify shader Editor or ShaderGraph for generating your own shader.
     
  4. Hexer_

    Hexer_

    Joined:
    Aug 25, 2016
    Posts:
    94
    I see, for example, I'll have to recreate HDRP Lit and plug VertExmotion into it?
     
  5. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,498
    Yes, the package includes an addon for shaderGraph 5.13,
    you'll have to plug it to the position input of the lit master node :)
    Here the documentation
    There's a sample shader included.
     
    Last edited: May 3, 2019
    Hexer_ likes this.
  6. Dobalina

    Dobalina

    Joined:
    Sep 6, 2013
    Posts:
    105
    Hi @kalagaan I was delighted to see this package claim shaderforge support and quickly picked it up from the asset store. Unfortunately I'm having some issues with VertExmotion + Shaderforge in Unity 2018.3.

    If I apply the shaderforge example material to the zombie character, the visuals become separated from the entity and only visible at 0.0.0 of the scene (and completely invisible at runtime)... I should note the example shaderforge material compiles with no errors.
    upload_2019-5-4_4-3-20.png
    upload_2019-5-4_4-32-45.png In the shaderforge scene, I can see the visuals at runtime, but they sit at the root of the scene as well.

    If I try to convert one of my own shaderforge shaders to use VertExmotion, the shader breaks and just goes pink with the following errors.
    Shader error in 'VertExmotion/ShaderForge/char_enemy_flesh': failed to open source file: 'Assets/VertExmotion/Shaders/VertExmotion.cginc.cginc' at line 40 (on d3d11)

    Shader error in 'VertExmotion/ShaderForge/char_enemy_flesh': failed to open source file: 'Assets/VertExmotion/Shaders/VertExmotion.cginc.cginc' at line 264 (on d3d11)

    I tried re-importing my 'Assets\VertExmotion\Shaders' folder, but didn't fix anything.

    I realize the issue probably resides in Shaderforge which has gone Opensource/Deprecated... but might you have any thoughts or suggestions?
     
    Last edited: May 4, 2019
  7. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,498
    Thank you for the feedback,
    Sorry, there's a bug in the ShaderForge function :confused:
    I'll push a fix on the assetstore

    Please copy past this function into VertExmotion.cginc (line 338) :

    Code (CSharp):
    1.  
    2. //------------------------------------------
    3. //Shader Forge function
    4.  
    5. float3 VertExmotionSF(float3 wrldXYZ, float wrldW, float3 col)
    6. {
    7.     float w = 0;
    8.     return mul(unity_WorldToObject, VertExmotionBase(float4(wrldXYZ, wrldW), float4(col, 0), w) - float4(wrldXYZ, 1)).xyz;
    9. }
    10.  
    Your shader doesn't compile because the target file is
    'Assets/VertExmotion/Shaders/VertExmotion.cginc'
    not
    'Assets/VertExmotion/Shaders/VertExmotion.cginc.cginc'

    The ShaderForge UI adds automatically the '.cginc' extension ;)
     
  8. Dobalina

    Dobalina

    Joined:
    Sep 6, 2013
    Posts:
    105
    Wonderful! This all works great. Thank you so much :)

     
    kalagaan likes this.
  9. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,476
  10. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,498
    This toon shader was made with Amplify Shader Editor, so you can easily add VertExmotion to it :)
    Have a look at the documentation.
    If you have any issue, please send me an email (contact@kalagaan.com) and I'll help you to fix it ;)
     
    Last edited: May 5, 2019
  11. ndntennisman

    ndntennisman

    Joined:
    Jan 19, 2015
    Posts:
    2
    I was wondering if this asset can be used for low poly VR scenes. Specifically in my case for use of high end mobile VR. Thanks.
     
  12. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,498
    Yes,
    VertExmotion works on mobile and is very fast, it will also work for VR. ;)
     
  13. Falagard

    Falagard

    Joined:
    Jan 8, 2014
    Posts:
    43
    I just bought VertExmotion and using the built in shaders I was able to get some good results. However, I also tried using it with Amplify Shader Editor and am getting this error any time I try adding the VertExmotion node to an ASE shader graph:

    Shader error in 'New Amplify Shader': undeclared identifier 'VertExmotionASE' at line 25 (on d3d11)

    I looked at the shader output doesn't appear to have a reference to any of the Vertexmotion inc files, and I don't know too much about node injection stuff in ASE but I can see some commented out code in VertExmotionASEParentNode that had an include path.

    I'm using 2018.3, the latest versions of VertExmotion and ASE.
     
  14. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,498
    You have to add the 'VertExmotion.cginc' path in the settings of the shader,
    have a look to the documentation ;)
     
  15. Falagard

    Falagard

    Joined:
    Jan 8, 2014
    Posts:
    43
    To avoid confusion you should probably state in your documentation that you still need to manually edit the shader generated by Amplify Shader Editor to add those lines, since the documentation doesn't mention it. Thanks!
     
  16. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,498
    You don't have to modify manually the shader, ;)
    you have to add the path of the VertExmotion.cginc file in the 'additionnal directives' in the ASE UI,
    there's a section about ASE in the documentation (p 13).
    You can also have a look to the ASE documentation.

    The ASE team has renamed the 'additionnal inludes' by 'additionnal directives' in the latest version.
    Now you can select the .cginc file from your project.

    I'll update the doc :)
     
    hopeful likes this.
  17. Alessandro-Previti

    Alessandro-Previti

    Joined:
    Nov 1, 2014
    Posts:
    30
    Hello! I am interested in your plugin, but I understand it will not work with external shaders like RealToon Shader, is it so?
     
    Last edited: Jul 3, 2019
  18. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,498
    VertExmotion is easy to include in other shaders, have a look to the documentation.
    If you need help, send me an email. ;)
     
  19. QBGROUP

    QBGROUP

    Joined:
    Feb 14, 2017
    Posts:
    3
    Hi,
    I have a rigged character that comes out from Character Creator (Reallusion).
    I need to add Vertexmotion to hair, and I need hair to move when the head rotates.
    If I move the whole character in the space, hair moves correctly, but do not move when head rotates from its bones rigging.
    How can I get the needed result?
    Thank you very much
    regards
    Marco
    upload_2019-7-8_13-41-53.png
     
  20. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,498
    Hi Marco,
    you have to drag&drop the parent bone in the sensor settings.
    In your case, it should be 'CC_Base-Head'
    The sensor will be automaticaly parented to this bone at runtime. ;)

     
    Last edited: Jul 8, 2019
    hopeful and QBGROUP like this.
  21. QBGROUP

    QBGROUP

    Joined:
    Feb 14, 2017
    Posts:
    3
    Thank you, it works perfectly!
    I noticed that the shader of the material is replaced with your shader. Is there a version of the standard shader two sided? For hair I need both sides to be rendered.
    Thank you again.
    marco
     
  22. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,498
    Here a simple 2-sided surface shader compatible with VertExmotion ;)

    You can modify it if you need more features :

    Code (CSharp):
    1.  
    2. Shader "VertExmotion/Surface_2sided" {
    3.     Properties {
    4.         _Color ("Color", Color) = (1,1,1,1)
    5.         _MainTex ("Albedo (RGB)", 2D) = "white" {}
    6.         _BumpMap("Bumpmap", 2D) = "bump" {}
    7.         _Glossiness ("Smoothness", Range(0,1)) = 0.5
    8.         _Metallic ("Metallic", Range(0,1)) = 0.0
    9.     }
    10.     SubShader {
    11.         Tags { "RenderType"="Opaque" }
    12.         LOD 200
    13.         Cull off
    14.  
    15.         CGPROGRAM
    16.         // Physically based Standard lighting model, and enable shadows on all light types
    17.         #pragma surface surf Standard fullforwardshadows vertex:vert addshadow
    18.  
    19.  
    20.         // Use shader model 3.0 target, to get nicer looking lighting
    21.         #pragma target 3.0
    22.      
    23.         #include "Assets/VertExmotion/Shaders/VertExmotion.cginc"
    24.  
    25.  
    26.  
    27.         sampler2D _MainTex;
    28.         sampler2D _BumpMap;
    29.  
    30.         struct Input {
    31.             float2 uv_MainTex;
    32.             float2 uv_BumpMap;
    33.             fixed facing : VFACE;
    34.             INTERNAL_DATA
    35.         };
    36.  
    37.         half _Glossiness;
    38.         half _Metallic;
    39.         fixed4 _Color;
    40.  
    41.         // Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
    42.         // See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
    43.         // #pragma instancing_options assumeuniformscaling
    44.         UNITY_INSTANCING_CBUFFER_START(Props)
    45.             // put more per-instance properties here
    46.         UNITY_INSTANCING_CBUFFER_END
    47.  
    48.      
    49.         void vert(inout appdata_full v) { VertExmotion(v); }
    50.  
    51.         void surf (Input IN, inout SurfaceOutputStandard o) {
    52.             // Albedo comes from a texture tinted by color
    53.             fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
    54.  
    55.             float3 n = UnpackNormal(tex2D(_BumpMap, IN.uv_MainTex));
    56.             if (IN.facing < 0)n = -n;            
    57.             o.Normal = n;
    58.  
    59.             o.Albedo = c.rgb;
    60.             // Metallic and smoothness come from slider variables
    61.             o.Metallic = _Metallic;
    62.             o.Smoothness = _Glossiness;
    63.             o.Alpha = c.a;
    64.         }
    65.         ENDCG
    66.     }
    67.     FallBack "Diffuse"
    68. }
    69.  
     
    Last edited: Jul 9, 2019
  23. Hazneliel

    Hazneliel

    Joined:
    Nov 14, 2013
    Posts:
    305
    Hello

    Just updated my project to Unity 2019 and the vertexmotion meshes are throwing errors:

    Code (CSharp):
    1. InvalidCastException: Specified cast is not valid.
    2. UnityEditor.PrefabImporterEditor.SaveDirtyPrefabAssets () (at C:/buildslave/unity/build/Editor/Mono/Prefabs/PrefabImporterEditor.cs:118)
    3. UnityEditor.PrefabImporterEditor.OnDestroy () (at C:/buildslave/unity/build/Editor/Mono/Prefabs/PrefabImporterEditor.cs:84)
    I hope you can help me with it.

    Thanks
     
  24. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,498
    Hi,
    VertExmotion is compatible with the latest version of Unity (2019.1.11).

    These errors does not come from the VertExmotion package,
    it looks like an internal error of the prefab importer. :confused:

    Maybe you've updated from a too old version of unity, and the conversion process failed.
    You could try to upgrade to an intermediate version (ex : 2018.1.5->2019.1.1->2019.1.11)

    Sorry I can't help you if there's no error from the VertExmotion package... :(

    Edit : if you're using 'VertExmotion basic' (not the pro version), check that the script used on the prefab is 'VertExmotion' not 'VertExmotionBase'
     
    Last edited: Jul 25, 2019
    Hazneliel and JBR-games like this.
  25. Hazneliel

    Hazneliel

    Joined:
    Nov 14, 2013
    Posts:
    305
    Tried to upgrade to lower versions and I get the same issue.
    This is the mesh prefab generated by Vertexmotion, there is no way to check which script it is using as it doesnt show and starts throwing that error as soon as I select it on the project explorer

    It definitely has something to do with Vertexmotion since all other assets imported correctly
     
  26. Hazneliel

    Hazneliel

    Joined:
    Nov 14, 2013
    Posts:
    305
    Im also getting this error when trying to paint the mesh, Im using Vertexmotion script and not the base. My Vertexmotion version is 1.8.5
    I get the same error in the Demo Scenes

    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. Kalagaan.VertExmotionEditor.DrawBrushMenu () (at <bcacfd59ee8b4b308cd68c6b0237cf5f>:0)
    3. Kalagaan.VertExmotionEditor.DrawPaint (Kalagaan.VertExmotionBase vtm) (at <bcacfd59ee8b4b308cd68c6b0237cf5f>:0)
     
    Last edited: Jul 26, 2019
  27. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,498
    You should try to toggle off 'use mesh reference' in the 'paint' tab
    And revert the mesh in the SkinnedMeshRenderer component.
    If you still have issues, please send me a sample (contact@kalagaan.com)
     
  28. Hazneliel

    Hazneliel

    Joined:
    Nov 14, 2013
    Posts:
    305
    I cannot toggle it off, the moment I open the paint tab it starts throwing errors and the editor gets buggy so I cannot interact with anything in the editor panel.
     
  29. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,498
    There's a way to disable it when the inspector is in debug mode.
    - Right click on the inspector tab -> switch to Debug mode
    - In the VertExmotion inspector : toggle off 'params->Use paint data from mesh color'
    - switch the inspector to normal mode

    You have also to revert the mesh reference in the SkinnedMeshRenderer to the original fbx file.
     
  30. Hazneliel

    Hazneliel

    Joined:
    Nov 14, 2013
    Posts:
    305
    Tried all this, the Use paint data from mesh color param was already off, I am using the original mesh from the fbx

    Still getting errors
     
  31. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,498
    That's weird :confused:
    Did you try to remove the VertExmotion component and add it again ?
    If you could send me a package with the prefab, I could check what's going on.

    You could try to reinstall the VertExmotion package, maybe something was corrupted in the update process.
     
    Last edited: Jul 27, 2019
  32. Qleenie

    Qleenie

    Joined:
    Jan 27, 2019
    Posts:
    851
    Hi,
    thinking about purchasing VertExmotion, already got Hair Designer, which works great. One question: Is it possible to use VertExmotion in combination with HDRP Lit Tessellation shader out of the box ? Did not see an option in shader graph to rebuild shader with tessellation in 2019.2.

    Thanks
     
  33. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,498
    VertExmotion is compatible with ShaderGraph and ASE, but there's no compatibility with the HDRP Lit shader.
    So the tessellation will only work when ASE or ShaderGraph will add the option for HDRP.
     
  34. Hexer_

    Hexer_

    Joined:
    Aug 25, 2016
    Posts:
    94
    Did anyone manage to plugin Vertexmotion into Unity's HDRP Lit shader manually?
    I opened the Lit shader's code and found that it references a vertex vert function but I can't find it anywhere.
    It's probably in one of the includes but I couldn't locate it.
    I'm using Unity 2019.2.0f1 with HDRP 6.9.1
     
  35. alanmthomas

    alanmthomas

    Joined:
    Sep 7, 2015
    Posts:
    197
    Are the HDRP shader graph nodes compatible with LWRP? I don't see any LWRP nodes in the package which is why I'm asking.
     
  36. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,498
    Yes, the nodes for ASE and shaderGraph are both compatible with HDRP & LWRP ;)
     
  37. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,498
    It's a pain to modify the Lit shader :(
    And it requires to modify the package.

    I think that the function to modify for including VertExmotion is :
    void ApplyVertexModification(AttributesMesh input, float3 normalWS, inout float3 positionRWS, float4 time)

    it's located in the file : "Runtime/Material/Lit/LitDataMeshModification.hlsl"

    I'll do some tests ;)
     
    Last edited: Aug 15, 2019
  38. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,498
    It was easier than expected :p

    Here the modification of Runtime/Material/Lit/LitDataMeshModification.hlsl (unity 2019.2.0f1)

    Code (CSharp):
    1.  
    2. #define VERTEXMOTION_ASE_HD_LW_RP
    3. #include "Assets/VertExmotion/Shaders/VertExmotion.cginc"
    4.  
    5.  
    6. // Note: positionWS can be either in camera relative space or not
    7. float3 GetVertexDisplacement(float3 positionRWS, float3 normalWS, float2 texCoord0, float2 texCoord1, float2 texCoord2, float2 texCoord3, float4 vertexColor)
    8. {
    9.     // This call will work for both LayeredLit and Lit shader
    10.     LayerTexCoord layerTexCoord;
    11.     ZERO_INITIALIZE(LayerTexCoord, layerTexCoord);
    12.     GetLayerTexCoord(texCoord0, texCoord1, texCoord2, texCoord3, positionRWS, normalWS, layerTexCoord);
    13.  
    14.     // TODO: do this algorithm for lod fetching as lod not available in vertex/domain shader
    15.     // http://www.sebastiansylvan.com/post/the-problem-with-tessellation-in-directx-11/
    16.     float lod = 0.0;
    17.     return ComputePerVertexDisplacement(layerTexCoord, vertexColor, lod) * normalWS;
    18. }
    19.  
    20. // Note: positionWS can be either in camera relative space or not
    21. void ApplyVertexModification(AttributesMesh input, float3 normalWS, inout float3 positionRWS, float3 timeParameters)
    22. {
    23. #if defined(_VERTEX_DISPLACEMENT)
    24.  
    25.     positionRWS += GetVertexDisplacement(positionRWS, normalWS,
    26.     #ifdef ATTRIBUTES_NEED_TEXCOORD0
    27.         input.uv0,
    28.     #else
    29.         float2(0.0, 0.0),
    30.     #endif
    31.     #ifdef ATTRIBUTES_NEED_TEXCOORD1
    32.         input.uv1,
    33.     #else
    34.         float2(0.0, 0.0),
    35.     #endif
    36.     #ifdef ATTRIBUTES_NEED_TEXCOORD2
    37.         input.uv2,
    38.     #else
    39.         float2(0.0, 0.0),
    40.     #endif
    41.     #ifdef ATTRIBUTES_NEED_TEXCOORD3
    42.         input.uv3,
    43.     #else
    44.         float2(0.0, 0.0),
    45.     #endif
    46.     #ifdef ATTRIBUTES_NEED_COLOR
    47.         input.color
    48.     #else
    49.         float4(0.0, 0.0, 0.0, 0.0)
    50.     #endif
    51.         );
    52.  
    53.     //-----------------
    54.     //VertExmotion
    55.     float3 worldPos = GetAbsolutePositionWS(positionRWS);
    56.     float w;
    57.     worldPos = VertExmotionBase(float4(worldPos,1), input.color, w);
    58.     positionRWS = GetCameraRelativePositionWS(worldPos);
    59.     //-----------------
    60.  
    61. #endif
    62. }
    63.  
    64. #ifdef TESSELLATION_ON
    65.  
    66. float4 GetTessellationFactors(float3 p0, float3 p1, float3 p2, float3 n0, float3 n1, float3 n2)
    67. {
    68.     float maxDisplacement = GetMaxDisplacement();
    69.  
    70.     // For tessellation we want to process tessellation factor always from the point of view of the camera (to be consistent and avoid Z-fight).
    71.     // For the culling part however we want to use the current view (shadow view).
    72.     // Thus the following code play with both.
    73.     float frustumEps = -maxDisplacement; // "-" Expected parameter for CullTriangleEdgesFrustum
    74.  
    75.     // TODO: the only reason I test the near plane here is that I am not sure that the product of other tessellation factors
    76.     // (such as screen-space/distance-based) results in the tessellation factor of 1 for the geometry behind the near plane.
    77.     // If that is the case (and, IMHO, it should be), we shouldn't have to test the near plane here.
    78.     bool3 frustumCullEdgesMainView = CullTriangleEdgesFrustum(p0, p1, p2, frustumEps, _FrustumPlanes, 5); // Do not test the far plane
    79.  
    80. #if defined(SHADERPASS) && (SHADERPASS != SHADERPASS_SHADOWS)
    81.     bool frustumCullCurrView = all(frustumCullEdgesMainView);
    82. #else
    83.     bool frustumCullCurrView = CullTriangleFrustum(p0, p1, p2, frustumEps, _ShadowFrustumPlanes, 4); // Do not test near/far planes
    84. #endif
    85.  
    86.     bool faceCull = false;
    87.  
    88. #ifndef _DOUBLESIDED_ON
    89.     if (_TessellationBackFaceCullEpsilon > -1.0) // Is back-face culling enabled ?
    90.     {
    91.         // Handle transform mirroring (like negative scaling)
    92.         // Note: We don't need to handle handness of view matrix here as the backface is perform in worldspace
    93.         // note2: When we have an orthogonal matrix (cascade shadow map), we need to use the direction of the light.
    94.         // Otherwise we use only p0 instead of the mean of P0, p1,p2 to save ALU as with tessellated geomerty it is rarely needed and user can still control _TessellationBackFaceCullEpsilon.
    95.         float winding = unity_WorldTransformParams.w;
    96.         faceCull = CullTriangleBackFaceView(p0, p1, p2, _TessellationBackFaceCullEpsilon, GetWorldSpaceNormalizeViewDir(p0), winding); // Use shadow view
    97.     }
    98. #endif
    99.  
    100.     if (frustumCullCurrView || faceCull)
    101.     {
    102.         // Settings factor to 0 will kill the triangle
    103.         return 0;
    104.     }
    105.  
    106.     // For performance reasons, we choose not to tessellate outside of the main camera view
    107.     // (we perform this test both during the regular scene rendering and the shadow pass).
    108.     // For edges not visible from the main view, our goal is to set the tessellation factor to 1.
    109.     // In this case, we set the tessellation factor to 0 here.
    110.     // That way, all scaling of this tessellation factor will still result in 0.
    111.     // Before we call CalcTriTessFactorsFromEdgeTessFactors(), all factors are clamped by max(f, 1),
    112.     // which achieves the desired effect.
    113.     float3 edgeTessFactors = float3(frustumCullEdgesMainView.x ? 0 : 1, frustumCullEdgesMainView.y ? 0 : 1, frustumCullEdgesMainView.z ? 0 : 1);
    114.  
    115.     // Adaptive screen space tessellation
    116.     if (_TessellationFactorTriangleSize > 0.0)
    117.     {
    118.         // return a value between 0 and 1
    119.         // Warning: '_ViewProjMatrix' can be the viewproj matrix of the light when we render shadows, that's why we use _CameraViewProjMatrix instead
    120.         edgeTessFactors *= GetScreenSpaceTessFactor( p0, p1, p2, _CameraViewProjMatrix, _ScreenSize, _TessellationFactorTriangleSize); // Use primary camera view
    121.     }
    122.  
    123.     // Distance based tessellation
    124.     if (_TessellationFactorMaxDistance > 0.0)
    125.     {
    126.         float3 distFactor = GetDistanceBasedTessFactor(p0, p1, p2, GetPrimaryCameraPosition(), _TessellationFactorMinDistance, _TessellationFactorMaxDistance);  // Use primary camera view
    127.         // We square the disance factor as it allow a better percptual descrease of vertex density.
    128.         edgeTessFactors *= distFactor * distFactor;
    129.     }
    130.  
    131.     edgeTessFactors *= _TessellationFactor;
    132.  
    133.     // TessFactor below 1.0 have no effect. At 0 it kill the triangle, so clamp it to 1.0
    134.     edgeTessFactors = max(edgeTessFactors, float3(1.0, 1.0, 1.0));
    135.  
    136.     return CalcTriTessFactorsFromEdgeTessFactors(edgeTessFactors);
    137. }
    138.  
    139. // tessellationFactors
    140. // x - 1->2 edge
    141. // y - 2->0 edge
    142. // z - 0->1 edge
    143. // w - inside tessellation factor
    144. void ApplyTessellationModification(VaryingsMeshToDS input, float3 normalWS, inout float3 positionRWS)
    145. {
    146. #if defined(_TESSELLATION_DISPLACEMENT)
    147.  
    148.     positionRWS += GetVertexDisplacement(positionRWS, normalWS,
    149.     #ifdef VARYINGS_DS_NEED_TEXCOORD0
    150.         input.texCoord0.xy,
    151.     #else
    152.         float2(0.0, 0.0),
    153.     #endif
    154.     #ifdef VARYINGS_DS_NEED_TEXCOORD1
    155.         input.texCoord1.xy,
    156.     #else
    157.         float2(0.0, 0.0),
    158.     #endif
    159.     #ifdef VARYINGS_DS_NEED_TEXCOORD2
    160.         input.texCoord2.xy,
    161.     #else
    162.         float2(0.0, 0.0),
    163.     #endif
    164.     #ifdef VARYINGS_DS_NEED_TEXCOORD3
    165.         input.texCoord3.xy,
    166.     #else
    167.         float2(0.0, 0.0),
    168.     #endif
    169.     #ifdef VARYINGS_DS_NEED_COLOR
    170.         input.color
    171.     #else
    172.         float4(0.0, 0.0, 0.0, 0.0)
    173.     #endif
    174.         );
    175.  
    176.  
    177.     //-----------------
    178.     //VertExmotion
    179.     float3 worldPos = GetAbsolutePositionWS(positionRWS);
    180.     float w;
    181.     worldPos = VertExmotionBase(float4(worldPos, 1), input.color, w);
    182.     positionRWS = GetCameraRelativePositionWS(worldPos);
    183.     //-----------------
    184. #endif // _TESSELLATION_DISPLACEMENT
    185. }
    186.  
    187. #endif // #ifdef TESSELLATION_ON
    188.  
    The displacement mode must be set to 'Vertex displacement' in the material settings.
    It works for the tessellation lit shader too :)
     
    Last edited: Aug 15, 2019
    Hexer_ likes this.
  39. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,498
    So it works with tessellation now :p
     
  40. alanmthomas

    alanmthomas

    Joined:
    Sep 7, 2015
    Posts:
    197
    I'm attempting to add the VertExmotion node to my shader graph, as per the instructions in the documentation, but I get the following error when I try to add the component to the game object using that material.

    Material use a non compatible shader (Shader Graphs/Grass 1), please select a VertexMotion shader in your material properties or add VertExmotion function to your custom shader.

    I'm using Unity 2019.2.0 and ShaderGraph 6.9.1 with LWRP.
     
  41. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,498
    If you didn't add the path 'VertExmotion/' in shaderGraph, you'll have this message.
    You can edit it in the shaderGraph UI, replace 'Shader Graph' (below the shader name) by 'VertExmotion'.

    you can also ignore that warning ( toggle on : Don't check shader compatibility).
     
  42. alanmthomas

    alanmthomas

    Joined:
    Sep 7, 2015
    Posts:
    197
    Thanks. I did that and those errors have gone away. I'm facing a new issue. I had been using a vertex displacement graph to modify the vertices. I disconnected all of that and replaced it with the VertExmotion node. I added the component to my game object but now the whole mesh is displaced from its position.
     
  43. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,498
    The Vertex function is weird in shader graph, the HDRP requires to substract the camera position, but not the LWRP... :confused:
    To fix it, you have to open the VertExmotion subgraph and copy the nodes to your shader, and remove the camera offset.
    It should look like this :



    If you still have issues, please send me your shader (contact@kalagaan.com), I'll have a look ;)
     
    Last edited: Aug 17, 2019
  44. alanmthomas

    alanmthomas

    Joined:
    Sep 7, 2015
    Posts:
    197
    Thanks for the assist! That has solved the displacement issues. I'm going to apply the displacement now that the shader is working. The primary reason that I am using your asset in this particular instance is for some vegetation wind displacement. The issue I've come across with other vertex displacement solutions is that normals aren't really considered so I wind up with some artifacts on the geometry that are, to say the least, undesirable. Now that the other issues are resolved, I'm going to attempt to apply some deformations and see how that goes.

    Thanks again!
     
  45. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,498
    Unfortunatly the current version of ShaderGraph doesn't allow to override the vertex normal :confused:
    I don't understand why the unity team didn't include this important feature, I hope that it will be available soon...
    So for now the normal won't be corrected :(

    The next version will include a new node for ASE, the normal conversion will be available for HDRP + LWRP.
     
    Last edited: Aug 17, 2019
  46. Hexer_

    Hexer_

    Joined:
    Aug 25, 2016
    Posts:
    94
    @kalagaan Thank you so much for helping me with Lit shader. You're the best! :D
     
    kalagaan likes this.
  47. DigitalAdam

    DigitalAdam

    Joined:
    Jul 18, 2007
    Posts:
    1,202
    @kalagaan

    Hi, I'm running Unity 2019.2.1f1 and VertexMotion 1.8.5 p5. When I apply your VertExmotion_HDRP_Metallic shader to my mesh and edit, I'm getting this result:

    screenshot.jpg

    Thoughts? Thanks.
     
  48. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,498
    I did some tests with different versions of unity (2019.2.0 & 2019.2.4) (HDRP), and it's working as expected.
    I'll test with 2019.2.1f1 asap.;)
    Does the file 'VertExmotion/Shaders/VertExmotion_editor' exist in your project?
    You could try to reimport it.

    Edit : it works with 2019.2.1f1. Could you try in an empty scene? Maybe there's a bug with another script or shader.
     
    Last edited: Sep 9, 2019
  49. DigitalAdam

    DigitalAdam

    Joined:
    Jul 18, 2007
    Posts:
    1,202
    Hi, so 'VertExmotion_editor' does exist and rebuilt it. No luck. Tried it in a new scene, no luck.

    Created a new project, 2019.2.1f1.
    It has Shader Graph 6.9.0.

    Here are the steps I took with the new scene:
    Installed latest VertExmotion.
    Imported 'VertExmotion_ShaderGraph_5_13'
    Opened the Shader Graph 'VertExmotion_HDRP_Metallic'
    I get the following error:

    screenshot.png

    The 'VertExmotion_HDRP_Metallic' preview is pink, and when I add it my a capsule mesh the mesh vanishes.

    Tried the same things with 2019.3 as above, shader is not pink, but when I assign VertexMotion to a mesh, I get this result:



    Thoughts?

    UPDATE: I opened my original scene and it looks like if I shut off the lighting in the Scene View using the light-bulb icon on that Scene View window, it works correctly. When I enable lighting it had some transparency issues, both within the Scene View and in the Game windows.
     

    Attached Files:

    Last edited: Sep 10, 2019
  50. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,498
    You could replace the suggraph in the shader.
    - open the shader with ShaderGraph
    - open the subshader (double click)
    - copy the nodes
    - in the shader graph, delete VertExmotion_SubGraph
    - paste the nodes and connect the output to the 'Position' input of the PBR Master node
    - Save the shader

    It should look like that :