A Unity ID allows you to buy and/or subscribe to Unity products and services, shop in the Asset Store and participate
in the Unity community.
Discussion in 'Assets and Asset Store' started by StaggartCreations, Jan 5, 2020.
ok, no problem, i will send it to you, agian thnx for the reply.
Working a new feature, which I had in the back of my head for a while. Where the grass length can be scaled, depending on how strongly a terrain layer is painted. This allows the grass to be shorter on certain terrain layers.
The height is saved along with the color map and works with tiled terrain setups and is GPU based, so bakes in a split second.
Yeaaa, that's a good idea! I think Genshin Impact does this for their grass too:
On an unrelated note, I think your colormap editor does not properly calculate the bounds for multiple terrain tiles. At least, when they share a corner all at 0,0,0.
Changing the logic for min/max bounds in the following way works, for all dimensions, seems to fix it:
if(max.x > maxSum.x)
maxSum.x = max.x;
Another suggestion I have is to maybe offer a conditional shader feature that blends the global colormap with the gust tint. Otherwise, if you use the color map for shadows on the grass for efficiency your gust tint will look very strange!
I fixed the bounds calculation for next update, noticed it acted up if terrains were under a parent object that had a negative position. It now works correctly in every and any case. But thanks for the headsup, would probably have gone unnoticed
Unfortunately due to the way/order color is composited your suggestion isn't viable. When using realtime shadows, the wind gust is hidden in shadows, but if they're baked into the color map, there's no way to accurately tell what represents a shadow or not.
Hi guys! My rendered colormap is much darker than the actual terrain, so when I apply it the grass is dark grey. How should I render the colormap to get true colors?
It seems like the Colormap renderer does not take into account directional lights, so the terrain is extremely dark
Ok, I solved it by baking my directional light
Hi @StaggartCreations, still loving the shader and excited for the next update. I had a question regarding performance. I'm using VegStudioPro, and have a rotating sunlight to simulate time of day. My performance absolutely tanks whenever the sun is setting (hitting the grass directly from the side). My grass isn't casting shadows but is receiving it, and at this point it's all receiving some sort of shadow with the light that low. Although perhaps it might have something to do with the translucency effect? Do you have any recommendations?
It's also possibly a VSP issue, I'm working URP and not sure if there's something going on there. I also still can't get wind to communicate between VSP and the shader.
Also, any luck on our discussions regarding omitting grass bends based on elevation above/below grass? Thanks!
Edit: Regarding the performance... sorry, just as I was typing that it occurred to me that it might have nothing to do with the grass and rather the way I'm rendering trees (a custom setup, outside VSP). I'll keep testing.
I've encountered the same sort of issue using VSP, though this is in a project that doesn't use this grass shader. It's due to the fact that a low sun angle a whole lot more shadows are being rendered, because VSP's shadow culling feature also renders shadows for vegetation outside the camera view, but within the light's frustrum. At a low angle, the light essentially "sees" more vegetation.
I haven't been able to mitigate this, except disable shadow culling, but this causes tree shadows to pop in. Pulling the shadow distance back 10% when the sun approaches the horizon made a bit of improvement. In any case, the translucency rendering has a constant but unmeasurable performance cost, it merely becomes more visible at low sun angles.
Despite several attempts, I haven't been able to fade out the grass bending when a bending goes below a grass mesh. It's still on my todo list, so I'll have another swing at it when a better idea comes up.
The wind strength can be controlled by assigning a wind zone to the Stylized Grass Rendering component. This'll multiply the ambient/gust wind strength value of the material by the wind zone's "main" value. Speed and direction can't be changed, since this would cause the grass to jitter, until the values are fixed. I can make a wind controller for VSP with strength, speed and direction controls if this doesn't matter!
Hello! I'm having a really strange issue with the latest LTS for 2019/ URP / Nature Renderer
Whenever I have grass on the terrain with stylized grass shader.. the grass pops in and out. You can see this happening in the video at the edge of the terrain in this example.
If I use another grass asset without the shader, this doesn't happen.
Here is how it looks in the editor. That empty space should have grass visible.
Thanks for the video, it appears the vegetation cells are being culled early or incorrectly. If you have "Procedural Instancing" checked on Nature Renderer, you'll have to ensure the grass shader is also using this configuration (by default it isn't). That may be the cause.
You can find this option at the bottom of the grass material:
Thank you for the quick reply. Yes I have the Third party shader config set to Nature Renderer.. and I have the the NR Procedural Instancing turned on. I've also tried turning it off for both.Still no luck.
Here's what my inspectors look like for both NR and SG.
In the Nature Renderer demo scene, I can reproduce the same result: https://gyazo.com/e862704458bf8c8dde03ff924e382941.
Procedural Instancing in this case doesn't seem to make a difference, and it also occurs when switching the grass material to the URP Unlit shader, so doesn't appear to be related to the shader being used.
Summoning @Visual-Design-Cafe, is this a known issue?
Thanks for testing that! Can you also confirm one last thing.
When I use the Visual Design Cafe grass assets I don't see this issue. I know you said you changed the grass material and still saw the issue. However when I used the grass that came with the Open World nature asset (also made by Visual Design Cafe), I don't have that issue.
I did some further testing, and it turns out if the grass prefab has a LOD Group, some grass patches don't get rendered properly like you're seeing. The "Grass Generic Group Medium" prefab included with NR doesn't have a LOD Group, which is why it does seem to work correctly. This somewhat makes sense, since the terrain detail system doesn't support LOD groups to begin with, but this worked in an earlier version of NR.
So you can either convert the "GrassPatch" prefab to not use any LODs, or create a new grass prefab using the same mesh and material:
Thank you SO MUCH for catching that! I don't think I would've ever figured that out lol.
I just tested it and I can confirm that it is broken. The issue is the culling distance set in the LOD Group. If you increase the culling distance to something like this (see screenshot) then everything should work fine.
Nature Renderer calculates the LOD distance based on tiles with a fixed size, instead of per-object. I think that in this case the culling distance is too close to the transition distance, and both fall within the same tile. This should still work correctly but there must be a wrong calculation somewhere and it ends up using culling the entire tile. I'll look into it and fix it for the next update.
Working on getting the v1.1.0 update out the door. This includes the terrain layer-based grass scale, and a number of fixes.
Last minute addition is a fix for "shadow acne" available for the Advanced Lighting mode.
(URP Lit shader on the left sphere, notice the banding artifacts)
The workaround for this is to increase the shadow depth bias in the URP settings, but this affects all objects, and also pushes the shadows cast by the grass away from the mesh, making them appear to slightly float.
With the fix enable, the shadows received on the grass are pushed away a very small amount. Meaning there's no self-intersecting shadows anymore, while keeping the shadows cast by the grass as is.
Shadow bias settings now no longer have any effect on shadows cast by grass. Meaning the settings can be tweaked for regular objects, without creating a gap between shadows and the base of the grass mesh.
Managed to get LOD crossfading working, added an additional LOD mesh to accomendate this. LOD0 now has more edge loops, which results in smoother wind animations and bending. This is something that has to be enabled on a prefab's LOD group:
Self-cast shadows don't fade correctly, where the shadows from the previous LOD are cast onto the next, so they still pop. But this is related to how LOD groups work and has been around since at least Unity 4
Submitted version 1.1.0. Change log:
- Colormap Renderer can now also render a scale map for grass, based on terrain layers. Allows grass scale to be determined by painted terrain layer strength.
Material now has a Vector3 field to control the scale influence for the XYZ axis. The "Apply scalemap" toggle must be enabled on a material.
- "Shadow banding correction" toggle. Offsets the shadows received by the grass a tiny bit. This avoids unwanted self-shadowing (aka shadow acne).
- Support for LOD dithered crossfading (requires to be enabled on LOD group)
- Height offset for mesh grass benders is now also applied to the wireframe gizmo
- Active color map is now re-assigned whenever scene is saved, to avoid the link to the shader being broken
- "Bending" section in material UI was renamed to "Vertices".
- Bending render area edge masking now also works when not in play-mode.
- Added additional edge loop to LOD0 of meshes. Added a LOD2 mesh with fewer vertices.
- Color Map Renderer
* Render area calculations when terrains have a negative position
* Handling cases where terrains are entirely flat
- (Preemptive) Warning about obsolete method in URP 9.0.0+ (2020.2)
- Shader error in URP 9.0.0, due to changes in URP lighting functions.
- Environment reflections not correct when a normal map was used on curved meshes.
- Specular highlight parameter, this was broken to begin with and translucency ends up offering the same visual result.
- Prefabs in Vegetation Studio Pro have to be refreshed to avoid shadow flickering issues
- Scale map functionality is marked as experimental, since all terrain layers currently have to be configured. Ideally, scale would stay at 100% for layers not configured.
Following update will allow a color map to be generated at runtime. And possibly add an "Unshaded" lighting mode, which is Unlit shading but with support for shadow casting/receiving.
Does this asset have grass physics?, for an example can this asset interact with players movement?, does it support full physics simulation?
Not exactly, the physics engine doesn't come into play because physics run on the CPU through scripting, where as a shader is something that runs on the GPU. The grass bending functionality is "fake", in the sense that the shape of a mesh, particle system or trail is translated in a way that a shader understands. This shape is subsequently used to push the grass down and away from it. But no actual colliders are being used.
Might be a stupid question, but does grass touch bending work when using Nature Renderer?
It does, this poses no conflict
Hi! Using MapMagic2, NatureRenderer and MicroSplat and when two terrains meet I'm getting this effect, is there any way to fix this? This is using the Unity Grass not Mesh Grass.
Haven't seen this before! Unfortunately doesn't immediately ring any bells as to what may cause this. Does disabling Procedural Instancing in NR make any difference?
So I am having issues with the shadows and the wavy lines in the grass. I have changed some parameters but nothing seemed to smooth it out. Could someone point me in the right direction
What you're seeing is shadow acne, this can be remedied by increasing the shadow bias/normal values in the URP pipeline settings asset (the one assigned in Graphics Settings). This is most noticeable because the grass planes are pointing up, towards the light direction.
You can also try the "shadow banding correction" toggle on the grass material itself.
Thanks so much for the help.
I would like to know if your system works with GAIA and also if it would work for a top down game?
I actually already bought your asset a few days ago, but now I'm reaching a point in my project that I would like to prototype a level.
I'm having a bit of a hard time with it... (I'm new to the graphic part of things. I'm more of a programmer).
Gaia spawns vegetation using the terrain vegetation system, so anything that works with it is automatically compatible with Gaia. There's a section in the documentation that covers using grass with the terrain vegetation system here: http://staggart.xyz/unity/stylized-grass-shader/sgs-docs/?section=placing-grass
As I recall, Gaia refers to trees as "prototypes", so that's maybe something to look out for.
For a top down game, the "perspective correction" feature may prove useful. This is a slider on the grass material. This bends grass away from the camera slightly, when it looks down, to provide the illusion of better coverage.
Hey there, love the shader, however I am not able to get the perspective correction to have any affect. In the demo scene I have set the Perspective Correction to 1 on the Stylized Grass which seems to be the grass used in the scene (set it to 1 on all of the mats just to be sure), however it still looks the same as it does with the value at 0.
I'm using 2019.3 with URP, any insight on how I might get this working?
I can't figure out how to use this with map magic and nature renderer... any tips?? Like I can assign the texture in map magic, and it looks fine and performance is great (I guess nature renderer is taking care of it?), but how can I get it to be the same color as the terrain / use your shader?
Note that you'll only really see it taking effect when the camera looks down on the grass, when looking towards the horizon the effect is rather subtle
I'm not super familiar with MapMagic, but it does use the built-in vegetation system, which NR in turn takes over rendering.
If you're adding grass as meshes, using the supplied prefabs will automatically ensure the grass shader is used. If you're using 2D grass billboards, you'll have to assign the StylizedGrass material to the "Material override" field on the Nature Renderer component.
For the terrain color blending, you can check out the set up steps in this documentation section: http://staggart.xyz/unity/stylized-grass-shader/sgs-docs/?section=blending-with-terrain-colors
Nope, no difference .
Thanks for the pointer. The error ended up being the hard-coded path to the NatureRenderer ccginc. This might be nice to call out in the docs somewhere, as I think most developers move their plugins at least into /Plugins.
I then got this error:
NullReferenceException: Object reference not set to an instance of an object
StylizedGrass.GrassColorMapRendererInspector.DrawLayerHeightSettings () (at Assets/Plugins/_Shaders/Stylized Grass Shader/Scripts/Editor/GrassColorMapRendererInspector.cs:229)
Somehow `script.layerScaleSettings` is null. Maybe this is something with how MM2 paints it's terrain? Probably want a null-check here?
So I commented out that entire if/else block since it seems like some advanced feature anyways.
Now my render button showed up, but clicking it gives me this:
So close! Any ideas?
After setting the volume manually, I was able to get a more accurate render in the color map, but getting very weird results on the Terrain itself. This is using StyledGrass material and terrain grass + NR:
Video of scene: http://shorturl.at/dyEW5
Still investigating this issue above, but I found another small fix for you. So, for some reason my `terrain.terrainLayers` has a null entry in it. I guess at some point MM2 inserted a null layer?
This causes a runtime error from ColorMapRenderer when I press "Add Active Terrains".
I fixed that with a null check (and also removed the nulll texture layer from MM2), and still getting a very odd colormap render:
I tweaked the code to leave the camera in the scene, it seems to be rendering fine, so I'm pretty confused... here's a video:
I have a problem. I followed the instructions and put the color map component onto the scene but in the inspector it still says no color map active and renders everything in red.
Thanks for the headsup! I didn't consider a terrain layer may be empty, but I'll add a check for it first.
The red you're seeing if the hidden render camera cutting off. The blue box that represents the render area should cover the entire terrain in both width and height. For the width, this has to be exact (but can be smaller). But for the height it doesn't matter, as long as the volume is tall enough to encapsulate the entire terrain.
As for the render, I'm positive Azure is interfering. It probably has a Render Feature added to the default renderer, which subsequently is used by any created camera. So the Azure effects end up unintentionally being rendered into the color map.
For now, a viable workaround is to create a new Forward renderer in the Project window through Create->Rendering->Universal Render Pipeline->Forward Renderer. Then assign this to your pipeline settings:
Then set this to "Default". As a result, any newly created camera's aren't going to have any special effects on them.
On your main camera you will have to switch the renderer from Default, to the CustomForwardRendererData, which has Azure applied to it, and possibly other effects:
This is something I can circumvent, by temporarily creating a new "clean" renderer, and using that, so no setup would be needed. I've added this to my todo list
Would you mind sharing a screenshot of your terrain, with the Colormap Renderer component selected? The blue box should wrap around the terrain.
For me that Colormap texture just ends up looking white/greyish - sort of like a baked AO map. I also had the above issue of having to add a renderer on the bottom of the stack, but I solved that with using layers instead. The bounding box is set up correctly and wraps around the entire terrain, and from what I can see in the baked out map it's catching the entire terrain, it's just super bright.
Using MicroSplat and MapMagic2.
If I could make a feature request, it would be some way we could trample the grass over time. Basically applying some color, and bending/shortening the grass. Something like a PersistentColorizedHeightBender. Clamped to some color and height ranges (so the grass can't get too short, or too colored)
This would allow us to walk through our large islands, leaving trails as we go, but also to track monsters that have run through the grass previously One can dream....
Does your default renderer have any Render Features attached to it, by any chance? Like third party post processing effects?
Looks great in action, thanks for sharing! I've managed to automate this process. To verify, if I add a post processing render feature to the default renderer, it also appears in the color map. With the fix in place, this is no longer the case. I'm aiming to submit an update some time this week that includes it.
Early on I played with persistent bending, where grass benders acted more like a brush on a canvas. But this didn't quite pan out. If a trail was running from left to right, and you moved forward, it would start flattening the grass over its length.
Trails and particles always have a lifetime, so they will die out eventually. An alternative would be a Line Renderer, where points are created like breadcrumbs as objects move around the world. Currently Line Renderers aren't supported, but this is straightforward to add. But adding color, on a per-bender basis isn't, this is too specific I'm afraid.
I made a test script, which creates a line as a trail, I can probably integrate the same functionality.
public class LineTrail : MonoBehaviour
public LineRenderer lineRenderer;
public float pointDistance = 0.25f;
public float width = 1f;
private Vector3 currentPos;
private Vector3 lastPos;
private Vector3 positions;
private List<Vector3> positionList = new List<Vector3>();
private void OnEnable()
lastPos = this.transform.position;
positions = new Vector3;
private void Update()
public void Clear()
positions = new Vector3;
public void UpdateTrail()
if (!lineRenderer) return;
currentPos = this.transform.position;
lineRenderer.useWorldSpace = true;
lineRenderer.widthMultiplier = width;
if ((currentPos - lastPos).magnitude >= pointDistance)
lastPos = currentPos;
positionList = positions.ToList();
positions = positionList.ToArray();
lineRenderer.positionCount = positions.Length;
//Fix last point to current position
Massive Clouds are from Atmos, Caustics is from https://assetstore.unity.com/packages/vfx/shaders/stylized-water-for-urp-162025
Pushing the Render Button in the ColorMap Renderer makes the whole terrain white-ish until I go into Play mode, then the terrain fixes itself.
Thanks for the screenshots. In this case Atmos/Caustics are being applied to the color map render. More often than not these features don't support orthographic cameras, which may explain why it looks so strange.
In any event, a fix for this will be available soon. So render feature can no longer affect the color map.
Thanks for writing that code snippet I'll try it out!
Ya I hear what you mean, that's why I think it kinda needs to be a combination of color, height reduction, and bending.
For reference, here is an effect I made with GrassFlow that I absolutely loved, and really would like to make work with this. https://www.reddit.com/r/Unity3D/comments/i9xwit/added_some_stylized_grass_and_that_leavs_trails/
It works as a brush, reducing height as you walk over (with a min size), and painting on some color (to a max opacity) + some permanent bending. Result is that you walk over a place 3 or 4 times and all of a sudden you have a very nice, clearly defined trail.
Another reason a paintable height map would be nice is we could use it to cut the grass when the character swings their sword, or places down a structure. Currently we can cut grass using terrainData, but it's pretty slow
Thanks! Any possible ETA on that update?
I'm also experiencing weird pop up for the new grass LOD's, there's no cross fading and they just pop in around the character after a while - not even at a distance.
I am using SteamVR and the Perspective Correction does not work for me. It just doesn't do anything.
Also, the colormap feature is nice. But is there a way to maybe get the same color/ lighting for the bottom of the grass than for the position of the terrain it's placed on? So it would fade into the terrain. It's still very easy to see the polygons when close to the grass. For VR it just isn't very pleasant to the eye.
Thank you for your hard work
I noticed this to, the grass is not lit the same as the terrain.
I read somewhere you're supposed to make the normals of the grass be flat, instead of up, so it gets the same lighting as the terrain. Not sure if that would be a viable fix?