Solution to unexpected issue (Patreon)
Content
This was quite frustrating. At first we thought we had to abandon the shader, which would suck extremely hard considering the amount of time we've put into it. Reading the forums didn't help much or give any hope either. As a matter of fact, none of the fur shaders available in the Unity asset store support receiving shadows. And these guys have been trying to get it to work for far longer than we have. So if they hadn't managed to solve it by now, how could we do it?
At this point, we seriously thought we were fucked. Obviously we cannot use a shader that doesn't support receiving shadows. Any character using such a shader would look completely out of place when indoors, or when another character is casting a [non-visible] shadow onto him/her. However, having invested so much time into this, we refused to let ourselves be defeated by such an unexpected issue. It seems so trivial, yet apparently it is quite a complex problem getting true transparency and shadows to work (in any engine, not just Unity).
After much blood, sweat and tears, we're happy being able to show this result:
http://i.imgur.com/xthPG9k.png
It may not seem so impressive, but I don't think you realize the amount of trouble we had to go through to get it work. And apparently, no other fur-shader maker has managed to do so! So it feels almost unreal that we managed to achieve this when they haven't.
I won't go into details what magic we are using to accomplish this, but I can give you some other information. Right now, the highest quality fur shader we've got is actually 977 lines of uncompiled (!) source code. If you're uninitiated to how shaders work, you may not realize how much that is for a shader. It is HUGE.
What's more - because we required more control of how Unity renders the shaders, we had to go away from using Unity's simple way of creating shaders ("surface shaders") to writing our completely own fragment and vertex shaders (in essence circumventing Unity almost entirely). While being harder to work with, they are also faster than surface shaders. So by bumping into this problem, we manged to get a speed improvement as well! (In addition to supporting shadows.)
I understand that this post might come off as a bit of a brag or something. But never having written a line of fragment shaders previously, it just feels amazing to actually having overcome such a huge issue that apparently other fur-shader makers haven't solved! And we're so happy right now that we can keep the fur shader.
It would seem that, where there's a will, there's a way. :)
Unfortunately, this unexpected issue also means we're a bit behind schedule. We might still be able to release on Sunday, but there's a risk there will be a delay.
- odes