Hello, I’m trying to create a shader for the iOS to make meshes look like fluffy clouds. I’m pretty new to writing shaders for unity and have run into some trouble.
My original idea was to combine a fresnel like alpha (rim alpha) with a cloud texture alpha to have the model fade out towards it’s edges in fluffy lumps. I could not find a way to create a fresnel “rim light” effect however. At least not without getting into the more advanced surface shader stuff, which I’m under the impression won’t work on iOS.
Instead, to try and fake the rim alpha effect, I tried making a texture with a radial gradient and sphere mapping it to the model. This almost worked quite well, except it creates some ugly artifacts around the edges of the models:
I would really appreciate some help with either some way of cleaning up those rendering artifacts or achieving the rim alpha effect I wanted. Here’s the code for my current shader for the above picture:
That impression is incorrect. Any iOS device that could handle your four texture stages can use GLSL. Work with the dot product of the view direction, and normal.
I haven’t tested the current shader on an actual iPhone yet, only in graphics emulation. I plan to reduce it down to two texture stages if I do end up using it.
Good to know that the surface shader stuff can work with iOS, now I just have to learn how to write it…
Also, thanks for those video tutorials you made. They’re how I learned how to write shaders to begin with.
I’m pretty sure that this is caused by my using alpha instead of alphatest, but I can’t seem to get alphatest to work. I’m not sure how to use it. An explanation of how to use alphatest in surface shaders would be nice, or any other ideas on how I can get the visible area properly opaque?
Okay, I’ve kind of figured out how to get alphatest to work. But it looks terrible with rough ugly pixelated edges, and the hard edges don’t have that fluffy cloud feel. is there really no middle ground method available?
Note that I’ve also moved it into the “Transparent” queue, so it gets drawn after everything else. This is a quickly knocked together example:
Also, don’t use AlphaTest on iOS, it’s known to have a drastic effect on performance.
In other words, is there a solution which will always keep the edges faded, regardless of where the camera is? Because if I spin around this one, it develops a hard edge at any other angle than head on