Today I& #39;d like to talk about the shader I made for The Adventures of Wolf and Hood. It& #39;s what gives the puzzle pieces their realistic look but it also allows for a cool visual effect when you complete a puzzle. 1/9 #screenshotsaturday #gamedev #indiedev #jigsaw #madewithunity
The shader is actually pretty simple, just a main texture plus a shadow and normal map derived from the shape of the puzzle pieces. The cool bit is how these are smoothed away around a position in space (the final mouse position) with the effect radius controlled by script. 2/9
I also add an expanding particle system to give it a bit more interest and to make it look like the particles are smoothing out the joins between the pieces. I use a sprite mask to keep the particles inside the puzzle frame. 3/9
Now, here& #39;s where it gets weird and nerdy. What follows is going to be a tedious explanation of a problem I had with the Android build of the game, which took me weeks to figure out. Only read on if you& #39;ve had shader problems on mobile with Unity 2019. 4/9
The PC build worked just fine, and when building for Android the editor version looked fine too. However, when testing on an Android device the smoothing effect just wasn& #39;t right. The joins between the pieces didn& #39;t go away as intended. 5/9
The odd thing is in Unity 2018 it worked just fine, so something had clearly broken in the upgrade to 2019. I tried everything I could think of and I won& #39;t bore you with what didn& #39;t work so I& #39;ll just describe what I did to finally fix it. 6/9
I changed the order of the exposed shader properties in Shader Graph. Makes no sense, right? I change the effect radius value of the material via script but for some reason in the Android build that wasn& #39;t working. But if I moved that property up in the order it worked fine. 7/9
I verified this with the other properties and found the effect centre (set by the final mouse position) would also stop working if it was in a particular place in the property list. I solved the problem by just trying different orders until it all worked. 8/9
I only change a couple of the properties via script so as long as those properties could be changed then all is well. But it& #39;s still super weird and clearly an issue that could catch you out. If you& #39;re having similar problem I hope this helps you fix them. End of thread. 9/9
You can follow @StoneBakedGames.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled: