[Unity] Dynamic Jigsaw Puzzle Generation #3

[ Puzzle Unity Package ] < Right Click and select “Save Link As…”

Now with batching! I’ve improved my shader code to now use vertex colors as a way to store data for which mask to use on which edge.

This allows the pieces to batch. (e.g. For a 100×100 puzzle it’s now only 2 draw calls and 998 batched!)

And don’t forget to set all three of the texture mask’s to use Wrap Mode: Repeat. Otherwise you’ll have issues.

 

19 thoughts on “[Unity] Dynamic Jigsaw Puzzle Generation #3

    1. Check my response to Denis to see if that fixes it for you as well. It seems to be dependent upon what Unity version you’re using or perhaps the graphics API of the project.

    1. Check my response to Denis to see if that fixes it for you as well. It seems to be dependent upon what Unity version you’re using or perhaps the graphics API of the project.

    1. So I think we found a fix for this. Somewhere down the line (2018, 2019?) either the Quads UV indexes got changed or they’re specific to the graphics API the project is using.

      The solution is to update the indexes to:
      uvs[0] = new Vector2 ((i – 1) * uvWidth, (j – 1) * uvHeight);
      uvs[2] = new Vector2 ((i – 1) * uvWidth, (j + 2) * uvHeight);
      uvs[3] = new Vector2 ((i + 2) * uvWidth, (j + 2) * uvHeight);
      uvs[1] = new Vector2 ((i + 2) * uvWidth, (j – 1) * uvHeight);

  1. Hi and good evening. This works really well with square images and it is spectacular. What do I need to alter to prevent stretching of non-square images? Is it possible to do that?

  2. Hi Stephen

    Love your puzzle tutorial. Do you have availability to take on small game projects? I’m looking for someone to help get a jig saw puzzle into my project.

    What’s the best way to get in touch with you? Your social media links don’t go to your personal pages. 🙂

    Thanks!

    1. Yeah I should probably link my socials at some point. Haha. Can just email me at sdomenici009@gmail. Not sure if I’ve got the time at the moment but send something over and I’ll get back to ya. Thanks!

  3. Just thank you! You saved me hours and hours of photoshop cropping and masking 😀 THANK YOU!

Leave a Reply

Your email address will not be published. Required fields are marked *