12
2014
2D Visibility / Shadow
Started converting this 2D visibility/light script ( http://ncase.me/sight-and-light/ ) to unity, finally some progress!
btw. lines are drawn using GLDebug from : http://www.unity3d-france.com/unity/phpBB3/viewtopic.php?f=24&t=5409
Unity forum thread: http://forum.unity3d.com/threads/2d-visibility-shadow-free.275698/
—
TODO:
– Quad segments are currently crossed..
– Fix mesh generation *Temporary fix: insert extra boxes outside the view..
– Source cleaning up
– Publish to github
– Optimize
– Some documentation
– Try raster version (bresenham + floodfill)
– Support for moving objects
– Sprite support (but unity indie has quad sprite mesh, no tight mesh generation..needs extra script to generate helper points for sprite image edges..?)
– Better system for finding edge segments
– …
Stats:
– 20 obstacles (~80 vertices) : ~45-50ms per frame (in editor, with slow’ish pc)
Webplayer:
http://unitycoder.com/upload/demos/2DVisibility/v1/ (v1, still broken)
http://unitycoder.com/upload/demos/2DVisibility/v2/ (v2, almost done)
Source:
https://github.com/unitycoder/2DShadow (Please help improving the code!)
Previous attempt:
Shadow casting 2D : http://unitycoder.com/blog/2014/02/10/shadow-casting-2d/ (using pseudo angles, unfinished
—
Image#2: Few problems fixed, mesh still broken..somehow cannot make the light vertices go in to “correct” world space(?)
—
Image#3: Mesh fixed, but still starts “stretching” when mouse moves away from center..
—
Image#4: Good enough..(added hidden boxes outside the view, to avoid broken mesh *hidden box idea from denamond)
—
Image#5: Current profiler view, gets quite slow with many objects..need to start optimizing
—
Image#6: Testing visibility with Martt’s dual camera depth mask system (see the 2nd sphere is partly hidden)
Related Posts
31 Comments + Add Comment
Leave a comment
Recent posts
- MotionVector Effect: Object “disappears” when paused
- [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
Recent Comments
- [Asset Store] Point Cloud Viewer & Tools on
- [Asset Store] Point Cloud Viewer & Tools on
- 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
Hey, did you ever get around to releasing the code to this, I would be really interested?
yeah, very soon (inital versio is ready for github, just didnt have the time yet : )
Cheers mate, I appreciate it!
Its alive: https://github.com/unitycoder/2DShadow
Hi, the source files in GitHub looks broken (the total size is 37 kb).
Man, thanks for your great contribution for indies developers.
Github zip looks ok, its quite small since there are no images, not much code either etc. (that image#6 demo is not included, as it was just quickly hacked together…needs work/cleaning up)
You’re a genius man! Everything is working with no errors, just wanted to know where the scripts go and how I make the scene. Thanks again, so much!
2D Dynamic Lights and Shadows (free, works with sprites)
https://www.assetstore.unity3d.com/#!/content/24083?aid=1101lGti
Hi mgear, i’ve try to get effect like –> Image#6: Testing visibility with Martt’s dual camera depth mask system — > but i can’t get it.
can you send me a little help ?
I downloaded his demo package,
http://forum.unity3d.com/threads/skynox.124019/#post-1007954
And removed all the extras, expect the dual camera system.
thanks man, but I still can not get it,. Can you post the project file and see what I am doing wrong?
This one has nice features!
2D Light of Sight:
https://github.com/f15gdsy/2D-Light-of-Sight-Unity
2D per pixel shadow maps:
https://github.com/brianasu/2d-pixelshadows
VLS2D is a 2D light creation system:
https://github.com/reveriejake/VLS2D
vishull2d (Computes the visible region from a point for a given environment represented by a collection of line segments) *javascript (not unity):
https://github.com/mikolalysenko/vishull2d
Damn man, i love you. Amazing work!
Field-of-View
https://github.com/SebLague/Field-of-View
Vector lighting explained
https://www.facebook.com/notes/monaco/vector-lighting-explained/395139091995/
A simple 2d/3d visibility effect in Unity
https://github.com/OskarSigvardsson/2d-3d-visibility
using 3D objects and light to cast 2D shadows:
http://piranhacms.org/blog/fast-beautiful-2d-lighting-in-unity
Fast 2D shadows in Unity using 1D shadow mapping
https://www.gamasutra.com/blogs/RobWare/20180226/313491/Fast_2D_shadows_in_Unity_using_1D_shadow_mapping.php/
Realtime 2D Raytracing in Unity using Signed Distance Fields
https://github.com/Robert-K/light2D
2D SDF Shadows
https://www.ronja-tutorials.com/2018/12/01/2d-shadows.html
VisibilityPolygonCSharp
https://github.com/xaviergonz/visibility-polygon-csharp
2D lighting system using commandbuffer
https://github.com/SardineFish/Unity2DLighting
GPU Line of Sight / Field of View visualization for Unity
https://github.com/EntroPi-Games/GPU-Line-of-Sight
tilemap shadow casting
https://github.com/BrianCraig/Tilemap-Shadow-Caster
Field of view visualisations
https://github.com/SebLague/Field-of-View
visibility using sprite mask
https://forum.unity.com/threads/how-can-i-show-only-the-part-of-a-sprite-thats-behind-a-mask.1265504/
Script for generating ShadowCaster2Ds for Tilemaps
https://forum.unity.com/threads/script-for-generating-shadowcaster2ds-for-tilemaps.906767/
cast rays on the edges of nearby objects and then filling the space between the rays by generating a mesh
https://github.com/aniketrajnish/optimized-2d-lighting-unity