3D surface rotation in Mathematica 7 with anti-aliasing turned off is very fast and smooth. However, turning on anti-aliasing, even at a moderate level, drastically reduces the rendered frame rate, making rotation very choppy. This happens to a much greater degree in Mathematica than it does in other 3D applications.
Why is anti-aliasing disproportionately slower in Mathematica?
A way to greatly enhance the feel of 3D graphics would be to turn off AA during rotation, but turn it on as soon as rotation is stopped. Can this be done in Mathematica 7?
An example was requested. I will use a variation of Mike's code. Please try the following with Edit > Preferences > Appearance > Graphics
first set to No antialiasing
and then Highest quality
. Also try the settings in between. For me, any setting besides No antialiasing
is not smooth. I can visually distinguish three different levels of AA, so it is not a matter of my GPU forcing all or none, yet all of them are slow.
Animate[Plot3D[{x^2 + y^2, -x^2 - y^2}, {x, -2, 2}, {y, -2, 2},
ImageSize -> 700,
ViewPoint ->
Dynamic[{Sin[theta] Cos[phi], Sin[theta] Sin[phi], Cos[theta]}]],
{theta, 0, Pi}, {phi, 0, 2 Pi},
RefreshRate -> 120
]
While playing around with Alexey and Mike's code, something strange and good happened. I suddenly have smooth antialiased rotation! I don't know what precipitated the change, and I have not closed Mathematica for fear that it will go away, but this proves what I suspected, that it CAN be fast.
More strange, I have the slow and fast behavior happening in parallel in the same notebook. One graphic is rotating smoothly, and another produced with the same code is choppy. I theorize that some cell option was modified by running Alexey and Mike's code, and it is having a very desirable effect. I am going to do my best to figure out what it is.
The helpful options were RotationAction -> "Clip", SphericalRegion -> True
that appeared in Alexey's code incidentally. These, or their effect (ViewAngle
), "stick" with a graphic in the same way that rotation does, therefore I was able to type new code without these options over the old, and run it, and still get the smooth rotation (which explains what I saw above). See answers below for some elaboration.
While a viable workaround has been discovered, I am still interested in an explanation for the choppy rotation with AA on. I do not believe that the "fitting" of the graphic is an explanation, but merely a correlation, as the fitting still needs to take place with AA off, and yet the rotation is smooth.
I appear to have discovered—for my configuration—a magic option that allows for smooth 3D rotation with full antialiasing on. This works for every 3D plot type I have tried therefore unless this also magically stops working I have my solution. I am very interested to know if this has the same effect on other systems.
The option is ViewAngle
. Any numeric value appears to work; Automatic
does not.
Evaluating the code below the first graphic rotates poorly and the second graphic rotates smoothly.
Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, ImageSize -> 900]
Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, ImageSize -> 900, ViewAngle -> 0.43]
I have a problem with Mike's RotationAction -> "Clip"
method, in that I get unexpected and sometimes extreme cropping when rotate the graphic. However, adding SphericalRegion -> True
restores the behavior that I get with ViewAngle
, and the angle is chosen automatically:
Plot3D[{x^2 + y^2, -(x^2 + y^2)}, {x, -2, +2}, {y, -2, +2},
ImageSize -> 700, SphericalRegion -> True, RotationAction -> "Clip"]