Search Unity

  1. Engage, network and learn at Unite Austin 2017, Oct 3 - 5. Get your ticket today!
    Dismiss Notice
  2. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  3. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  4. Unity 2017.1 is now released.
    Dismiss Notice
  5. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice
  6. Unity 2017.2 beta is now available for download.
    Dismiss Notice

Negative X scaling = nearly half the fps

Discussion in 'Editor & General Support' started by n0mad, Nov 25, 2009.

  1. n0mad

    n0mad

    Joined:
    Jan 27, 2009
    Posts:
    3,732
    Hello,

    I have to make a feature where a full skinned Mesh can be mirrored in X axis.
    But I'm witnessing a severe perf loss when I use this localScale(-1, 1, 1), jumping from 17 ms average frametime to 24 ms ...
    The skinned mesh has 2 box colliders / rigid bodies attached to it.

    I just set that X axis inversion once, do nothing else, and then bam the Fps goes down as long as it is -1. When I switch scale back to 1, everything returns to nice Fps.

    Profiler says that the CPU is the cause of slowing down the overall.

    Is there a way not to have perf loss ?

    Thank you
     
  2. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,325
    Create the mirrorred character in your 3d app and freeze the transformations.
     
  3. n0mad

    n0mad

    Joined:
    Jan 27, 2009
    Posts:
    3,732
    Thanks, so this means that perf loss is how things work, and that there is no way not to avoid them ?

    Jeez ... my FBX size will be huge :(
     
  4. n0mad

    n0mad

    Joined:
    Jan 27, 2009
    Posts:
    3,732
    Hello again, one thing I can't understand : why is this negative scaling much more CPU consuming than other transforms ?
     
  5. Graham-Dunnett

    Graham-Dunnett

    Unity Technologies

    Joined:
    Jun 2, 2009
    Posts:
    4,262
    Guys,

    If you are comparing a negative scale to no scale at all (I guess I mean the identity scale) then it is possible that you are asking the CPU to do some work to perform the scale. If an object is not being scaled I imagine it is sent down some fast path submission.

    Your scale is non-uniform (only affects the x-component of each vertex) and non-uniform scales really mess with matrix operations. Translation and rotation both preserve the shape of an object. Uniform scales do too, but non-uniform scales stretch geometry. Imagine a scale of (2, 1, 1). This ability to mess with the shape of an object is what causes non-uniform scales to require some slower submission path. You might say that a scale of (-1,1,1) is not messing with the shape of your object, but in fact it is turning your object inside out.

    Glad you are finding the profiler helpful!

    Regards,
    Graham