- Home /
Can I cast real time shadows on lightmapped objects?
I've been working in a test scene and I just can't seem to figure out why it doesn't work while it's probably quite obvious. I've already spent many hours looking for the answer but I simply can't find it, so here it goes:
I'm using Beast to bake shadows on several objects in my scene which I have marked as static. An image of the scene can be viewed below. I've baked both point lights on the cubes and the plane by using 'bake selected' and excluded the blue ball by not selecting it. Everything seems to work just fine, but after the scene is baked I can't seem to project any real time calculated shadows on the lightmapped objects anymore. The blue ball can cast a shadow on any new object I bring into the scene, but not one of the lightmapped ones.
Is it possible for the plane and cubes to receive additional shadows of none-lightmapped objects such as the blue ball? If so, how would I achieve this?
![alt text][1] [1]: /storage/temp/1983-lightbaking_testscene.jpg
Thank you for your time.
Answer by Edy · Aug 18, 2013 at 12:04 AM
I assume you've marked "Lightmap Static" on all objects but the sphere.
The behavior of the realtime shadows strongly vary depending on the Rendering Path.
In Deferred Lighting with Single Lightmap you only choice is to use Realtime-only lights, which also affect the lightmapped objects. Auto lights will cast realtime shadows from static (lightmapped) objects onto dynamic objects, but not the opposite. In your scene with Auto lights, the cubes cast realtime shadows on the sphere.
Alternate option: Forward Rendering + single Directional Light in Auto mode.
This light will cast realtime shadows from dynamic objects onto lightmapped objects. Note that in Forward Rendering the realtime shadows are limited to a single directional light. You can use other lights to bake the lightmap, but they won't cast any realtime shadows.
Full details here: http://www.edy.es/dev/docs/unity-3d-lightmapping-reference-guide/
That is a very thorough and well illustrated guide, Edy. Nice work on that - answered this same question for me. Cheers.
Answer by Bovine · Jul 18, 2012 at 08:38 PM
Is the ball set to cast shadows?
What shaders are you using and what is your render path? I'm not sure if you can have shadows with Lightmapped geometry that's vertex lit for example - you can't even have real-time lights working without writing some funky shaders.
Are you running Unity Pro? I believe real-time shadows are a Pro feature:
Thanks for taking your time to help me.
I'm running Unity Pro, and the ball is set to cast shadows. In fact, it casts shadows just fine. It just doesn't cast shadows on the objects that are lightmapped.
$$anonymous$$y render path is deferred lighting and I'm using default diffuse shaders.
NP, What are your quality settings set to? Your shadow distance/settings?
Does the help throw anything up?
http://docs.unity3d.com/Documentation/$$anonymous$$anual/LightmappingInDepth.html
Is the ball shadow being baked into the lightmap and then ignored - what is the Lightmapped setting on your light? Is your ball static?
$$anonymous$$y quality settings are on fantastic. $$anonymous$$y shadow settings are as follows: Shadows: Hard and Soft Shadows Shadow Resolution: Very High Resolution Shadow Projection: Stable Fit Shadow Cascades: Four Cascades Shadow Distance: 100
The shadow distance should be well within range and throwing it up doesn't make a difference. There's also a shadow distance setting in the lightmap display. When I play with this using dual lightmaps I can get the sphere to cast a faint shadow, but I'm not really looking for shadow blending because it's a game with top down perspective.
I'm not trying to bake the shadow of the ball at all. It's not a static object because it represents the moving objects in my scene. I'm using the auto lightmap setting on my lights.
I just figured out that I can duplicate the lights I'm baking,and set the duplicates on RealtimeOnly, the lights I'm using to bake on BakedOnly. This way I actually can cast a real-time shadow of the blue ball on the baked objects. It's a bit of a workaround though, because the scene gets a bit too bright or the shadows a bit too faint because I'm now using two lightsources, but it's something!
Any idea if I can use the same light for the baking and the real-time shadows? I can imagine this gives a better result. Right now it looks like this: http://i48.tinypic.com/2vrwhea.jpg But I'd like to have some more distinct shadows (shadow strength is already set to 1).
Could it be the issue described in the 3.5.2 release notes?
http://unity3d.com/unity/whats-new/unity-3.5.2
See the issue mentioned at the bottom.