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
- Unity Editor: Tree Generator
- Leaf/Foliage Generator Tools (Runs in Browser)
- Testing Unity AI Beta
- Ways to Support UnityCoder Development
- Using UI Slider to Create 5-Star Rating Element
- Game Music Library For Unity (editor plugin)
- Fontastic : Easily Test Fonts in Unity Editor!
- GeoTiff Importer & Terrain Generator for Unity
- Create Baked DropShadow for UI images
- .JP2 Ortho Image Converter to PNG/JPG/TIFF
- Convert LAS/LAZ/PLY pointclouds to GLTF (GLB) Point Meshes (standalone converter)
- Detect SRP (URP or HDRP) with Assembly Definition Version Defines
Recent Comments
- on Sprite Sheet Flip Book Shader
- on Sprite Sheet Flip Book Shader
- on [Asset Store] PolygonCollider2D Optimizer
- on Trajectory Test Scene 2.0
- on Vector3 maths for dummies!
- on UnityHub 3.6.0: Remove Version Control & Cloud Dashboard columns
- on Using RenderDoc with Unity (graphics debugger)
- on UI Scroll View automatic Content height
Coin:
CUgDSbRqFcAumDSAcdKDvuXsw26VdkJe8C8WGUQHBAGS
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/