Hello All,
I am trying to, on import into Unity, set the shader that each material uses based upon the information in the model. The issue is that to determine what shader the material should use, I read from the texture. Some of my models re-use parts of textures that contain alpha but do not use that alpha information. I want an efficient way to figure out if my model is using any of the alpha information on the texture it uses.
I have achieved this, BUT, it is way too slow to be practical.
Current Solution:
I am looping through all of the pixels of the texture applied to my model’s material and checking to see if those semi-transparent pixels fall inside the any of the UV triangles on my model. If it doesn’t fall inside any of the UV triangles then I set the shader to not use transparency.
The only optimization I have tried so far is to limit the pixel information I read by looking at every 16 pixels (any higher and I think i might miss the portion that is alpha’d). I am also looking into limiting the number of UV triangles I’m looping through.
I would welcome any help with this issue even if you aren’t familiar with C# or unity. This needs to be fast because it is part of our workflow to unity. If you can figure out a way to reduce the time it takes to figure out if my model uses alpha information on my texture please let me know!
Thank you!
Also, our workflow is 3ds Max> .FBX > Unity