- Home /
Any way of getting shadows in Unity Indie
Hi again, I know that there are no dynamic shadows in the non-pro version of unity however does anyone know of a way around this. I am trying to make a scary game and so shadows are very important for this.
what I am looking for are:
any downloadable addOns enabling dynamic shadows
Work arounds possibly using raycast or linecast to check if there is something in the way of the light(don't mind if it is complicated but if it is code please make sure it is javascript)
Anything that is vaguely useful for creating shadows of complex shapes or just a plain, definite answer that it is not possible so I don't waste anymore time trying
Thanks for your help
Scribe
Answer by skovacs1 · Dec 10, 2010 at 07:57 PM
Unless your shadows need to be dynamic (which usually they actually don't need to be, you should consider:
- Baking your lighting in another program. Into the textures or into lightmaps. This is one of the best solutions.
- Shadow projectors.
If you really need dynamic shadows, you might try:
- Animated lightmaps. Can be quite expensive, depending on your setup.
- Animated Shadow projectors
- Writing a shader that projects backfacing vertices back into space to create shadow volumes. Can be complicated, expensive and suffers many other limitations.
- Defining meshes at run-time to create custom shadow volumes. Even worse than writing a shader to do it.
Thanks a lot, I'm planning to make monsters run across the walls and throw large shadows so I think I definitely need dynamic shadows. You gave a lot of detail so i'm going to do some further research into your suggested methods. Thanks again.
Hmmm. Throw large shadows as projectiles? I would recommend a particle system in that case. Or do you mean it as in casting large shadows? Bear in $$anonymous$$d that shadows are made large by proximity to the light source. Something you could try is a shadow projector which changes fieldOfView based on your proximity to the light and rotation based on direction to the light source. Of course that won't adjust if your shadow casters turn such that the shadow doesn't properly represent their contours. To compensate, you might have an animated texture advanced based on orientation, but that's a pain.
I have already been trying to figure out a way of making the projector field of view adjust as the distance changes just with a plain sphere but I haven't managed to get very far. I was trying to find the extents and make them the use them to adjust the field of view but it didn't work (I'm not that great at scripting but getting better) I will continue adjusting my scripts for this technique if you think it might work.
Just out of interest is there no way of using raycasting to say for example: If raycast hits, allow light to hit this surface if raycast is blocked by something don't light up
A raycast would be a fairly costly way to do it as you would have to do it for every light and every shadow projector. A cheaper way would be defining a simple volume for the lights, adding the projecting objects when they enter the volume and removing them when they leave. Updating the projector would be done based on a simple subtraction of the positions of the two objects. The magnitude or magnitude squared of this result can be used to deter$$anonymous$$e distance, and this result is the direction to cast the shadow.
Answer by yoyo · Dec 10, 2010 at 09:23 PM
Casting shadows onto a ground plane is easy. It doesn't handle the project-on-wall case you want for your game, but might be useful in some situations.
There's an article in Game Programming Gems Volume 1 that explains ground plane shadows. (The technique could potentially be generalized for other planar shadows.)
Thanks for the link I will continue to read it as i haven't got very far yet
Your answer
![](https://koobas.hobune.stream/wayback/20220613090534im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
What is this lighting issue? 1 Answer
Object drops shadow without accepting light 1 Answer
Shadows pass through meshes after baking 0 Answers
Custom Lighting shader issue w Spot/Point lights and atten 0 Answers
What causes this shadow? (w/ image) 0 Answers