Foliage shading softness


Always having an issue with foliage shading model. It looks very nice and soft towards light source and so hard and noisy when you start looking to sides/back.
I think if there was a way to make SSS affect surfaces even when you’re not looking towards the light source it can help make the foliage look s a lot softer. Here’s a detailed lighting view. You can see on the right it feels a lot more like grass and on the left it’s more like hard spikes. Any solutions?

1 Like

Are you using a normal map? What do your vertex normals look like? I can’t say I’ve noticed this issue unless I have a very strong normal map and/or messy vertex normals. I generally have the meshes following the normal of the terrain, which helps make them feel more volumetric and softer in my opinion.

Point all of the grass normals vertically or very close to it. It helps a lot with the shading. You shouldn’t need to use SSS if you just use the foliage shading model(it has a lot of that stuff worked into it already).

VertexNormal - polycount has some great information on normals.

It doesn’t really look much different in regards to lighting whether there is a normal map or not. My mesh normals are pointing in their default directions. Making them point upwards means as if they are flat surfaces facing upwards and makes them reflect the Sun light unrealistically.

I’ve setup a similar scene in cryengine, it helps demonstrating the issue better.
In both cases Sun angle is 20 degrees. In cryengine it looks much more consistent. (It has a bit noise to it due to me not knowing how to switch to better AA in that engine).

I can sleep a bit better now.
Needs a bit more work though.

well, how did you do it? :slight_smile:

Aye - be sure to post solution at some point!

Get directional light’s right and left vector and use that to bump up SSS intensity in material, use forward vector to prevent SSS blowing up when looking towards direct light.
I’m still tweaking and trying different things with it to make it look more like cryengine.

So, here are my thoughts on foliage shading:

Firstly, it worth mentioning, that if tangent space normals are enabled in material, your normal will be flipped for backface. While it is desired behavior for grass cards with default normals, if you are using foliage with edited normals, the backfaces will have incorrect normals. Using foliage with edited normals implies disabling disabling tangent space normals and handling normals yourself in the material using two-sided sign.

Secondly, SSS and foliage shading models receive both direct and indirect subsurface color. The latter one is obtained by sampling environment cubemap in the direction, opposite of the normal. If your grass cluster normals are pointing upwards, they will sample the skylight from bottom part. Needless to say, that if skylight is set to use black for lower hemisphere, you won’t get any subsurface from indirect light.

Thirdly, there needs to be a good balance between skylight and directional light intensity. In case, when latter is overly strong, there will be distinct separation between zones of dominant subsurface and surface, as shown by Maximum-Dev. It feels that tweaking subsurface intensity separately for direct and indirect light we pretty good thing to have, but this one would be only tweakable per light, not per material.

Fourthly, pointing grass normals straight up, as was mentioned, is a questionable suggestion, when realistic look is concerned. You’d want every grass blade to have some sort of distinct specular highlights, preferably corresponding to grass blade orientation, supported by normal map.

Fifthly, subsurface color should not differ considerably from albedo, when foliage is in question. This is actually quite important to overall look.

Sixthly, foliage shading model could be altered a bit.

Seventhly, if normal map is in use, it also helps if its intensity is high enough to shift surface-subsurface balance from card level to grass blade level.

Lastly, as suggested by Maximum-Dev, rotating normals towards camera instead of pointing them up, is a good supplement to unify grass shading, while not causing uniform ugly white sheen.

Good post, but bending the normals is still an easier approach to take. Example: Look at how you handle foliage normals in speedtree. The same applies to grass. I should have reiterated that you don’t have to point all of the vertices perfectly straight up, but transferring them from a spherelike object tends to give better results. Basically, all the normals bend slightly more toward the z-axis, with the topmost normals almost perfectly straight up. If needed, you can still mitigate a lot of the upper tip issues with normal maps or with a vector3 gradient for a normal(far cheaper route) that you have bending in a specific direction (you can calculate it based on things like light direction in an MPC).

It’s always going to be a trade between quality vs performance. Strike a good balance of the two and accept that you’re not going to get both.

Regarding that last line, here’s how that looks like in cryengine.

It makes a lot of difference in grass softness and consistent lighting, reducing the spiky look as well as receiving better SSS.
I’m doing a bit of experimenting with two sided shader code atm (trial and error) and made some improvements. But I haven’t been able to do this normal orientation thing in UE4 so far. :s

It does help, but it is not targeted at issue with seeing distinct zones, when looking perpendicular to light direction. Well it does help, but to limited extent.

I’ll just go ahead and mention, IMO, that in DEATHRAY’s comparison I vastly prefer the left.

Every artist in every game seems to want the “soft, indistinct” grass look, and in my experience this just doesn’t look good nor realistic. Grass doesn’t magically fade into the ground, nor become blurry and indistinct in life. Why there’s the obsession with doing so in ALL game art is beyond me. I understand art direction, but it’s in every game regardless as if this is somehow “correct”.

Here’s an example I took personally of a little grassy dip. You can clearly see each blade of grass, just how distinct and contrasty it is from the ground, and just how sharp and spiky it feels:

An issue we have in game engines is that they are still very far from emulating real life physics, we just dont have the ability to make everything 100% accurate to real life, and in our attempt to do so with current techniques a lot of the time produces sub par results. So although the shading method above is not exactly accurate to real life, it is more pleasing on the eye within our current limitations.


Found a solution. Changing 2 values in shader code solves the problem forever. Check it out in the link below! :smiley:

Up there I’m using one direct light at 20 degrees angle, it’s shining from right to left with 125,000 Lux (bright sunny day) it’s definitely the left image that’s looking wrong and the modified shader looks a lot more believable.
And here’s the material setup, a bit shifting SSS to yellow just so we can feel some light passing through.

If I use your normal orientation setup along with the modified shader it will look a little nicer than what I posted above. Thanks a lot for that. :slight_smile:
Will do a some tweaking with values in shader code and share it here in a bit.

Again, to me it just looks worse. If the darkness at the bottom was lessened the sharper grass would look a lot better to me. But soft grass is just a thing artists all seem obsessed with. It’s gotta be soft because everyone says it’s gotta be soft, and you can’t go against the wisdom of the crowd. Well why not?

It’s not about individual grass blades it’s about grass fields and making their transition to ground look seamless at far distance when they get culled and that can be achieved only if grass meshes look similar to landscape grass layer in terms of color and brightness all around. That’s why we don’t want blown out SSS on front, darkened grass on sides, and bright grass when turning back.

Yep, any kind of normal trickery eats details. That is why that kind of controls should be always exposed, and it is unlikely that one is going to use it at maximum intensity.


Can we have some sort of common ground truth in discussion, other than CE? Something like photo of grass field with sun being relatively low ?

Hard to find a reference of flat grass field with sun being low and on the side. But here’s a setup under more decent lighting. You can see SSS on right, grass is slightly saturated there compared to left. My eyeballing says it looks fine apart from being a bit noisy. That’s with sun at 20 degrees. In reality sun with such angle has a lot less intensity though.

May I ask what was those? I’m going a little bit desperate of this problem but this probably is beyond my current knowledge.