Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Pixel Perfect Shadow Caster (2D) for Unity

License

NotificationsYou must be signed in to change notification settings

aniketrajnish/PixelPerfectShadowCaster2D-Unity

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)

comparision

How To Use

  • 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 hasRead/Write Enabled in texture import settings
  • Change theCasting Source ofShadowCaster2D toPolygon Collider 2D
  • Change theTrim Edges ofShadowCaster2D to 0
  • Set theAlpha 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

Contributing

Contributions to the project are welcome.

License

MIT

Acknowledgement

Thankful to O3 for Contour Tracing Algorithm.

About

Pixel Perfect Shadow Caster (2D) for Unity

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp