- Home /
Does transform.LocalScale now use the GPU? Is it still slow on phones?
The manual still warns against scaling objects and suggests they be scaled in the external modeler, imported at 1.0 and left there or performance will suffer. Ok, what about things that need to get bigger and smaller to varying degrees in the game? I read a post from last year from a Unity person that they were 'working on it'. I see Aras said that in Version 3.0, it will use the GPU, but that was from before it came out. So... does it? I've just got to the point in my game where I need to make things scale, and it already chugs in the webplayer at 1024x768 resolution, and I can't afford the profiler, so freaking out a bit over this.
I was actually thinking of making a vertex shader to do my in-game scaling, but if that's essentially what the engine is doing now, I won't waste the time on it. (My first thought was that I could make a hundred or so versions of the mesh at different sizes and switch them on and off every few frames like a flip book; and could that really be faster than just setting the scale, and if so; wtf. )
So, is just setting transform.localscale good & kosher now in 3.0 or is some workaround still needed?
How is using a vertex shader at all the same thing as scaling the Transform? Scale is used for a lot more than rendering.
Answer by Paulius-Liekis · Jun 07, 2011 at 09:09 AM
Scaling object is not a problem in my experience. The only case that I'm concerned about is having a Collider on scaled object, because in that case it has to rebuild collider everytime you change your scale.
Otherwise just try it and see if it works.
Answer by spovf · Sep 21, 2011 at 10:39 AM
I ran into a similar problem. The slowdown issue is not the GameObject itself which you want to rescale, but its collider. Even if never using the collider, it is actually there and will be updated with a call to transform.localScale resulting in a more complex scaling.
The collider is used for physics and collision detection, if you do not need this, the solution is quite simple - just destroy the collider of your GameObject.
GameObject.Destroy ( myGameObjectrenderer.collider );
Happy Scaling!
Or, alternatively, don't put one on in the first place! If you're changing things as fundamental as that at runtime, you might run into problems.
Well, that is the strange thing. I didn't add it. I call myGameObject = GameObject.CreatePrimitive ( PrimitiveType.Plane ); Shouldn't be a problem if destroyed right after creating it.
Answer by jonas-echterhoff · Sep 21, 2011 at 12:32 PM
Unity 3.0 does have GPU support for uniform scaling for mesh renderers. However, non-uniform scaling (different values for x/y/z), and colliders with scaling will still cause performance hits.
Your answer
Follow this Question
Related Questions
Build GPU Performance 0 Answers
GPU (render time) increase if screen size increase 1 Answer
GPU spikes from SubmitVBO 0 Answers
Compute shader dispatch large spike in CPU and GPU profiler 0 Answers
Why CPU waits for GPU when there is not much work on GPU? 0 Answers