2D Toolkit Forum

2D Toolkit => Support => Topic started by: zettam on April 10, 2014, 10:18:09 am

Title: Tangents and Normals?
Post by: zettam on April 10, 2014, 10:18:09 am
Custom shader caused this error

Shader wants normals, but the mesh  doesn't have them
UnityEditor.DockArea:OnGUI()

I've set my collection settings to generate both tangents and normals, however the error is still there. What's the quick fix for this?
Title: Re: Tangents and Normals?
Post by: zettam on April 10, 2014, 10:43:31 am
UPDATE: My custom shader works with regular sprites. It doens't work with fonts in the collection.
When I set the material of any image based sprite to the material that uses my shader, it works nicely (no errors) however when the same material is set for any fonts in the correction, the error is there.

I believe the current version is TK2D is not generating normals and tangents for the fonts, even if it's set in settings.
Title: Re: Tangents and Normals?
Post by: unikronsoftware on April 11, 2014, 02:09:04 pm
Its not creating them, simply because of the additional overhead. If you need it you can call mesh.RecalculateNormals() where it RecalculateBounds() in tk2dTextMesh.cs. You can fill constant values into the normals (0,1,0) and tangents (1,0, 0, 1) I think should you want to do that as well.