10
2014
Shadow Casting 2D
Another fake shadow test.. (similar to the old raycast version, but should work with Physics2D).
*This is currently abandoned..
See also:
http://unitycoder.com/blog/2014/10/12/2d-visibility-shadow-for-unity-indie/
Info:
– Testing PseudoAngle to sort object positions
Todo:
– Take shadow caster PolygonCollider2D vertices, check which one are visible to play
– ..
Webplayer:
http://unitycoder.com/upload/demos/Dynamic2DShadows1/ (v1, update speed is 0.1f)
Related forum topic:
http://forum.unity3d.com/threads/165283-2D-Dynamic-Shadows
—
Snippets:
PseudoAngle (c#)
float pseudoAngle(float dx,float dy) { float ax = Mathf.Abs(dx); float ay = Mathf.Abs(dy); float p = dy/(ax+ay); if (dx < 0) p = 2 - p; //# elif dy < 0: p = 4 + p return p; }
Related Posts
5 Comments + Add Comment
Leave a comment
Recent posts
- 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)
- Check if point is inside polygon 2D (using line intersection)
- UnityHub: Enable Create Project Button (without having to select Cloud Organization)
- UI: Make Tooltip background fit Text content length
- Pong-Wars in Unity
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub)
- UnityHub: Add support for custom project title (instead of folder name) or use ProductName
- Testing Unity MUSE AI
2D Geometry calculations:
http://tog.acm.org/resources/GraphicsGems/category.html
Faster Line Segment Intersection for Unity3D/C#
http://www.stefanbader.ch/faster-line-segment-intersection-for-unity3dc/
FasterLineSegmentIntersection (source)
http://forum.unity3d.com/threads/17384-Line-Intersection?p=1135726&viewfull=1#post1135726
raycasting, optimized shadows (web javascript example)
http://gamemechanicexplorer.com/#raycasting-3
seems like good explanation here: (with sources)
how to create 2D visibility/shadow effects for your game
http://ncase.me/sight-and-light/
how light works
https://ciechanow.ski/lights-and-shadows/