Feb
10
2014

Shadow Casting 2D

dynamic_shadow_casting_1

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;
}

5 Comments + Add Comment

Leave a comment

Connect

Twitter View LinkedIn profile Youtube Youtube Join Discord Twitch

UnityLauncherPro

Get UnityLauncherPRO and work faster with Unity Projects!
*free unity hub alternative

@unitycoder_com

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.