Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

[RELEASED] DirectX 11 Grass Shader

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

  1. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    877
    Thanks very much for your help, I will take a look at the functions you mention, side note for me when I tried to use the painter on my grass the red circle does not move, do I need to let click to add/remove grass on certain areas? Would it be possible to make a short demonstration video on how this works, I have not been able to use it yet, maybe I am on a old version , although I recently imported the asset to a new project form the asset store, no errors seen in the console either, maybe I just don't know how to use it properly.
     
  2. JonDadley

    JonDadley

    Joined:
    Sep 2, 2013
    Posts:
    139
    Thanks, hopefully it's a simple issue with an easy fix :)
     
  3. JonDadley

    JonDadley

    Joined:
    Sep 2, 2013
    Posts:
    139
    I managed to hack around the issue by clamping the max colour of the grass. At the end of GrassLighting.cginc I put in the following clamp:

    Code (CSharp):
    1.     color = clamp(color, 0, 0.5);
    and it mitigates the issue. Obviously a bit of a hack but works for me.
     
    Last edited: Mar 10, 2017
    twobob likes this.
  4. MarcusValerius

    MarcusValerius

    Joined:
    Aug 1, 2016
    Posts:
    12
    Hello,
    I've been using this asset with Unity 5.4.0 for the past days without any problems whatsoever.
    However, yesterday I switched to Unity 5.5.2, and now all I ever get is hundreds of blades of grass centered at 0,0,0 which looks like this:

    That's the asset's example scene by the way. (I moved the sphere aside.)
    My installation of Unity 5.5.2 is set to "Win,Mac,Linux Standalone DirectX11" on "Fantastic" quality, and this particular test project is new and clean apart from this grass asset. It's still working fine with Unity 5.4. on the same PC.
    I'm not getting any errors or warnings either. Changing any of the shader values in the inspector also doesn't help.
    Anybody have any idea what's going on here?
     
  5. Nonakesh

    Nonakesh

    Joined:
    Aug 27, 2011
    Posts:
    446
    Yeah, I'll try to look into how Unity solved this in their standard shader, but if that doesn't work out, I might do it the same way. At least for the specular highlights.

    Are you sure you are using the latest version of the shader? 5.5 should work, unless Unity changed something in 5.5.2
     
  6. MarcusValerius

    MarcusValerius

    Joined:
    Aug 1, 2016
    Posts:
    12
    Yup, you're right. I'm not sure what happened here, but an old version of the shader was in my project. I updated again and it's working fine now.
     
    Nonakesh likes this.
  7. MuckSponge

    MuckSponge

    Joined:
    Jul 11, 2015
    Posts:
    41
    Hi Nonakesh, fantastic shader :) I was desperate to use this on macOS (OpenGL Core) so I gave it a go and it mostly works, to my surprise.

    There are a few weird GL compilation issues when using more than 1 grass texture, a texture atlas, or the smooth grass width/height options. I really just needed to be able to use a texture atlas so I could add some variety to my grass and I managed to track down the culprit.

    Relocate the texture atlas code in GrassSurface.cginc to the geomToFrag function in GrassGeom.cginc. I have no idea why but Unity doesn't like to manipulate the UV coordinates from inside the surf function. Took me a good 2 hours to work that one out!

    I might see if I can fix the issues with smooth grass width/height next...

    EDIT: Some proof. Textures are placeholders:

    atlased-grass.jpg
     
    Last edited: Mar 11, 2017
    Cristian76 and Nonakesh like this.
  8. Nonakesh

    Nonakesh

    Joined:
    Aug 27, 2011
    Posts:
    446
    This is great, thanks for sharing! I'll look into it myself too, once I got the time again. If you find out something else, please share it here!

    By the way, I already like the look of your scene! :)
     
  9. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    877
    Hi, I would like to ask if you would be willing to take a look at my efforts , see below.
    I have tried to do as you suggest, I have removed Editor type functions as I understand it, see attached script(GrassPainterRemover.cs.txt), some problems I have currently is I see the following exception at runtime when mouse clicking/using the script:

    NullReferenceException: Object reference not set to an instance of an object
    StixGames.GrassManipulationUtility.GetWorldToTextureSpaceMatrix (Ray ray, Single offset, UnityEngine.Collider collider, UnityEngine.RaycastHit& hit, UnityEngine.Vector2& forward, UnityEngine.Vector2& right) (at Assets/StixGames - DirectX 11 Grass Shader/Scripts/GrassManipulationUtility.cs:82)
    GrassPainterRemover.ApplyBrush (Vector3 hitPoint) (at Assets/myscene/GrassPainterRemover.cs:136)
    GrassPainterRemover.Update () (at Assets/myscene/GrassPainterRemover.cs:62)

    Could I ask you to take a look at the script I modified, to see if it looks ok generally? One thing I am not sure of how to control is that mouse clicks delete, not add grass, I set the variable:
    private static int brushMode = 1;
    Will that do it?
    Can I get away with not using the script GrassManipulationUtility.cs as seen in the exception?
     

    Attached Files:

  10. TheBearAu

    TheBearAu

    Joined:
    Mar 19, 2017
    Posts:
    2
    Hi,

    We've been using your asset for quite a while without any issues, however recently we have been having problems when using Unity 5.5.2 on PS4 (and maybe other 5.5.x versions). We had the grass working in previous builds on PS4 using Unity 5.4, but at some point that stopped working (not quite sure when, we've upgraded the unity version, the PS4 firmware version and updated to the latest version of your asset). Everything works fine for Windows builds.

    The problem we are getting is there weird jumping around triangles that are superimposed on top of everything. The number of triangles seem to be influenced by the amount of grass on screen (even grass obscured by other objects).

    grass issue.jpg

    You can't tell from the image but the triangles and lines are jumping around and turning on and off constantly.

    I've tried toggling a bunch of the player settings on and off, and disabled every other script and effect on the camera to try to rule out any conflicts. Does any one have any suggestions what we can look into from here?
     
  11. Nonakesh

    Nonakesh

    Joined:
    Aug 27, 2011
    Posts:
    446
    Sorry for not answering for so long, I'll look into it, but right now I have to work on another important project. I'll contact you, once I get the time.

    Are there any error messages regarding the PS4 build? I'd really like to test this myself, but I don't have a PS4 Devkit, so I'll have to try to fix it remotely.
     
  12. FirstTimeCreator

    FirstTimeCreator

    Joined:
    Sep 28, 2016
    Posts:
    717
    There is an issue with writing the texture in 5.5 when you edit the grass mesh. I sent you a support email with a screen shot, other than that the grass is working fine, just an issue with the editor writing the displacement texture.
     
  13. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    877
     
  14. TheBearAu

    TheBearAu

    Joined:
    Mar 19, 2017
    Posts:
    2
    Nonakesh,

    There are no error messages, nothing when I build in Unity, and as best I can tell there are no runtime errors (the PS4 console outputs a lot of info, but I can't find anything in there that could be related to this issue).

    I've tried starting a new project, importing your asset and building for PS4 using your example scene. There is something in there that throws an exception (only on PS4), so I disabled everything except the game objects you can see in the image below. It pretty much does the same thing, the only difference I noticed is that in my scene the strange triangles are all over the screen, where as when I used your scene the strangeness was limited to the ball's shadow. If I rolled the ball out of the grass the shadow disappears and so does the strangeness. Not sure if any of that helps.

    grass2.jpg

    If there are any other debugging steps you want me to try let me know. You can also contact me direct on ben at lightningrock.com
     
  15. Nonakesh

    Nonakesh

    Joined:
    Aug 27, 2011
    Posts:
    446
    Hey, sorry about not answering there, as I've said I have some time critical work to do on another project right now. The grass-painter bug where it writes that the wrong texture format is used can be fixed manually, by selecting the texture and switching to one of the formats listed (it has to have an alpha channel though). I will hopefully be able to patch this until the end of this week.

    I'll contact you once I get the time! I hope this doesn't limit your development too much.
     
  16. TimeSniper

    TimeSniper

    Joined:
    Nov 26, 2012
    Posts:
    17
    Hi?
    When the grass shader works together with UI(NGUI in our case), it is rendered in front of the UI, which is weird.
    Please notice that the some parts of the UI elements are invisible in the below image. NGUI has its own camera and I think it should be rendered top of grass shader.
    Can you give me some advice how I can fix this?
    Gavin
    NGUI.png
     
  17. Nonakesh

    Nonakesh

    Joined:
    Aug 27, 2011
    Posts:
    446
    Hey! I've never used NGUI before, but here are a few ideas: Have you tried disabling the layer with your grass object on the UI camera? I think it shouldn't have to render anything but the UI, right? Are you using the replacement Camera-DepthNormal shader? When using image effects that use the depth-map it's sometimes required to use this, maybe the UI depends on it too. Are you having this problem with anything other than the grass?

    If that doesn't help at all, could you send me your project per PM, so I can look at it myself?
     
  18. Nonakesh

    Nonakesh

    Joined:
    Aug 27, 2011
    Posts:
    446
    I just uploaded a new patch, here's the changelog:

    1.6.0:
    • Adds a new lighting mode "Unshaded" that is still affected by light colors and shadows, but has no specular or diffuse lighting, similar to unlit.
    • Fixed lighting issues with HDR in forward rendering.
    • Fixed the grass painter bug in 5.2, where new texture were not imported correctly.
    • Splits the grass painter into two seperate classes, this should make it easier to create a in-game grass editor.
    As always, you can send me your invoice number to get the new version right now, or you could just wait until Unity approves the new version.
     
  19. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    877
    "Splits the grass painter into two separate classes, this should make it easier to create a in-game grass editor." , woah :) sounds very interesting! Any tips on how to use this would be most welcome, will the patch have any api/samples on how to use this, I am most interested in this to try use this at runtime.
     
    Last edited: Apr 4, 2017
  20. colateroso

    colateroso

    Joined:
    Nov 16, 2015
    Posts:
    8
    Hi, is it possible to make the terrain, with the grass material, invisible? I mean, so that i can have a terrain with textures and another one with the grass material and this one only showing the grass blades.
     
  21. Zaki_X

    Zaki_X

    Joined:
    Jul 5, 2016
    Posts:
    55
    I would like to use DX11 grass shader just for my billboard grasses (turboscalpeur's). Is it easy to set?
    Can I switch from regular Unity shader to yours or does it overwrite the standard one?

    Mike
     
  22. Nonakesh

    Nonakesh

    Joined:
    Aug 27, 2011
    Posts:
    446
    I didn't add any samples, honestly I haven't even tried it in-game, but it should work. I'm happy I was able to do as much as I did with the little time I had recently.
    Once you have the patch, you should look at the file Scripts/GrassPainter.cs. Add it as a variable to one of your script and call the Draw(Ray) method, then everything should work. It will only work on editable textures, to you'll have to prepare your grass object a bit. If you have any questions, just ask them here!

    Yeah, that's how it's working right now. The grass material doesn't render the floor, so you can use a second material with any shader you want. This has the disadvantage of having to duplicate the terrain though.

    My grass shader is a bit different from Unity's terrain grass, but now that the shader includes a grass painter, the workflow isn't that different any more. If you already have a scene with Unity's grass, I think it should be possible to export your current grass locations via a script and use it with my grass shader. I haven't tried this yet, but if you have any trouble with it, I'd be happy to help you out.
     
    Last edited: Apr 5, 2017
  23. Zaki_X

    Zaki_X

    Joined:
    Jul 5, 2016
    Posts:
    55
    @Nonakesh - what if I don't have my grasses spawned yet? If I would spawn these after adding your shader to my project would it work? What about switching from DX11 shader to standard one (in case if something would not look right for example on PS4)? Is it possible?
     
  24. Nonakesh

    Nonakesh

    Joined:
    Aug 27, 2011
    Posts:
    446
    Yes, going back should work as well, the shader uses a texture for grass density, so it should be straight forward to use the data. Just so you know: PS4 doesn't seem to be working right now, but it's a bit hard to test it without a PS4 dev kit. If you decide to test it and get any error messages from the debug log, I'll try to get it working again.
     
  25. moxi299

    moxi299

    Joined:
    Jul 6, 2015
    Posts:
    36
    Would it be possible that you add a deferred render Mode? ;)
    I have a lot of Image processing going on in my Project.
     
  26. Nonakesh

    Nonakesh

    Joined:
    Aug 27, 2011
    Posts:
    446
    I've tried that a few times at the start, but at least with the current drawing modes this isn't possible. The problem is that the grass rotates with the camera and still has complex lighting, so right now the normal of the grass has to be changed per light, which isn't possible in deferred rendering. It might be possible in the future, when I get the time to implement other grass modes.

    That said, the grass should work with image processing just fine, as long as you are using the included Camera-DepthNormal shader.
     
  27. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    1,489
    hi @Nonakesh

    I have been keeping my eyes on this shader for a while now. And it is great to see you are still supporting it after all this time. I have decided to try the shader for my project but I want to know few things first :

    1. I read sometime ago about the shader not working properly under deferred render mode especially with multiple point lights affecting the surface of grass generating mesh. Something to do with grass being rendered only with forward rendering mode and the point light's importance setting causing lighting difference on the surface and the actual grass on top of it. Is this issue been addressed at all? If not, can we at least force the grass to just pickup the color from the surface geometry and use that color uniformly per blade of grass? ( making the grass blade lighting simple and calculated from the surface geometry instead of calculating from the actual light sources)

    2. How is console support at the moment? I just read something about PS4 is a bit out of date on testing and some bugs in there, but how about XboxOne? If you would like me to work with you to address problems on these platforms I would be glad to jump in.

    3. Having said all of above, I would really need to actually test the shader for the project so would you be kind to let me test it before buying it or would you be able to offer refund if I found it to be not practical for my project after I bought it and tested it? PM me if you want.

    Thanks!

    -- Edit --

    Just bought the shader anyway. I need to use deferred lighting mode and it seems to work on XboxOne. However, I really think there should be a lighting model that takes lighting info from the ground instead of lighting individual blade separately. I have also noticed that the ambient color isn't being applied to the grass on PC (editor & built) but it works fine on XboxOne. This is first time I ever seen PC side not working properly but the console one does. XD
     
    Last edited: Apr 6, 2017
  28. colateroso

    colateroso

    Joined:
    Nov 16, 2015
    Posts:
    8
    I have a huge terrain (10 km x 10 km) using RTP and a duplicate terrain using the grass shader. I set the pixel error of the one with the grass to 200 and at a big distance the grassy terrain shows up as black regions or white regions. As soon as i get home i'll post some pictures. I'm using Unity Terrains.

    Edit: Here goes the picture and i found that it has something with the basemap distance. The image below is taken with basemap dist set to 2000 (max as far as i know).


    Edit2: It looks like i "fixed" It by attaching a script to the grassy terrain that changes the basemapDistance property to 10000 inside the Update() function. I didn't notice any performance impact by doing so.
     
    Last edited: Apr 6, 2017
  29. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    877
     
  30. Nonakesh

    Nonakesh

    Joined:
    Aug 27, 2011
    Posts:
    446
    Since the new update ambient color should work on PC, even with specular lighting. I think taking the lighting directly from the floor would cause more problems than it would solve, for example grass that is on a slight slope would be darker, even though the grass itself should be perfectly lit. I will definitely look into adding more lighting modes, like the unshaded mode, but with specular lighting for example.
    If you have any problem with the console support, please post here or send me a PM, it's a bit hard to fix bugs without a dev-kit myself.

    Yes I believe adding a script to change the basemapDistance is the way to go here!

    The update has been accepted, so you should be able to get it from the asset store now!
     
  31. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    1,489
    I have updated the package to 1.6 yesterday but ambient color is still not working for pc.
     
  32. Nonakesh

    Nonakesh

    Joined:
    Aug 27, 2011
    Posts:
    446
    Really? Maybe we are talking about different things. Can you send post a few screenshot, maybe one on PC and one on XBox?
     
  33. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    1,489
    Yes, I understand your concerns about taking lighting info from the ground. But in case where the game is just a flat surface. ( This can happen more than what anyone think ) It is useful in such case. Also, for the mode where the grass follows the normal of the surface, it can also be useful.

    I will try to post the screen shots of PC and XboxOne.
     
  34. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    877
    Hi Nonakesh,

    Sorry for the big post, hope it is ok to add it here.
    I have been trying to get the remove some grass (wherever mouse clicks) at runtime to work but am facing further problems (I'm just not understanding how your code works yet :) ).
    Here is my GrassPainterRuntimeRemover.cs script (most of it copied from your scripts):

    using System;
    using UnityEngine;
    using System.IO;
    using StixGames;

    public class GrassPainterRuntimeRemover : MonoBehaviour
    {
    public int Channel = 0;
    public int BrushMode = 1;
    public float Strength = 1;
    public float Size = 1;
    public float Softness = 0.5f;
    public float Spacing = 0.5f;
    public float Rotation = 0;
    private Texture2D texture;
    private bool startedWithCollider;
    private int textureSize = 512;
    private bool mouseDown;
    private Vector3 lastPaintPos;
    private bool didDraw;
    private bool showCloseMessage;
    private bool showTargetSwitchMessage;
    private const float EPSILON = 0.01f;

    void Update()
    {
    UpdateInput();
    //Paint
    if (Input.GetMouseButton (0)) {
    var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
    RaycastHit hit;
    if (Physics.Raycast (ray, out hit)) {
    Debug.Log ("msg2");
    ApplyBrush (hit.point);
    didDraw = true;
    }
    }
    }

    private void UpdateInput()
    {
    if (texture != null && Event.current.type == EventType.MouseDown && Event.current.button == 0) {
    mouseDown = true;
    Debug.Log ("msg4");
    if (Event.current.type == EventType.MouseUp && Event.current.button == 0) {
    mouseDown = false;
    if (didDraw) {
    didDraw = false;
    }
    }
    }
    }

    public Collider GrassCollider;
    public Texture2D Texture;
    public bool Draw(Ray ray)
    {
    Debug.Log ("msg3");
    RaycastHit hit;
    if (Physics.Raycast(ray, out hit))
    {
    GrassCollider = hit.collider;
    Texture = (Texture2D) hit.collider.GetComponent<Renderer>().material.mainTexture;
    Debug.Log ("msg4");
    ApplyBrush(hit.point);
    return true;
    }
    return false;
    }

    public void ApplyBrush(Vector3 hitPoint)
    {
    Debug.Log ("msg6");
    RaycastHit hit;
    Vector2 texForward, texRight;
    if (!GrassManipulationUtility.GetWorldToTextureSpaceMatrix(new Ray(hitPoint + Vector3.up * 1000, Vector3.down),
    EPSILON, GrassCollider, out hit, out texForward, out texRight))
    {
    return;
    }
    Debug.Log ("msg7");
    Vector2 texCoord = hit.textureCoord;
    int pixelRadius = (int)(Size * texForward.magnitude * Texture.width);
    Vector2 mid = new Vector2(texCoord.x * Texture.width, texCoord.y * Texture.height);
    int targetStartX = (int)(mid.x - pixelRadius);
    int targetStartY = (int)(mid.y - pixelRadius);
    int startX = Mathf.Clamp(targetStartX, 0, Texture.width);
    int startY = Mathf.Clamp(targetStartY, 0, Texture.height);
    int width = Mathf.Min(targetStartX + pixelRadius * 2, Texture.width) - targetStartX;
    int height = Mathf.Min(targetStartY + pixelRadius * 2, Texture.height) - targetStartY;
    mid -= new Vector2(startX, startY);
    Color[] pixels = Texture.GetPixels(startX, startY, width, height);
    for (int y = 0; y < height; y++)
    {
    for (int x = 0; x < width; x++)
    {
    int index = y * width + x;
    Vector2 uv = ((new Vector2(x, y) - mid) / pixelRadius) * 0.5f + new Vector2(0.5f, 0.5f);
    pixels[index] = ApplyBrushToPixel(pixels[index], uv);
    }
    }
    Texture.SetPixels(startX, startY, width, height, pixels);
    Texture.Apply();
    }

    private Color ApplyBrushToPixel(Color c, Vector2 v)
    {
    v -= new Vector2(0.5f, 0.5f);
    v *= 2;
    float distance = v.magnitude;
    float value = SmoothStep(1, Mathf.Min(1 - Softness, 0.999f), distance);
    switch (BrushMode)
    {
    case 0:
    c = ChangeChannel(c, x => x + value * Strength);
    break;

    case 1:
    c = ChangeChannel(c, x => x - value * Strength);
    break;

    case 2:
    c = ChangeChannel(c, x => x * (1 - value) + Strength * value);
    break;
    }

    return c;
    }

    private Color ChangeChannel(Color c, Func<float, float> densityChange)
    {
    switch (Channel)
    {
    case 0:
    c.r = Mathf.Clamp01(densityChange(c.r));
    break;
    case 1:
    c.g = Mathf.Clamp01(densityChange(c.g));
    break;
    case 2:
    c.b = Mathf.Clamp01(densityChange(c.b));
    break;
    case 3:
    c.a = Mathf.Clamp01(densityChange(c.a));
    break;
    default:
    throw new InvalidOperationException("Channel number invalid");
    }
    return c;
    }

    private float SmoothStep(float edge0, float edge1, float x)
    {
    x = Mathf.Clamp((x - edge0) / (edge1 - edge0), 0.0f, 1.0f);
    return x * x * (3 - 2 * x);
    }
    }


    NOTE that I have public int BrushMode = 1; which is what I think must be set to remove grass (I don't want to add! only remove grass in certain areas at runtime).
    When I then click on a grass object at runtime I see the following exception:

    MissingReferenceException: The object of type 'MeshCollider' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object.
    UnityEngine.Collider.Internal_Raycast (UnityEngine.Collider col, Ray ray, UnityEngine.RaycastHit& hitInfo, Single maxDistance) (at C:/buildslave/unity/build/artifacts/generated/common/modules/Physics/DynamicsBindings.gen.cs:2766)
    UnityEngine.Collider.Raycast (Ray ray, UnityEngine.RaycastHit& hitInfo, Single maxDistance) (at C:/buildslave/unity/build/artifacts/generated/common/modules/Physics/DynamicsBindings.gen.cs:2774)
    StixGames.GrassManipulationUtility.GetWorldToTextureSpaceMatrix (Ray ray, Single offset, UnityEngine.Collider collider, UnityEngine.RaycastHit& hit, UnityEngine.Vector2& forward, UnityEngine.Vector2& right) (at Assets/StixGames - DirectX 11 Grass


    On this method in your script GrassManipulationUtility.cs:
    public static bool GetWorldToTextureSpaceMatrix(Ray ray, float offset, Collider collider, out RaycastHit hit, out Vector2 forward, out Vector2 right)
    {
    if (collider.Raycast(ray, out hit, Mathf.Infinity))
    {
    forward = GetTexCoordDifference(ray.origin, hit.textureCoord, Vector3.forward * offset, collider);
    right = GetTexCoordDifference(ray.origin, hit.textureCoord, Vector3.right * offset, collider);
    return true;
    }

    Te texture is readable, I have a MeshCollider on the object..
    The method ApplyBrush looks like it checks for GrassManipulationUtility.GetWorldToTextureSpaceMatrix, when this is called I see the error.
    Any hints on what I missing or doing wrong would be much appreciated, whenever you have some time of course. P.S with the update to 1.60 I now can use the painter tool via the Editor GUI,before I was not able to for some reason.
     
  35. Nemo1991

    Nemo1991

    Joined:
    May 10, 2016
    Posts:
    3
    Hey.
    We are thinking to purchase the shader for use in our project. Does it work with the newest Unity 5.6?

    Please, let me know as soon as possible. ;)
     
  36. Cristian76

    Cristian76

    Joined:
    Feb 9, 2017
    Posts:
    4
    Hi was desperate too and I fixed the same issue you had probably. I'm still trying to fix the smooth height/width issue (didn't investigate yet). If I found something I will post and update too
     
  37. Nonakesh

    Nonakesh

    Joined:
    Aug 27, 2011
    Posts:
    446
    Yes, it should work there without problems!

    Thanks guys, I'll look into OpenGL Core support myself too, once I get the time, but please post anything you find!

    Does the object with your grass material itself have the grass material? It wouldn't work when the floor object has the collider. Although it's a bit strange it says that the collider was destroyed, not simply null. I'll look into it, as I said, I only tested the painter in the editor, so it might just be because of that.
     
  38. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    877
    Hi,
    No probs, any help would be appreciated so I can realise the goal for my game :)
    To answer:
    Does the object with your grass material itself have the grass material?
    I am using the prefabs you provide, with my own grass texture added, it has a mesh collider, see screenshots:

    1.PNG 2.PNG
     
  39. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,301
    Is there any way to get this shader to render as Deferred, into the G-Buffer, instead of forcing itself to Forward Add like it does now? I'm trying to get it to work with SEGI and some other image effects but the rendering as a separate forward pass seems to exclude it from most effects.
     
  40. Shofixti

    Shofixti

    Joined:
    Sep 30, 2012
    Posts:
    1
    Hey there, just downloaded this, and it's absolutely fantastic! Amazing work.
    I am, unfortunately, having a small problem with using it on a duplicated Unity Terrain. Namely that the base texture of the floor of the grass shows up as white, rather than showing through to the terrain beneath it. Screenshot below:

    I've played around with just about all the settings I could find on both the terrain and the shader, but can't seem to find any indication as to what might be causing this. Applying the grass material to a mesh works fine.

    Any assistance is appreciated! I know you said previously that you were a little fed up with trying to support Unity Terrains. So perhaps I should instead work with meshes generated outside of Unity?
     

    Attached Files:

  41. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    877
    Hi, not sure if I understand correctly, but you could try to disable the mesh renderer for he object, does that help?
     
  42. Will-D-Ramsey

    Will-D-Ramsey

    Joined:
    Dec 9, 2012
    Posts:
    221
    Any info about this working with TerrainComposer2?
     
  43. m1735

    m1735

    Joined:
    Nov 28, 2013
    Posts:
    9
    How to get this to work on Xbox One?

    All I see is a lot of the pinky-purple associated with "shader ain't working".

    Unity 5.6.0b9.

    e.: Compiled without any errors in Unity or Visual Studio.
     
  44. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    877
    Hope it is ok to chime in: Just my view on this, that is still a beta version to my knowledge, is it normal to support your product with a unreleased version of Unity?
     
  45. m1735

    m1735

    Joined:
    Nov 28, 2013
    Posts:
    9
    Also pink in 5.6.0f3.
     
  46. nbac

    nbac

    Joined:
    Jul 7, 2015
    Posts:
    239
    is the grass painter released yet?!
     
  47. Will-D-Ramsey

    Will-D-Ramsey

    Joined:
    Dec 9, 2012
    Posts:
    221
    Terrain Composer 2?
     
  48. Nonakesh

    Nonakesh

    Joined:
    Aug 27, 2011
    Posts:
    446
    I'll look into it again, I will post here when I've found the problem!

    Deferred rendering isn't possible with the grass, but I might add a grass mode that supports this in the future. The shader should work with image effects though. Are you using the Camera-DepthNormal shader that comes with the shader? This should fix problems with image effects.

    This can be fixed by either setting the base map distance on the terrain from the editor or via a script. With a script you can go over the maximum distance in the editor. Just set it to 10000, or a similarly large distance and you should be fine.

    It's working in the editor on my end. Is the problem only when compiling to Xbox One? I can't test this myself as I don't have a Xbox One. When you're selecting the shader, is there an error message in the editor? Or maybe in the log when starting your game?

    Yes, it is! When you select a grass mesh in the scene, go to the material section and click the button "Open Grass Painter", or when you're working with Unity terrain, select the terrain with the grass material, go to Windows > Stix Games > Grass Painter

    I haven't used it myself, but if it generates a mesh, you should be able to use the grass shader. It's just a shader, not a mesh generator, so compatibility should only rarely be a problem. If you have any assets that don't work together with my shader, please post it here, or send an email to my support mail address!
     
  49. SharpeDesigns

    SharpeDesigns

    Joined:
    Mar 4, 2015
    Posts:
    4
    Would love to try implementing this into our mac build as well. So is it GrassSurface.cginc that prevents this from working in OpenGL Core? Don't know a lot about graphics API's and their shader support, so I'm not sure where I'd even begin.
     
  50. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,301
    I must have missed this in the instructions... what do I assign this shader to?