- Home /
Combined transparent mesh, lit vertices showing from underneath
This is a little hard to explain, but I'm having a lighting issue when trying to light a 2D character with a single mesh and transparent texture.
This character is an FBS file with a single mesh, material, and rig - but all done in 2D. For nice soft edges, I'm looking to use alpha-blending and avoid the sharp edges that come with "cut off" shaders. I'll be writing a custom shader for some other effects eventually, but this issue also occurs when using the standard shader (Transparent Rendering Mode) with a Diffuse and Normal map.
For performance, I'm combining each limb into a single Skinned Mesh Renderer, which first gave me problems with the display until I realised it's based on the order in which triangles are drawn. To correct this, I separate each limb slightly on the Z-axis, have a script re-order triangles front-to-back, and then give each vertice a z-position of 0.
I then introduce a single point light, also with a Z position of 0, which looks fine when none of the limbs overlay:
However, when limbs overlap during animation, the lighting caused by limbs underneath show up over limbs that are drawn last:
Is it necessary to also find a way to change the order in which lighting is handled? Or is there an inherent limitation to overlaying transparent textures in a single mesh? Leaving the vertex positions alone seemingly has no effect on this.
This area isn't my forte so I appreciate any advice. Thanks!