Skip to content

Surface shaders with flipbook / spritesheet animation functionality

License

Notifications You must be signed in to change notification settings

thnewlands/unity-surfaceshader-flipbook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flipbook Surface Shader for Unity

This is a surface shader solution for flipbook animation with spritesheets in Unity. I've been using this so that I can add shadows to flipbook animations without going through Unity's sprite system.

Setup is relatively simple:

  1. Create a spritesheet with even spacing between sprites. For my spritesheets I've been using: https://www.johnwordsworth.com/projects/photoshop-sprite-sheet-generator-script/ and generating source sprite images in 3d Studio MAX. This makes it especially easy to get normal information for renderings.
  2. Plug in your spritesheets to a new material with Custom/SurfaceSpriteSheet
  3. Set the number of rows / columns and then the number of overall frames. --- I count the number of overall frames in case of incomplete rows ---
  4. Set it loose! You can use the animator to set the frame number over time or make it loop using the built in animation speed variable!

Improvements / suggestions for other variations:

For foliage -- blend the bottom of the geometry with the ground by orienting the normals to the surface. This is easiest for flat surfaces with which you can just set the normals to point upward in a vertex shader.

Try implimenting billboarding -- In the past I've used this solution to good effect: https://gist.github.com/renaudbedard/7a90ec4a5a7359712202, note that it won't batch correctly out of the box.

About

Surface shaders with flipbook / spritesheet animation functionality

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published