How to deal with huge amount of foliage?

So I’m working on an underwater scene. And lately I’ve been focusing on the visuals. The ocean bottom is a landscape mesh with rock and sand textures. It looks ok. I made some sea weed foliage just to see if it would make it look even better. It’s a single face with a grass texture on it. As basic as can be. And it actually makes the ocean bottom look more organic, more real. To the point where it looks odd in areas where there aren’t any foliage. Which makes sense I guess. An ocean bottom is seemingly covered in algea and weed after all.

So I painted away with foliage all over the map. I rebuilt the lighting at 64K instances of foliage. And that’s just a start, I stopped there to see if UE would be able to handle that amount. Because it started to feel a little ridicilous. And yup, building lights took forever. And complained about light map resolution. I get a feeling I’m not doing it right. I’m probably not suppose to have like 100K instances of foliage in a scene. I’m wondering how the pros go about this. I mean, if you have a huge forest or medieval battle fields with large areas of grass, do they really have like 500K instances or whatever of foliage? Or do they simply spawn grass around the player at runtime?

Well, how about you just disable shadows altogether for the foliage?
its not very realistic to have shadows underwater anyway, since in theory they cast differently then outside of air - because of caustics.

And as far as “how the pros go”, they too turn off shadows. Some more aggressively then others.

The grass is almost always rendered at runtime.
its cheaper, and you really don’t need shadows on it at all for the most part.
if you want to nitpick you can enable shadows in a 1 to 2 meter camera range. Disable entierly thereafter.

why? Because each strand of grass is usually around a max of 1cm. At a meter distance you can barely distinguish the grass blade - so the shade it casts is usually even less noticeable.
it is - generally speaking - enough to fake the effect by having the albedo be darker at the bottom then at the tip.
Which also translates well to sub surf, so it solves 2 issues.

the next thing is to use distance fields for trees.
https://docs.unrealengine.com/en-US/…ion/index.html

That can help lessen the load while providing decent distance looks… it’s kind of hard to balance on foliage, honestly.

Another foiage thing that is cool, but eats away at performance is the option to affect dynamic lightning.
supposedly, in a heavy fog scene the effect can be cool and natural. In practice, I lose over 20fps by just enabling it with 150 instances… for no return since my fog isn’t that heavy.

Last tip.
Watch From Ants to Outerspace, the livestream making of explanation.
a few good concepts explained there by @Hourences

I can’t believe I never thought of disabling shadows. But in all honesty, the more I think of it, I should just skip foliage.

I’m toying around with a submarine game. I happen to have geek level knowledge of submarine warfare. So the idea is to operate a submarine and try to find enemy submarines. The scene, or rather the ocean, need to be quite big for the whole scan-for-enemy-idea to be meaningful.

Cruising a huge ocean hunting submarines with sonar is probably the most boring game idea ever. Not to mention there already are way better submarine simulators out there. So my idea to make up for the boredom was to make it visually stunning. With corals, foliage and fish. Maybe some rusty ship wreck too.

the problem with the visuals are the size of the map. Think of it as cruising with an airplane. You’d need a lot of trees to make it look like huge forests on the ground. A lot. Whatever cows and lightpoles you put on the ground won’t be very visible. And least of all stunning. An old plane wreck on the ground would be so tiny you’d hardly see it.

I think I just need to come to terms with that I’m building a boring game, that’s very far from visually stunning. I don’t think foliage is going to change that.

You either disable shadows on the foliage, or you disable pre-built lighting altogether. Make the sun movable, turn on “Force No Precomputed Lighting” in your world settings, and enjoy a world where shadows just work, with zero lighting build times! (It will be slow/battery draining on mobile, though.)
It’s clear to me that pre-built lighting is slowly going away. Things like distance field pre-computation may still be a thing, but when you look at the demos of Lumen, and the push towards ray tracing, it’s clear that real-time is the future.

If you want to disable shadows on the foliage, you probably want a second landscape layer texture that is “ocean bottom, shadowed,” and manually paint that in. You could even use a procedural foliage spawner, tied to that material layer, so you spawn your seaweed only where you have painted shadows, and it’ll probably look OK with the appropriate density settings.

Sounds like you want to spend a year designing this up…
just enable world composition and bake an LOD with the shadowing.
or, make a capture camera to take a 2048x2048 texture capture with whatever custom rendering features you need and use the end result as the landscape’s LOD material.

As far as precomputed vs dynamic lighting. It will never really go away since the benefits of a close environment on less capable systems are vital. But you are correct in stating that things seem to be getting better without using it.
Maybe some day there won’t be a need to hang on to the precomputation. Maybe.

That’s not really doable for someone rendering on a single workstation, no matter how many cores there are.
A small 300x300 meter area with a few thousand trees and maybe ten thousand bushes will take all night to render at “preview” quality.

It’s instant just like if you were playing the game. use a render target inside unreal, not an external DCC.
OR are you just talking about building light for the level? In that case you aren’t wrong. that’s when you hijack all the PCs you find around and build your self a poor-man swarm :stuck_out_tongue:

Yes. Which is why I suggest turning off pre-computed lighting.

On which I agree, if the situation is right.
technically to bake the lod you don’t need to bake lighting if you set up for dynamic.
you do need to jump a few hoops to get the shadows correctly on the landscape using a manual scenecapture2d but its not too terrible.

At the same time, given I have over 11k tiles in the current project its not like I would even attempt a bake. Kind of wonder what would happen if I did… 365 days bake time? :stuck_out_tongue: