Renderer using wrong rendering mode (Transparent instead of Opaque)

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?

2 Answers

2

Why are you assigning a renderqueue of -1? Should you not be using:

materialArray*.renderQueue = RenderQueue.Geometry;*

?

What do I need to import to use this line of code? RenderQueue.Geometry can't be found, "using UnityEngine.Rendering" doesn't help. I'm a noob regarding shaders etc. :/

Okay so the problem was not using the correct renderQueue. Setting it to 2000 is putting it into the Geometry queue which fixed the problem and made the meshes render in opaque mode.

A longer explanation can be found here

For special uses in-between queues can
be used. Internally each queue is
represented by integer index;
Background is 1000, Geometry is 2000,
AlphaTest is 2450, Transparent is 3000
and Overlay is 4000.

Thank you tanoshimi!