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
- UnityHub 3.6.0: Remove Version Control & Cloud Dashboard columns
- 2 Sided Lighting for Sprite Diffuse Shader
- Run webgl application locally using python
- [LudumDare53] Delivery
- Dungeon Crawler Jam 2023: Trials Of the Mage
- [GreaseMonkey] Display “Unity Version Added” info in API Docs
- Fake 3D Parallax Effect using Shader & (Pre-generated) Depth Map
- Using OpenAI API with WebRequest from Unity
- [LudumDare52] Theme: Harvest
- Painting with Compute Shader
- Draw Pseudo Hilbert Curve
- Unity Stable Diffusion plugin
Recent Comments
- on Three.js PlaneGeometry.js to Unity C#
- on 2D Visibility / Shadow
- on [Asset Store] Point Cloud Viewer & Tools
- on [Asset Store] Point Cloud Viewer & Tools
- on [GreaseMonkey] Display “Unity Version Added” info in API Docs
- on [Asset Store] Point Cloud Viewer & Tools
- on [Asset Store] Point Cloud Viewer & Tools
- on LineRenderer with Outline Shader
An article by











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/