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

[RELEASED] DirectX 11 Grass Shader

Discussion in 'Assets and Asset Store' started by Nonakesh, Aug 17, 2015.

  1. Nonakesh

    Nonakesh

    Joined:
    Aug 27, 2011
    Posts:
    576
    Apparently it does not, you were the first to try it. If you send me your invoice number via PM I can give you a refund, if you want.

    It looks like there's a bug there, I'll look into it!

    Is this still on Mac? In this case that's probably to be expected. The floor not rendering is as intended, you need a second object for that (so you can have a separate shader for the floor, instead of being bound to the one hard coded in the shader)
    The grass is probably still Unity terrain's grass, I think? If not you should try one of the example materials, or play around with the settings. If you need help you could also ask here!

    Exactly!

    Even if the shader had a second pass internally, it would still result in the terrain being rendered twice (well it might have some slight advantages, but I still think the current solution is better). If you have extreme performance problems, you could try using the Terrain Converter to create a mesh instead, maybe that helps.

    Does this happen in OpenGL Core, or in regular DirectX Mode?

    Sorry, sometimes life comes between me and answering support questions. I try to answer all questions and look into all problems, but it's sometimes difficult.

    Alright, now that's strange... It looks like you have two objects with the same material, in the same spot... if that's not the case, can you send me your scene via PM? With your shader version, GPU etc.
     
  2. coen22

    coen22

    Joined:
    Aug 27, 2013
    Posts:
    31
    OpenGL on Mac. Though I have seen it work in v1.7.0 on my mac, though it wasn't stable.
    I'm getting much less errors in 1.8.1, however now it doesn't work anymore at all.
    But I've seen similar errors from other geometry/tessellation shaders.

    [EDIT]
    This was on Mac in the editor. v1.7.0
     
  3. Nonakesh

    Nonakesh

    Joined:
    Aug 27, 2011
    Posts:
    576
    To be honest this is mostly dependent on Unity's cross compiler, there's not much I can do about it... Honestly I'm not sure where the difficulties are, whenever I tried OpenGL Core compilation it was incredibly slow and didn't work to well in general. I guess it's just not a big priority for them.
     
  4. Nonakesh

    Nonakesh

    Joined:
    Aug 27, 2011
    Posts:
    576
    I just fixed the vertex density bug, it should be on the Asset Store in the next few days.

    Here's the changelog for consistency. 1.8.2:
    • Fixes vertex density.
    If you want the update right now, just send me your invoice number via PM.

    Edit:
    Actually, if you don't want to wait at all, just fix it yourself, it's really simple, just insert these lines:

    GrassDefinitionsAndFunctions.cginc, Line 167:

    Code (CSharp):
    1. #ifdef VERTEX_DENSITY
    2.     fixed4 color : COLOR;
    3. #endif
    GrassVertex.cginc, Line 16:

    Code (CSharp):
    1. #ifdef VERTEX_DENSITY
    2.     o.color = v.color;
    3. #endif
     
  5. coen22

    coen22

    Joined:
    Aug 27, 2013
    Posts:
    31
    Yes, that was also my conclusion.
    I sent them a bug report and they said it'd be fixed in 2017.2.0. Though that was not the case.
    The bug was closed, but never fixed. https://fogbugz.unity3d.com/default.asp?947829_s2aa3obcs7ia1lit
     
  6. Nonakesh

    Nonakesh

    Joined:
    Aug 27, 2011
    Posts:
    576
    Thanks, you just saved my quite a lot of work... Now I know I won't actually be able to fix this bug. Well, not directly, anyways. I've been thinking about adding deferred rendering to the shader again, that might work on Mac as well. No promises about when, though.. It would be a rather big update.
     
  7. coen22

    coen22

    Joined:
    Aug 27, 2013
    Posts:
    31
    UBER (https://assetstore.unity.com/packages/vfx/shaders/uber-standard-shader-ultra-39959) made a workaround with rewritten cginc includes from Unity, but I don't know why this one does work.

    [EDIT] This is the real issue

    -------- GLSL link error: ERROR: Input of fragment shader 'gs_COLOR1' differs in type/qualifiers to that written by geometry shader

    WARNING: Output of geometry shader 'gs_TEXCOORD7' not read by fragment shader
    WARNING: Output of geometry shader 'gs_TEXCOORD4' not read by fragment shader
    WARNING: Output of geometry shader 'gs_TEXCOORD3' not read by fragment shader
    ERROR: Input of fragment shader 'gs_COLOR1' not written by geometry shader
    ERROR: Input of fragment shader 'gs_TEXCOORD2' not written by geometry shader

    When compiled to openGL the gs_TEXCOORDs no longer match up.

    WARNING: Output of tessellation control shader 'hs_patchREALTESS0' not read by tessellation evaluation shader
    WARNING: Output of tessellation evaluation shader 'ds_TANGENT2' not read by geometry shader
    WARNING: Output of geometry shader 'gs_TEXCOORD7' not read by fragment shader
    WARNING: Output of geometry shader 'gs_TEXCOORD4' not read by fragment shader
    ERROR: Input of fragment shader 'gs_TEXCOORD3' differs in type/qualifiers to that written by geometry shader
    ERROR: Input of fragment shader 'gs_TEXCOORD3' not written by geometry shader

    Here the types don't match up
     
    Last edited: Dec 13, 2017
  8. Nonakesh

    Nonakesh

    Joined:
    Aug 27, 2011
    Posts:
    576
    Well, I guess that would work, but I'd have to maintain that file for every version of Unity.. I guess I could replace that one function instead. Honestly I think it's a bit ridiculous that one of their own lighting functions straight up doesn't work, but I'll look into it.
     
  9. coen22

    coen22

    Joined:
    Aug 27, 2013
    Posts:
    31
    I openend a new bug https://fogbugz.unity3d.com/default.asp?978279_93f8p62nqm81391t
    This was tested with the very latest beta version.
     
    Nonakesh likes this.
  10. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
  11. Dolzen

    Dolzen

    Joined:
    Mar 26, 2014
    Posts:
    90
    Hello Nonakesh!

    Ok I'm having this issue for a while now, here is the thing:

    Using Grass version 1.8.2
    Unity version 2017.2.0p2

    Problem: The more the mesh vertices the more the grass density no matter the density mode selected.

    My terrain is made of tiles and not all the tiles have the same number of vertices, some of them have 4 vertices and some other tiles have 10 or 12. So this is a problem because some of my tiles have more vertices and therefore that tile have more grass density and it makes the terrain grass looks odd and not seamless.

    As you can see in the image below I'm using the same settings for each tile and the more the vertices the more the grass density using Density mode "Value based density" or "Texture density"



    How to reproduce behaviour:

    1.- Create a new unity project and import your grass shader version 1.8.2
    2.- Create a new game object and add QuadGenerator component (Code is in the end of the reply)
    3.- Click Generate in the component using sizes 2, 4 or 8 for number of vertices. (This will add a mesh filter and mesh renderer too.
    4.- create a new material for the game object using Sixt Games/Grass and make sure Density mode is NOT vertex density.
    5.- Now play with Generate button and sizes (multiples of 2) and you will see that the more the vertices the more the grass density.

    As you can iamgine I would like to have the same grass density in all tiles no matter the vertex count of the mesh, I will be so happy if you can help me to figure how to solve this issue.

    Thanks so much!

    QuadGenerator:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class QuadGenerator : MonoBehaviour {
    6.  
    7.     public int patchResolution = 2;
    8.  
    9.     public void Generate()
    10.     {
    11.         Mesh mesh = new Mesh();
    12.  
    13.         #region Vertices      
    14.         Vector3[] vertices = new Vector3[patchResolution * patchResolution];
    15.         for (int z = 0; z < patchResolution; z++)
    16.         {
    17.             // [ -length / 2, length / 2 ]
    18.             float yPos = ((float)z / (patchResolution - 1) - .5f) * 2;
    19.             for (int x = 0; x < patchResolution; x++)
    20.             {
    21.                 // [ -width / 2, width / 2 ]
    22.                 float xPos = ((float)x / (patchResolution - 1) - .5f) * 2;
    23.                 Vector3 v = new Vector3(xPos, yPos + 0.5f, 0);
    24.  
    25.                 vertices[x + z * patchResolution] = v;
    26.             }
    27.         }
    28.         #endregion
    29.  
    30.         #region Normales
    31.         Vector3[] normales = new Vector3[vertices.Length];
    32.         for (int n = 0; n < normales.Length; n++)
    33.             normales[n] = Vector3.up;
    34.         #endregion
    35.  
    36.         #region UVs    
    37.         Vector2[] uvs = new Vector2[vertices.Length];
    38.         for (int v = 0; v < patchResolution; v++)
    39.         {
    40.             for (int u = 0; u < patchResolution; u++)
    41.             {
    42.                 uvs[u + v * patchResolution] = new Vector2((float)u / (patchResolution - 1), (float)v / (patchResolution - 1));
    43.             }
    44.         }
    45.         #endregion
    46.  
    47.         #region Triangles
    48.         int nbFaces = (patchResolution - 1) * (patchResolution - 1);
    49.         int[] triangles = new int[nbFaces * 6];
    50.         int t = 0;
    51.         for (int face = 0; face < nbFaces; face++)
    52.         {
    53.             // Retrieve lower left corner from face ind
    54.             int i = face % (patchResolution - 1) + (face / (patchResolution - 1) * patchResolution);
    55.  
    56.             triangles[t++] = i + patchResolution;
    57.             triangles[t++] = i + 1;
    58.             triangles[t++] = i;
    59.  
    60.             triangles[t++] = i + patchResolution;
    61.             triangles[t++] = i + patchResolution + 1;
    62.             triangles[t++] = i + 1;
    63.         }
    64.         #endregion
    65.  
    66.         mesh.vertices = vertices;
    67.  
    68.         mesh.normals = normales;
    69.         mesh.uv = uvs;
    70.         mesh.triangles = triangles;
    71.  
    72.         mesh.uv2 = new Vector2[uvs.Length];
    73.         mesh.tangents = new Vector4[uvs.Length];
    74.         mesh.colors = new Color[uvs.Length];
    75.  
    76.         mesh.RecalculateBounds();
    77.         mesh.RecalculateNormals();
    78.  
    79.         if (!gameObject.GetComponent<MeshFilter>())
    80.             gameObject.AddComponent<MeshFilter>();
    81.         if (!gameObject.GetComponent<MeshRenderer>())
    82.             gameObject.AddComponent<MeshRenderer>();
    83.  
    84.         gameObject.GetComponent<MeshFilter>().mesh = mesh;
    85.     }
    86. }
    87.  
    QuadGeneratorEditor:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEditor;
    5.  
    6. [CustomEditor(typeof(QuadGenerator))]
    7. public class QuadGeneratorEditor : Editor
    8. {
    9.  
    10.     QuadGenerator targetScript;
    11.  
    12.     public void Awake()
    13.     {
    14.         targetScript = (QuadGenerator)target;
    15.     }
    16.  
    17.     public override void OnInspectorGUI()
    18.     {
    19.         //base.OnInspectorGUI();
    20.  
    21.         targetScript.patchResolution = EditorGUILayout.IntField("Size:", targetScript.patchResolution);
    22.  
    23.         if (GUILayout.Button("Generate"))
    24.         {
    25.             targetScript.Generate();
    26.         }
    27.     }
    28.  
    29.     void OnSceneGUI()
    30.     {
    31.         MeshFilter filter = targetScript.GetComponent<MeshFilter>();
    32.         Vector3[] vertices = filter.sharedMesh.vertices;
    33.  
    34.         GUIStyle style = new GUIStyle();
    35.         style.normal.textColor = new Color(1, 0, 1);
    36.  
    37.         for (int i = 0; i < vertices.Length; i++)
    38.         {
    39.             Handles.Label(RotatePointAroundPivot(vertices[i] + targetScript.transform.position, targetScript.transform.position, targetScript.transform.rotation.eulerAngles), "v " + i.ToString() + " " + vertices[i], style);
    40.         }
    41.     }
    42.  
    43.     public Vector3 RotatePointAroundPivot(Vector3 point, Vector3 pivot, Vector3 angles)
    44.     {
    45.         return Quaternion.Euler(angles) * (point - pivot) + pivot;
    46.     }
    47. }
    48.  
     
  12. coen22

    coen22

    Joined:
    Aug 27, 2013
    Posts:
    31
    I created a new issue for this bug. This one has a bit better description.
     
    Nonakesh likes this.
  13. Medto

    Medto

    Joined:
    Oct 28, 2015
    Posts:
    8
    Hello There, I purchased your asset the last year and using it now in a VR project, it seems it's not compatible with single pass stereo rendering, is it correct? If not any update for this? Thanks!
     
  14. Nonakesh

    Nonakesh

    Joined:
    Aug 27, 2011
    Posts:
    576
    That's actually not a bug, the shader uses tessellation to generate the grass, so it will always be bound to the vertex density. Maybe you can try to have fixed density for all tiles with grass?

    No it doesn't support single pass stereo rendering yet. I put it in my todo list, but no promises when I'll be able to look into it.
     
  15. Nonakesh

    Nonakesh

    Joined:
    Aug 27, 2011
    Posts:
    576
    Thinking about it, you are probably changing the density for performance, right? For the grass, you could always spawn it at a specific density, but only in an area around the camera. The view range of the grass doesn't need to be as high as regular terrain, so it should still run smooth that way.
     
  16. playemgames

    playemgames

    Joined:
    Apr 30, 2009
    Posts:
    438
    I second getting on single pass stereo, I'm working on a PSVR title and every bit of performance makes a difference.
     
  17. Dolzen

    Dolzen

    Joined:
    Mar 26, 2014
    Posts:
    90
    I would like to use UV2 coordinates for texture density instead of default UV1 coordinates, where should I change the code?

    Thanks.
     
  18. BARDAVELI

    BARDAVELI

    Joined:
    Aug 9, 2017
    Posts:
    1
    I have a very tiny grass for Golf field in my project, for reference, grass should be much smaller than Golf ball. Terrain causes lot of problem as you mentioned, especial on this tiny scale. Best option for me is to create OBJ from terrain and apply grass shader to it. Here's my question: In order to have an acceptable density of grass, I need to have HUGE polycount on my mesh terrain, which results in Unity spliting the terrain to million pieces and I'm not able to use grass painter. Is there ANY way for me to increase density higher than provided in shader? (I think it's 6 right now) Thanks in advance!

    Also, can you think of any other solution?

    Thank you for amazing plugin!
     
  19. Nonakesh

    Nonakesh

    Joined:
    Aug 27, 2011
    Posts:
    576
    I think you only have to change one line. Go to GrassDefinitionsAndFunctions.cginc, line 160 and replace TEXCOORD0 with TEXCOORD1, now the shader should use UV2 for everything.

    I guess you only need the grass when you zoom in to the ball, right? I'd personally create a new plane mesh manually (with the Mesh class) each time you zoom in. You could use raycasts to fit the new plane to your terrain. You could also use a density texture to create a smooth border to the area without grass. That way you can set the density precisely and it would be a lot better for performance too!
    Increasing the density further than 6 isn't possible at all, it's based on tessellation and GPU's don't support more than that, apparently.
     
  20. Dolzen

    Dolzen

    Joined:
    Mar 26, 2014
    Posts:
    90
    THanks so much for your help.

    I have another request, using Inverted Specular PBR the grass will have more or less brightness depending on the directional light rotation right? If the light is comming from the side of the grass the grass will receive more light so it will shine more, I would like to have a fixed value for the grass brightnes no matter where the light is coming, where should I change the code? Thanks.

    Edit: I don't wanna use Unshaded or Unlight light modes since I want to keep some of the Inverted Specular PBR features like the specular wave.
     
  21. tntfoz

    tntfoz

    Joined:
    Sep 29, 2016
    Posts:
    129
    Hi, just gotten around to looking at your asset (after purchasing last year!) and I'm curious about the Xbox One support that is referenced.

    1) Is the DX11 grass working with a UWP build for Xbox One (retail with dev mode enabled), or has it only been tested on a native Xbox One build (actual devkit)?

    2) Will your grass shader support DX12 (PC or Xbox One)?

    Unfortunately I believe GPU instancing is borked on Xbox One UWP builds at the moment so this would likely affect your grass shader too I believe.

    Thanks!
     
  22. Nonakesh

    Nonakesh

    Joined:
    Aug 27, 2011
    Posts:
    576
    Alright, this is a bit of a hacky solution, but it should work fine for your purpose, it's basically a unshaded with specular light mode.

    Go to the GrassLighting.cginc and replace the lines 36-38 with this:

    Code (CSharp):
    1. half4 c = UNITY_BRDF_PBS(half3(0,0,0), s.Specular, oneMinusReflectivity, s.Smoothness, s.Normal, viewDir, gi.light, gi.indirect);
    2. c.a = 1;
    3. return c + half4(s.Albedo * (gi.light.color + gi.indirect.diffuse), 1);
    Basically it sets the grass diffuse color to black, then adds the lighting used for the unshaded mode, so it combines both of them.

    Honestly, I have no idea about the Xbox One support, some people confirmed it worked, but I cannot personally confirm it. If it doesn't work and you need it for your project, I would of course give you a refund.
     
    tntfoz likes this.
  23. tntfoz

    tntfoz

    Joined:
    Sep 29, 2016
    Posts:
    129
    Ah, in that case I'm guessing some have it working through a direct build to the Xbox One platform (which you need a dev kit for) rather than UWP.

    No need for a refund, I like the asset (it works well for my Windows build)! :)

    Are you able to check with whoever confirmed it working on Xbox One, how exactly they managed it?

    Thanks!
     
  24. tntfoz

    tntfoz

    Joined:
    Sep 29, 2016
    Posts:
    129
    After trying a UWP build on Xbox One I unfortunately get pink patches instead of the DX11 grass! The player log shows these errors:

     
  25. sohj2017

    sohj2017

    Joined:
    Jan 17, 2018
    Posts:
    4
    Hello, I recently purchased the asset. It seems that right now, the subsurface scattering doesn't work when randomized grass orientation is enabled (neither low nor high scattering reduces the darkness of the grass).

    This is on Unity version 5.6.3p2 btw.
     
    Last edited: Jan 17, 2018
  26. tntfoz

    tntfoz

    Joined:
    Sep 29, 2016
    Posts:
    129
    Please note the above errors were generated when running against DX11 on the Xbox One (UWP build).

    I have since tried running against DX12 on the Xbox One and the grass still doesn't work but at least the pink (missing shader) problem no longer shows.

    The player log for DX12 shows this error:

    d3d12: the given primitive topology does not match the topology expected by the geometry shader.

    If I run a standalone build on Windows with DX12 I get exactly the same result (no grass but also no pink patches) with the same error in the player log.

    Are you able to look at getting the grass shader to run on DX12 (testing with a standalone Windows DX12 build)? I feel that if you can get it working on Windows desktop DX12, it should actually work on the Xbox One DX12 path as well.

    I would of course offer to assist in helping to test out the Xbox One deployment for you.

    I've no experience with shaders (whatsoever!) but is it possible that the DX12 Graphics Jobs could provide a performance boost for your grass shader as well? That could be a big win for your asset as you'd have the only DX12 compatible grass shader on the store.

    Thanks.
     
  27. playemgames

    playemgames

    Joined:
    Apr 30, 2009
    Posts:
    438
    Getting this error when I build for PS4:

    Coming from Shader error in 'Stix Games/Grass' Programs 'domainShader', 'frag', 'vert', 'geom', 'domainShader', and 'hullShader'

    I'm using Unity 2017.1.1p1
     
    Last edited: Jan 18, 2018
  28. Genebris

    Genebris

    Joined:
    Mar 18, 2013
    Posts:
    143
    I noticed that grass density depends on screen resolution. Is there a way to disable that?
     
  29. piotr-gwiazdowski

    piotr-gwiazdowski

    Joined:
    Dec 2, 2015
    Posts:
    5
    Any chances of having motion vector support?
     
  30. Nonakesh

    Nonakesh

    Joined:
    Aug 27, 2011
    Posts:
    576
    I can't really make too much from these errors, every shader pass has a vertex shader, otherwise it wouldn't work on any platform. It's probably a problem with the cross compiler? You could report it as a bug, maybe the Unity team has an idea how to solve it. Feel free to add my support email, in case I can do something about it.

    Yes, it looks like that there's a bug there, I'll look into it.

    The primitive topology bug is something that should have been fixed a few updates ago. I just wish the shader compiler was a bit more verbose with its error messages, these cryptic messages don't really help.
    Just to be sure: Are you sure you are using the lastest version of the shader?

    About the DX12 thing, I'm quite sure there would be any performance boost from DX12, although it should run there like normally.

    I think that's the same problem as in the PC OpenGL Core build, it's a bug in Unity's own shader code. I'll look into it.

    As I've said in the email, the grass density should not be dependent on the screen resolution, so your problem is probably somewhere else, like grass not being rotated in the right direction, in VR.

    Honestly, it would be really difficult to make this possible. Not only would it be necessary to do the wind calculations of the last frame again, keep last frames density texture, then basically generate the vertices of each blade of grass twice, to finally be able to calculate the motion vector... well, it would increase the performance cost by a lot and require a lot of code that would be very hard to maintain.
     
    tntfoz likes this.
  31. Genebris

    Genebris

    Joined:
    Mar 18, 2013
    Posts:
    143
    I think you are confusing me with someone. You have never told me this in the email and I don't use VR. I have this issue even in empty project in example scene.
    1.png 2.png
    The only difference is viewport resolution.
     
  32. tntfoz

    tntfoz

    Joined:
    Sep 29, 2016
    Posts:
    129
    You are quite right! :) I had an older version of the grass shader (1.7 I think) and updating to the latest 1.8.2 has fixed it working in DX12 on the Xbox One! Thanks for your help, and apologies for not updating first!

    I have a new question for you following this. Is it possible to change the "Grass type" value of the shader via script similar to changing other shader values via the material? I'm looking to simplify the grass from "4 textures" to "Simple with density" on-the-fly depending on which platform is detected. It looks like none of the Shader Variants parameters are accessible through the shader unfortunately.
     
  33. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    Hello Nonakesh,

    I am ready to buy your asset but I want to present you with my case to be sure that I understood the document right:

    I am planning to use the grass in a Unity terrain, so I will duplicate my terrain, change the shader from the standard shader that comes with unity to the one that comes with your asset in this new terrain that will be only for the grass, one I have the grass working as I need it, I will be able to stop the new terrain from rendering?, remove all the other drawings stuff from the new terrain as well so my scene will only render the grass that is on it? and remove the new terrain collider as well? Please let me know as soon as you can if this is correct.

    Regards,
    Carlos
     
  34. Ardinius

    Ardinius

    Joined:
    Oct 4, 2015
    Posts:
    57
    Hi Nonakesh,
    I own your asset and it has been working perfectly for my needs so far, your documentation is brilliant, however i am only a hobbist Unity developer and i think i may be thinking about this problem wrong, please confirm the best approach:

    I have a custom terrain mesh, at present the whole mesh uses your shader so i get grass everywhere, i am now wanting to apply a splatmap to my terrain so i get other textures, what method should i use to insure that your shader is only applied to the area where the grass texture is on the mesh? Is there a method to give each texture on a mesh its own material? If not...
    Should i just add two materials to my mesh, one for the splatmap texture values and another material for your grass?
    Should i then create a colour/height texture like you say in 1.4.1 to control where the grass is displayed?
     
  35. sohj2017

    sohj2017

    Joined:
    Jan 17, 2018
    Posts:
    4
    I might be able to offer a solution - prepare two different shaders with the different settings you want. Build two identical meshes and put them in separate disabled game objects. Give each mesh one of the two shaders, and just enable the game object that already has the correct shader for the platform that gets detected. That way you never have to directly manipulate the shader at runtime, you just enable the one you need. Can do it with any number of shader variants too.

    Question for Nonakesh:

    I'm trying to create the ability for a thrown object to displace grass. I've made it work for the most part, except the grass also gets displaced when the object is in the air above the grass, not just when the object is actually in contact with the grass. I would obviously like for the object to only displace grass that it gets into contact with. I'm not sure if this is intended behaviour or not, and if there is an easy fix?

    I imagine it's tricky to detect collision with the grass itself, but I have implemented some appropriate events to keep it simple - the idea is to stop displacing grass when the player throws the object, and start displacing grass when the object collides with the ground again. So the work I'm doing with your code is basically just to figure out which parts of your code to enable and disable when those events get called, so I can pause and start the grass displacement. However, that's proving a bit troublesome.

    I tried conditionalizing the following part of the displacement trail renderer script:

    Code (CSharp):
    1.  
    2.                 // Added conditional that gets disabled when player releases object, and re-enabled on object-ground collision
    3.                 if (createTrail)
    4.                 {
    5.                     //Add new point if list is empty or distance to last point is bigger than minVertexDistance
    6.                     if (points.Count == 0 || Vector3.Distance(points[points.Count - 1].pos, pos) > minVertexDistance)
    7.                     {
    8.                         points.Add(new TrailPoint(pos, Time.time));
    9.                         addedPoint = true;
    10.                     }
    11.  
    12.                     List<TrailPoint> renderPoints = new List<TrailPoint>(points);
    13.  
    14.                     //If no point was added this frame, use the current position as point
    15.                     if (!addedPoint)
    16.                     {
    17.                         renderPoints.Add(new TrailPoint(pos, Time.time));
    18.  
    19.                     }
    20.  
    21.                     //If there are less than 2 points, don't render the trail.
    22.                     if (renderPoints.Count < 2)
    23.                     {
    24.                         return;
    25.                     }
    26.  
    27.                     UpdateMesh(renderPoints);
    28.                 }
    However, what this does is that the object correctly does not displace grass when in the air - but then once it collides with the ground, it immediately renders the whole trail that was below it while it flew through the air and until it hit the ground. So the displacement tracking doesn't seem to pause, even when disabled. Am I going about this all wrong, or?
     
    Last edited: Jan 30, 2018
    tntfoz likes this.
  36. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    Hello guys,

    I bought this asset recently and I am using it in Xbox One, but when I play the game it freezes at a random time and position every time without any error thrown in the console! Does anyone has any idea of what could the reason be? I am using the simple grass, not grass textures, just plane simple grass type, with the "Color Texture (RGB), Height(A)" slot in use. This is in a terrain just created for the grass.

    Any help would be very much appreciated

    Regards,
    Carlos
     
  37. tntfoz

    tntfoz

    Joined:
    Sep 29, 2016
    Posts:
    129
    That's curious - I'm having similar issues with unexpected freezes too but hadn't linked it to the grass asset.

    Are you building via UWP with DX12? That's the only way I could get the DX11 grassto work.
     
  38. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    tntfoz,

    No I am building trough the xbox one manager, and directly to the console and everything works great, excepts that it freezes randomly. I know it is the grass because as soon as I remove the grass from the build, the game runs without freezing at all.

    Regards,
    Carlos
     
    tntfoz likes this.
  39. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    Could this be the problem tntfoz?

    Shader warning in 'Stix Games/Grass': Program uses geometry shaders, automatically setting target to 4.0 at line 99

    Compiling Vertex program with DIRECTIONAL SHADOWS_SCREEN GRASS_CALC_GLOBAL_WIND GRASS_HEIGHT_SMOOTHING GRASS_IGNORE_GI_SPECULAR GRASS_PBR_LIGHTING SIMPLE_GRASS
    Platform defines: UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_LIGHT_PROBE_PROXY_VOLUME
     
  40. Xype

    Xype

    Joined:
    Apr 10, 2017
    Posts:
    339
    When I first looked at this, being part of the Nvidia Gameworks community my first thought was, omg this guy just straight ripped of Turf Effects. But nope, they never released any code for that! Great job making the same stuff yourself.

    Have you tried fiddling with this in voxeland, I think it would be amazing if you can have this grass automatically populate grass voxel surfaces o_O
     
  41. tntfoz

    tntfoz

    Joined:
    Sep 29, 2016
    Posts:
    129
    Sounds like a much friendlier (easier) environment to work with than Unity -> UWP -> VS2017 -> Xbox. I'll have to see if I can get a devkit through id@xbox.

    It's possible. I get the impression the Xbox platform is quite finicky regarding shaders (particularly missing ones). Unfortunately I'm no expert (or even a beginner!) with shaders, so hopefully @Nonakesh will be able to give some pointers regarding this.
     
  42. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    Talking about @Nonakesh, I have been trying to contacting him through this forum and the email support but I haven't hear from him at all. I wonder how normal is this...
     
  43. Xype

    Xype

    Joined:
    Apr 10, 2017
    Posts:
    339
    Don't know. I bought it was really happy for 20 minutes when I got it all set with the basics. Soon as I tried to add a second grass style boom crash, over and over.
     
  44. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    are you using Terrain for the grass or and object? My crashing seems to disappear as soon as I added a terrain collider to my grass terrain, although the terrain collider is disabled, it just seems that if you use a terrain for the grass, and you remove the terrain collider component from it, there is an exception thrown randomly and this could have been what was crashing my game in the console. So if you are using a terrain, be sure you don't delete its collider, but just de-activate it. I have tested it several times with the grass, for long periods and my game hasn't crashed anymore so far, after I kept the collider in the grass terrain.

    Regards,
    Carlos
     
  45. Xype

    Xype

    Joined:
    Apr 10, 2017
    Posts:
    339
    No sir, voxels. I think its blowing the vertices max, no errors, plenty of computer power to spare, unity just freezes and I have to restart. Not really a crash but I have to force it down with task manager.
     
  46. Xype

    Xype

    Joined:
    Apr 10, 2017
    Posts:
    339
    I ONLY freeze when I try to change from simple or simple differed (or whatever it is I deleted the asset) to 2 3 or 4 grasses. Instant once I click that. I can do ANYTHING else fine with it, even take the 1 grass model and make it stupid dense with long range. I will also say the documentation is some of the best I have seen on the asset store. So it will be a shame if this dev poofs.
     
  47. Feartheway

    Feartheway

    Joined:
    Dec 12, 2017
    Posts:
    92
    Ok, I have just bought this asset after spending a few weeks trying to get a decent mass grass to work in unity. I love this asset. I got something similar going in unity using trees but good grief the performance hit was shocking. My question is there any good tutorials on getting the grass Dynamic Reactions - RenderTexture to work? preferably a video. I would also like my racing car to leave mud trails instead of grass. Maybe its something like burning grass?
     
  48. Feartheway

    Feartheway

    Joined:
    Dec 12, 2017
    Posts:
    92
    is there some way to write the path of a car as a line on a texture and use that to persistantly crush vegetation?
     
  49. coen22

    coen22

    Joined:
    Aug 27, 2013
    Posts:
    31
  50. tntfoz

    tntfoz

    Joined:
    Sep 29, 2016
    Posts:
    129
    I had the primitive topology error when trying the DX11 grass shader out on the Xbox One (via UWP).

    I wasn't running the latest version, and the topology problem was fixed in a recent update.

    Check that you have the latest asset version in your project (although whether this fixes OpenGL compilation or not I couldn't tell you!).