Shadows is too expensive.

Hi all!

One question about shadows. I have one directional light in my scene, and it is configured as “stationary”. I have many objects, that can cast shadows. Scene is look like this:

GPU Profiler shows that a lot of time spent in the shadow casting. Every object take 0.1-0.2 ms for casting shadow.

Is it normal situation? Is there way to optimize shadow casting? I repeat I have only one light source. By the way, I have disabled Preshadows. Don’t understand what is this, but it takes too many time too :slight_smile:

Hope for your help!

Questions: Is this for sunlight? Does the sun move during gameplay? One idea is to include the shadow as a part of the game piece, with a pre-baked, translucent shadow on an alpha-textured “******-like” base around the bottom of the model. One drawback would be this would not cast shadows on neighboring pieces, though if the sunlight were in a more “high-noon” position, this would become less of an issue…

Why would the word, “******” be censored?? Okay, clearly this means something else to someone in charge here, so I’ll post a picture of what I’m referring to:

Btw, “Pre-Shadows” refers, I believe, to the process of computing shadows ahead of time & baking them into the textures, which is usually only helpful for environments. It’s much akin to what I’m suggesting. So, to expand, here’s some tips about how to implement what I suggest:

In your model viewer, position the model as though you’re looking down on it from the direction of the sun. (Tip: Do this using repeatable keyboard commands for the sake of consistency!) Turn off the material, & dhow the model with flat shading, (white on black, for example.) Take a screen-shot, & bring it into GIMP or Photoshop. Edit this image into your texture map for the model’s material, being sure to include it as the alpha-channel.

Next, add a flat square faces around the bottom of your model, sitting just above the ground. Add the texture you just created to this square.

That’s the basic idea. Instead of computing these shadows every frame, you’ve got a pre-baked shadow for that piece all ready to go.

If any of this isn’t clear, just ask.

Thanks for answer! But yes, sun can move. It is static only on level, but between levels direction can change. For example, one level is sunny day, next level is cloudy evening. So I can’t use prerender shadows. I can use prerender decal shadows only for characters :frowning:

Is there way to change shadow’s technics? Or disable receiving shadows for some objects? Or I do something wrong? Just I look on StarCraft 2, and there are hundreds objects and they all cast dynamic shadows and all looks fine and fast.

By the way. There is great difference between on/off shadows. But no difference between shadows quality. And this is strange too.

r.ShadowQuality 0

r.ShadowQuality 1

r.ShadowQuality 3

Weird… No idea what the word is since when I try to view it, it won’t show me. Can you PM me the word and I’ll bring it up with Epic Staff so somebody can look into it? Just separate the letters if you have to.

Use a movable directional light with cascaded shadow maps. That way it only renders one shadow map (or few, depending on the number of cascades) which in turn means you don’t get the overhead of per object shadows as you see in your GPU profiler.

Thanks for the advice, but I think this is bad solution. Since I have some big movable objects (like an old windmill), and fake shadows will be too expensive to implement.

Big thanks for the great solution! I made some test. And they are very encouraging. On the test scene got a 10 fps increase.

“Dynamic Shadow Distance MovableLight” set to 5000.

“Dynamic Shadow Distance MovableLight” set to 20000.

Perhaps some light settings can increase FPS much more.

Try setting the cascade count to 1 to see if it helps resolution. Since you have a top down camera it doesn’t make any sense to use cascaded shadow maps that vary the cascade resolution based on scene depth. If the camera is far enough away, using the most high-res cascade for basically nothing.

I’ve taken “Flange” out of the censored words filter. It was in there by default (we made our list with a lot of pre-built stuff) and it is considered an insult in some places. It’s unfortunate that there is not an “intent” or “context” filter for so many of these common words that are also used as insults.

I know why, it is a rude colloquial/slang term in some parts of the UK and Vbulletin has/had 2 major coders from the UK so the base rude word filter may include it.

Lol about the flange, here ppl are using the word shoe to insult each other - so please add it to the filter ))))