Bug Report/Feature Request: SurfaceManager multiple material fix

Brendan

New member
SurfaceManager line 410 defines any renderer with more than one material as a complex material and then reverts to a triangleindex based approach to detect which material applies to the specific location the raycast hit. Surely this should be checking the MeshFilter subMeshCount, not the MeshRenderer's sharedMaterials count?

Unity's default behavour if there are 2 materials and 1 submesh is to render the same mesh twice, once with each material. There are several reasons why a simple single submesh object will have multiple materials, such as a procedural overlay or a visual effect like a glow or terrain blending effect. In this case it's not a complex model where you need to rely on triangleindex.

The triangleindex method also fails automatically on convex meshcolliders, so it would be best not to revert to this method if the simple one will work.
 
It has been awhile since I looked at the surface manager code but on the surface (hah!) this sounds like a good idea. I will take a closer look at it and let you know after I figure out more.
 
Top