a very slow and heavy scene with mirror script... why???

hellooo all …

i had a scene …with mirror reflecting textrue … but it work slow and heavy when i play it … here is the stats with and without the mirror… what is the problem with this script??

and i want to know how much the Unity bears from polygon , texture and lights …to work good and fast ???


Ok, so adding a mirror makes the draw calls increase 5 times (and so 5x more vertices to process etc.).

Usually a mirror would increase draw calls twice or less (you could setup layer masks so that unimportant stuff is not displayed in the mirror).

Are you sure you added only one mirror?

no … i added alot of mirror … :sweat_smile:
if u notice that i added it in all the window on the down on the palace … i added exactly 10 planes with mirror shader :sweat_smile:

is that impossible on Unity??? cause i cant put the mirror shader just on one window and i really need it in my games ???

Well, each mirror needs to render the scene “as it looks like when reflected”. So 10 mirrors = 10 times of rendering the scene.

Are they all coplanar (i.e. on the same plane)? In that case, why not create a single object that is composed of 10 separate quads, and use that whole object as a mirror?

That is possible, but 10 separate mirrors all active at the same time = 10 times more stuff to render. Which can be much slower :slight_smile:

Some ideas:

Do a raycast from the player towards the mirror. If it’s not visible (raycast hits something else), disable that mirror. In other words, do something so that not all mirrors are active at once.

Make the mirrors not update themselves every frame. What if each mirror would only re-render it’s view each 3rd frame?

…or maybe you don’t actually need mirrors at all? Create cubemaps that “approximately reflect” the environment, and use reflective shaders on the mirrors.

Aras said:
" …or maybe you don’t actually need mirrors at all? Create cubemaps that “approximately reflect” the environment, and use reflective shaders on the mirrors."

i can’t put a cubemaps because the character will not be appear when it be closed to the mirror … but i will try the raycast approach but making it from the camera rectangle view not from the player …

thanx for your help …

Are all the reflective windows at ground level? If not, you could do all the ones the player can’t get next to with cubemaps. I know it can be jarring not to see the reflection, but DICE chose to leave that out of Mirror’s Edge. I guess they couldn’t figure out a good solution for that, either.