After a bit of experimenting in Unity, I found that while Z test is impossible to run in alpha blending, you can get away with it in Alpha Clip. This opens up a few nice possibilities, namely that you could turn backface culling off with alpha clip without sorting issues. This means you can have a  2 sided material for about the same cost as a one sided material – 2 passes as normal, instead of 4 passes to cover base and fill lights for 2 sides. I flip the normals on the backfaces so that normals are accounted for correctly. This works OK but you may run into weird shadowing on high angles of incidence. For now i’m rolling with it, but I am open to any other suggestions :)Thanks to this, I thought it would be a good time to try out flat translucency. It’s basically a super cheap subsurface scattering approximation. This is useful for leaves or other paper thin materials that allow some light to pass through. I based my implementation on Crytek’s implementation of light transmission, featured in this paper. My implementation is a bit simpler to save a few instructions, but the idea is basically the same. Just skip past the vertex animation for now, I’ll get to that later 🙂
Lit from the front
Lit from the back

Maya CGFX File:

phongnormalflattranslucency.cgfx
File Size: 8 kb
File Type: cgfx

Download File


Unity SHADER File:

phongnormalflattranslucency.shader
File Size: 11 kb
File Type: shader

Download File


Leave a Reply

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