Download

Grass lighting

I am trying to achieve this (no light and only emessive):
grass 2.PNG.jpg

But I get this with directional light:
grass 1.PNG.jpg

If I make the grass unlit then I get what I’m looking for but then I don’t get any shadow of the tree or the player on the grass. I want to keep the color same throughout the environment and only have dark area where the shadows are present. I also disabled mesh casting shadow from mesh editor, so I don’t why there are dark area in the grass
grass 3.PNG

Thank you

The shading is coming from the vertex normals, point all the vertex normals straight up and it will match the shading of the terrain better (provided you are aligning the grass meshes to the terrain normals). It still won’t match your unlit version but it will be consistent.

I’m not sure there is a convenient way of getting the grass to behave the way you want without implementing a new shading model with the forward renderer. Someone’s already done this though if you’re willing to compile the engine from source: [WIP] Anime/Toon Stylized Shading Model - Unreal Engine Forums

I think its pretty easy to just do it without engine compiling.

First, you definitely have to fix the normals.

Second you have to bake the normalized Z value of each vertex into the vertex paint and squash the mesh flat before export.

Then, within the material you can multiply the vertex paint by a height factor, plug into the displacement as B and this will grow the grass.
you can use PerInstanceRandom to create variations across meshes, so not all the grass is the same height - but it is the same mesh and the cost is minimal.

So far so normal. We have almost all been doing this for ages. Performs really well and it also allows you to do more things in the future, like easy grass trails.

The next part is to cook up your shading.

You have the vertex paint, which can already help, but you can also offset the brightness (since you said you want it emissive) by the same height parameter you use to grow the grass.
This should - at least thats the theory - allow you to create the same variations you see in the image you shared, where the tip of the blades grow brighter.

The tips will always need to have the same color, so you need to subtract a scaled value of the height from the brightest color possible to shade the mesh.
the cost should be minimal. Probably less then using a dedicated AO texture.

However if you have performance issues or use VR you may want to ditch the custom height parameter and use the vertex paint straight up.

How would I Fix the normal is there any tutorial I look at, I’m fairly new to unreal.

You do that in a 3d application.

If you use bender you can look up tutorials on it.
rotating vertex normals became a menu options in .28… the visualizer is purple and they all need to pint up vertically.
when you squish the mesh they have a tendency to change…

It worked. Thank you so much.

Enable worldspace normals and plug in 0,0,1 into the normal

Not the same thing at all. the grass isn’t always pointed upwards.

I know. It does work for the most part, though.

why is there an effort to get grass to always point straight up on the z axis? If it’s for ‘realistic’ grass, then it would be not always pointing up…it would’ve grown in different vertical directions and according to slope.

Pointing the normals up and aligning to the terrain provides accurate shading of the grass that matches the terrain shadowing.
using a fixed z up doesn’t have the same result at all.

just transform 0,0,1 from local to world and you get local z-up, same as editing the mesh :wink:

still not the same. you can use actual normal maps if you modify the mesh normal. On tall grass that’s kind of necessary. on small stuff it doesn’t matter really.

you can still combine normalmaps with shader local z-up. sure it’s more expensive but it’s actually doable in cases where it’s necessary.
for example on realistic grass I usually do the regular normal up close and fade it to the local z-up at a distance. this way my semi-far grass isn’t as noisy, and when it fades out due to cull distance the transition is also less drastic