- Notifications
You must be signed in to change notification settings - Fork2
Pixel Perfect Shadow Caster (2D) for Unity
License
NotificationsYou must be signed in to change notification settings
aniketrajnish/PixelPerfectShadowCaster2D-Unity
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Pixel Perfect Shadow Caster (2D) for Unity using Contour Tracing!
Comparison between the following shape providers:
SpriteRenderer
that usesSprite.vertices
PolygonCollider2D
that usesSprite.GetPhysicsShape
PixelPerfectShadowCaster2D
that uses contour tracing (ours)
- Download either:
PixelPerfectShadowCaster2D.cs
&PixelPerfectSpritePathCalculator.cs
- latest
.unitypackage
fromReleases
- Import scripts into project
- Attach this script to a shadow-casting sprite
- Make sure the sprite has
Read/Write Enabled
in texture import settings - Change the
Casting Source
ofShadowCaster2D
toPolygon Collider 2D
- Change the
Trim Edges
ofShadowCaster2D
to 0 - Set the
Alpha Threshold
to the desired value, any pixel with alpha < threshold will be trimmed - Remove the script from the sprite after using it
Note
Using thePolygonCollider2D
as a mediator to set the path of theShadowCaster2D
instead of directly applying it as Unity recommends leaving the code withinUnityEngine.Rendering.Universal
untouched!
px_perf_shadow_cast_2d_how_to.mp4
Contributions to the project are welcome.
MIT
Thankful to O3 for Contour Tracing Algorithm.
About
Pixel Perfect Shadow Caster (2D) for Unity
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published