Everything except for two colorful cubes (the biggest and the smallest ones) uses the default “Legacy/Diffuse” shader.
These two colored cubes use a simple modification of this shader which sets emissive color.
Directional light is set to “Baked” mode, the pink spotlight is “realtime”.
Now, the main question.
Why do the realtime shadows disappear when I enable “Baked GI” in the Lighting window?
For some odd reason this only happens in Forward rendering path mode. When it’s set to deferred, shadows suddenly come back.
P.S.: Why the pink spotlight is baked to lightmap if it’s marked as realtime?
This forces lightmap to re-bake each time i tweak this light’s parameters or move/rotate it. It’s realtime. I guess, it shouldn’t get baked at all.
The part of this issue about baking realtime lights is still there: that pink spotlight is baked to lightmap despite it’s marked as realtime.
However, I just found a solution for “missing shadows” part.
I discovered surface shader needs to have “fullforwardshadows” parameters to allow spotlights to cast shadows. Either there was no such option the last time I checked documentation or I didn’t notice it all time I’m wrighting shaders. Sorry for falce alarm
Anyway, I think you should indicate it explicitly in the shader’s name. That this shader doesn’t receive spotlight shadows in forward rendering. Maybe, create two variants of default “Legacy/Diffuse” shader the same way you did with “Mobile/Bumped Specular”.
I actually experience the same issue here. Same as you are. i’m using forward rendering path. and i wanted to make my dynamic object cast shadows on my lightmapped static assets. But i failed in the process as i don’t know what i’m doing wrong.
i am using a custom surface shader that uses a ramp to lit the object. I tried many different things and my shadow do appear while unity is baking. But as soon as the GI baking is done the shadow dissapear. And what’s more frustrating is the fact that my character has glasses and receive the shadow of the glasses on his geometry. but there are no shadow on static objects. As you can see with this picture.
When @Lex-DRL said he fixed his issue by adding “fullforwardshadows” to his shader. i though it would fix my issue but it didn’t work for me. The shadow applies on the dynamic character with all the different kind of light (point light, spot, directionnal).But it doesn’t apply on static meshes.
I didn’t open a new thread because i found this was pretty similar to the issue a encountered
i hope someone can highlight me and help figure out what is going wrong and how i can fix this. And also i would like to know if a vertex/fragment shader could help fix these kind of issues. but i’d rather use this surface shaders and not swith to differed path.
@tuemiste
First things first.
It’s extremely difficult (if possible at all) to debug a complex scene.
You need to provide the least possible number of steps to reproduce your issue on the empty scene.
So first of all you need to isolate the problem. You don’t think these cubes and balls are the actual game I’m creating, do you? I created this simple scene specially for debug purposes. So should you.
Create a simple set of objects (cubes, balls, quads for ground) in the empty scene.
Mark some of them as static so that there will be all the possible scenarios: dynamic objects casting shadows to static, static to dynamic, static to static and dynamic to dynamic.
Create a new material with default “Legacy/Diffuse” shader and apply it to everything.
Create some lights. There also should be at least one static light in “baked” mode, dynamic lights in “realtime” and “mixed” modes… and all the possible combinations (baked/realtime/mixed + static/dynamic).
Each of these lights need to illuminate each type of created objects (static/dynamic + shadow caster/receiver).
And now start tweaking a scene. Change the material’s shader from default diffuse to your shader. Has anything changed? If not, then problem is not in the shader (and it should also appear with default one). If yes, then try to recreate a more specific scenario: what if your shader is applied to a shadow caster object and shadow receiver has default one? What if vice versa?
And then, step by step, start discarding scenarios where everything is fine.
This is how I got the scene displayed above before opening this thread. Initially there was about a hundred of cubes/balls with about 15 light sources.
I guess you are absolutely right i shouldn’t come with such a complex picture to illustrate my issue.
Even though before posting i did all the above you mentionned. I got here while googling “fullforwardshadow”.
I just didn’t feel the need to make a simplistic scene for this thread as your pictures perfectly illustrated my issue.
I did try changing mixing, baking, realtime, static / dynamic. And everything. it just didn’t work…
But i know why now, i figured you had an issue with your spotlight baking while it was set to realtime. wich doesn’t happen in my scene. with the “same” settings. the reason why is because i defined a culling mask.
This culling mask was preventing my dynamic object to cast shadows on static objects. It was my bad from the start
I guess you cannot have a setting with culling mask where a specific light only affect actors and these actors cast shadow on other layers. That is why my actor was receive shadow and not my static object.
i don’t know if this was meant to be. but in any case i thank you for your quick reply. you did help me