I am currently in process of adding small static details to my scene. Stones, Fungi, stuff like that.
I really would like these things to cast realtime shadows, at least up close. But I am aware that I might shoot myself in the foot with that as the amount of shadow casters seems to have a big influence on realtime shadow performance.
I am using a separate layer with a low layerculldistance set to make sure to render only the instances close enough to the camera to actually be bigger than just a pixel or two, and static batching should reduce the overhead of the many small meshes without having to combine them.
But I don’t know if static batching does work for shadow casting (does it?)…
So I have thought of different strategies to optimize the performance of the shadow casting part of these objects… could someone with more expierience on optimizing realtime shadows give me a “yay” or “nay” on wheter these are viable strategies to reduce the impact of these objects on shadow performace?
Combining multiple close instance to bigger meshes. Instead of just letting static batching do its thing, and probably shadows not getting batched at all, I could create bigger groups of objects, which certainly would be treated as a single shadow caster. Not sure if that would break static batching though for the visible meshes.
Using simplified proxy meshes for shadow casting. Turning shadow casting off on the visible mesh, and using a simplified mesh just for shadow casting. I would guess a 12 tris mesh would cost less time to be rendered into the shadow map than a 100 tris mesh.
Of course there might be problem with selfshadowing and stuff like that… so I wonder if its worth the hassle.
But, on the flipside I could add the proxy meshes to yet another layer that gets culled earlier, so that only the really close detail meshes cast shadows. Also, I could again group the proxy meshes into larger chunks so that they get rendered into the shadow map in chunks instead each mesh individually.
Does any of this make sense to reduce the impact of many shadow casters on realtime shadow performance?
I went ahead and did some of my own testing. Answering my own questions:
Yes, it works. Baking multiple meshes to one big mesh drastically reduces shadow caster count. Static batching on the other hand doesn’t work, as the documentation states.
I went ahead, duplicated the meshes, used one with shadow casting mode set to off as visible mesh, and one with shadow casting mode set to shadows only just for the shadows. The shadow casting meshes were combined into one large mesh, the visible meshes were left for static batching do do its thing. Seems to work fine.
Haven’t tried reducing polycount yet, though I guess I would need much a larger testscene to make any useful statement if it works or not.
The separate layer cull distance setting for the shadows on the other hand works like a charm. definitely going to experiment more with that.
idk if it help or is similar issue, but I had a mobile project with shadow, what I did was rendering the shadows by myself and saving different cascate shadows on every Channel of my shadow image, RGBA.
I got a good performance on CPU, GPU and memory. my final shadow texture was around 256kb with 4 shadows, and they were pretty soft shadow. the only issue was that im not using depth texture but for my camera view point was ok. also I draw the objects directly to the gpu and skip the camera (for not skinned mesh).
And was nice to have full control of the shadow, color, blur, opacity, edge etc.
Hi
I have a suggestion please consult me.
I thought maybe it could to bake shadow of tree into texture in blender then save it as PNG with alpha channel and import as sprite in project and attached it to the tree prefab as a child .
Is this method good for optimization on mobile when we have forest or a hug number of trees ?
Note to picture below that the palm shadow is a sprite.
Since many of you may strugling with realtime shadows on mobile more than me I have a question for you
I’m currently using a very lowpoly LOD for realtime shadows of my objects. so i.e my car with 10+ parts and ~100k polycount is using a single lowpoly shadow caster (1k polycount) that only cast shadows and itself is invisible to the camera.
However there is an issue that the caster partly cast shadows on the car itself as well which I dont want it to happen.
Does my approach (lower poly count for casters) has any positive effect in a larger scale or am I wasting my time strugling to fix the issue caused by this technique (casting some shadows on the self object)?
There might be another way by that I mean maybe reducing the Alpha of a material to 0 and maybe get the same result? I haven’t tested that though
Also, In Unity 5 and above, a “Shadows Only” option in the shadow settings of the mesh renderer component is available.These objects only cast shadows and are not rendered
The video is funny but are they talking about? There is built-in support for only rendering a shadow. No need to buy a plugin
Skinning usually has a much higher cost than just rendering a lot of polygons. GPUs are quite good at rendering tons of polygons nowadays. But when you are duplicating a skinned mesh, you also have to animate and skin two meshes instead of one - which has considerable cost on the CPU and the GPU