27
2012
Shadow Casting + Convex Hull = More Fake Shadows
Combine Simple Shadow Casting & Monotone Chain Convex Hull and you have…more fake shadows for unity indie!!1
Works fine for a box..should try the teapot next.
Details:
– Calculate vectors from the light, through every vertex in target object,Β lengthen the vector until reach ground (y=0)
– You get list of points in the ground, convex hull them to get shadow outline
– Create shadow mesh from the convex hull points
Ideas:
– Try multiple lights? Multiple objects?
– Soft shadows? (shader)
– ShadowMesh could have trigger collider, to check if object enters shadow?
– Use ShadowMesh as a mask for something else..(?)
– Only cast shadows for objects in view? (or objects within _ – range from light?)
Webplayer:
http://unitycoder.com/upload/demos/ShadowCastingConvexHull2/
Download source:
shadowhull1.unityPackage
—
Image#2: Deep profiler report (array sorting seems to take most of the time..)
Related Posts
12 Comments + Add Comment
Leave a comment
Recent posts
- [GreaseMonkey] Unity Forum Fixer
- UnityHub: Make Hub application background Translucent
- Customize SpriteShapeRenderer quality (but has issues)
- Editor tool: Copy selected gameobject’s names into clipboard as rows (for Excel)
- Editor tool: Replace string in selected gameobject’s names
- UnityHub: Enable built-in Login Dialog (no more browser login/logout issues!)
- Use TikTok-TTS in Unity (with WebRequest)
- Create Scene Thumbnail Image using OnSceneSaved & OnPreviewGUI
- webgl+javascript TTS
- Using Moonsharp (LUA) + Unity Webgl
- Using 3D gameobject prefabs with Unity Tilemap + NavMesh Surface
- Custom Unity Hub Project Template Preview Image/Video (using HTML+CSS in package description)
Recent Comments
- Vector3 maths for dummies! on
- UnityHub: Make Hub application background Translucent on
- UnityHub: Make Hub application background Translucent on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- [Asset Store] Point Cloud Viewer & Tools on
- [Asset Store] Point Cloud Viewer & Tools on
- ffmpeg stream raw video into Unity Texture2D on
looks promising, always a pleasure to check your blog π
Interesting. Does this technique allow projection on uneven surfaces? That’d be very good to achieve.
No it wouldnt work, as it just creates a flat (shadow) plane. Maybe with some modifications, but not sure how..
this is really kul!
This is what I need for a 2D project of mine. So basically, this, except simpler.
Do you think you could help me out with my forum thread when you have spare time? Casting mesh shadows is driving me up the wall, I just can’t figure it out. I’ve been trying for hours and I’m about two seconds away from total insanity.
http://forum.unity3d.com/threads/132728-Need-help-from-someone-who-understands-mesh-generation-%28Advanced%29.
not sure if this would be the best for 2D..
how about this kind of shader idea,
http://forum.unity3d.com/threads/102079-Dynamic-shadows-in-Unity-Free-Pro-possibly-Mobile
or those 2 links that i posted on the forum..
It is possible to obtain code for this? I would like to experiment or improve this. I just see code latter everywhere π Can you zip and email it please? I would be pleased.
..even a very small donation is enough for a special “Source-to-Your-Email”-service : )
I’ll post it there later also..just would need to clean it up a bit, add comments etc.. but havent had the time yet..
Hey there, really nice work, could you possibly share the code for this? I would be very grateful!! π (trying to build something similar for a university game prototype…)
yes, i’ll add it within few days (remind me if i forgot : )
cool thx a lot! π
added source, but something is broken (tested on 4.3), shadow is not visible..(?)