- Home /
What is 'Switches' in the stats tab? (And is it connected to my framerate issue?)
Hi. I'm experiencing some large drops in framerate - and all around choppy gameplay experience, and would like some second opinions on what might be causing it.
Use this picture for reference: http://grab.by/O57
I'm suspecting that the pipes in picture 1 are the culprits. (in game screenshot)
When looking in the direction of the pipe, the stats show 72 "switches" (see pic 2).
However, when looking in any other direction, the switches are maximum 2 (pic 3).
First question: What are these switches exactly? (as that could help me solve the root of the problem)
Second question: Now, the model is just different pieces of the pipe, which was then assembled within Unity. Can that be the cause? Will assembling everything within Maya, and the applying shaders and materials afterwards change anything?
Any and all help appreciated. Thanks.
Answer by Murcho · Nov 26, 2009 at 06:22 AM
Question One : The switches amount refers to the number of times the used RenderTextures had to have their context switched. It looks like the offending pipes are using a refractive type shader, which uses a Shaderlab feature called GrabPass.
GrabPass creates a RenderTexture and stores the current output buffer of that area of the screen in the RenderTexture. The shader is then able to access what is essentially behind the object, and make modifications to it, in this case refracting the background image. Each time an object uses GrabPass it causes a context switch.
Question Two : Having separate sections of pipe will cause each part of the pipe to get rendered separately. This involves sending each mesh to the GPU for rendering (which is a Draw Call), and then each part of the pipe being rendered to call GrabPass which causes your switch to happen. If they are combined into one mesh, it will only generate one draw call, and should only cause the context switch to happen one for that mesh.
Thank you for taking the time to help us out - and for the great answer :)
Your answer
Follow this Question
Related Questions
GUI health status 1 Answer
Problem With GUI Circle Thickness 0 Answers
Problem with GuiFont - Not appearing 0 Answers
Button onClick events will not be triggered 1 Answer
Gui Not showing up in game! 1 Answer