Hi!
I’m working on a project using very basic 3D shapes and a point light:
[72057-bildschirmfoto-2016-06-13-um-122949.png*_|72057]
No matter which shader I use for those objects (Standard shader with Opaque mode selected, Simply Lit shader with only lighting and one color property selectable), profiler tells me they’re being rendered using the transparent rendering mode. This results in very bad performance on mobile devices, getting worse with every “step” the objects get bigger and cover more area behind them.
[72058-bildschirmfoto-2016-06-13-um-122058.png*_|72058]
Am I missing something? I’m currently on Unity 5.1.5, tested on other versions as well with the same problem.
Thanks in advance,
Maui
EDIT:
Okay I think I got one step further. As the game proceeds, the floor-meshes get assigned materials that are reused so that the color can change gradually from one floor element to the next.
To get this working, I set up an array which gets filled with 30 materials at the beginning of runtime. They are then reused everytime a new floor element gets spawned at the end of the path.
I’m already trying to set the material’s shaders to Opaque like this: (found inside the Unity docs)
materialArray*.SetFloat("_Mode", 0);*
materialArray*.SetInt("SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
materialArray.SetInt("DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
materialArray.SetInt("ZWrite", 1);
materialArray.DisableKeyword("ALPHATEST_ON");
materialArray.DisableKeyword("ALPHABLEND_ON");
materialArray.DisableKeyword("ALPHAPREMULTIPLY_ON");
_materialArray.renderQueue = -1;*
But this doesn’t seem to really set the shaders to opaque, they are still rendered as transparent.
Maybe someone has a suggestion to even improve the whole thing so that I don’t need to create/use so many different materials and still have multiple colors for the floor elements at the same time.
Thx!
*
_*
Change your material?
– JatsArts