Suggested Improvements: 1) You can make rotation with Tick frame-independent by multiplying the Rotator by the Tick event's DeltaSeconds. We've implemented this in the Github source code.
When you want to draw the same mesh many times, I recommend using Instanced Static Mesh Component instead of having an actor for each. It renders a single mesh on multiple positions
First and foremost an excellent video! Very thorough! It's not entirely true that you can't do anything about the shadow. You can give the shadow a custom shadow stencil and conceivably you could rotate that stencil. It'll never be as precise as actually casting the shadow, but for simple shapes (like a coin) you can probably cheaply model the appearance from some uv coords.
I wonder how this test would differ if you used an instanced static mesh over regular static meshes. My guess is performance would probably increase dramatically for all of your tests
Have you done any testing in UE5.3? I've been dwelling in material to create some animation, to save on performance. Would be nice to know if there is a point to it still or if it's outdated nowadays. Like how would this compare to vertex animation?
how do you get his to rotate around the local axis? I have a propeller I want to spin, but it is not perfectly aligned in X,Y, or Z. It's tilted at 45 degrees. I can easily make it a child of a Scene Component, so it only rotates in Y, but the Material method does not see it this way. It still rotates it in World Y. I tried ObjectPiviotPoint, ComponentPivotLocal, Local, and I'm running out of choices.
On the NormalizedRotationAxis of the RotateAboutAxis material node, you'll want to specify a normalized (i.e. magnitude of 1) vector representing the axis you want the propeller to spin around. In the video, we're using a vector that represents a line pointing straight up in the Z axis (0,0,1). For your example of a 45 degree angle, you can try (0,0.707,0.707) or different combinations, as 0.707 is sin(45 degrees) and cos(45 degrees).
@@PendingKill yea... this still only gets me a fixed rotation. Meaning, I would have to know the object's angle in the game. I am randomly spawning fans, in a room. so... 1) trying to get the fan blade to face the correct direction. 2) (advanced) trying to get the fan blade to face the correct direction, if I have a ossolating fan. currently, If I look at the fan in the blueprint, it looks fine, but once I place it in the scene, it is locked aligned to XYZ that was set in the blue print, and it ignores the rotation of the actor in the scene.
@@PendingKill Got it to work. I had some help on a discord forum. Adding 2 nodes in the material that enter the RotateAboutAxis/NormalizedRotationAxis (input). Take the colored XYZ(RGB) node, plug it into a Normalize node. Add a ObjectOrientation Node. Add RotateVector node.
@@ZimCrusher Glad you figured it out! The ObjectOrientation node seems like the key to get it to rotate around arbitrarily placed objects in the scene. Thanks for writing this up, hopefully others will find it useful.
i wanna add if u use the material static mesh on BP - but set it as static not movable - the engine should realise it as instance (no more draw call for eatch)- and should get better performance ---- i test with another thing not ur test
I was under the assumption that static mesh components in actors were auto instanced. Other than that, it would be interesting to see how instanced static meshes would work with.
Typically they are auto-instanced as long as they're not moving. But once we add the Rotating Movement component or rotate the actor manually on tick, the auto-instancing no longer occurs.
Seriously. I have an actor that is my base pick up actor, and I turned tick off. My FPS stayed 120 FPS with over 300 actors on screen. Turned tick back on and it halved my FPS. So the material is really the best option.
It is kinda weird that less FPS = slower rotation when using Tick... If you multiplied your RotationRate by DeltaTime, this shouldn't have been a problem.
Thanks! I believe that a C++ implementation would follow a very similar structure, especially for the Rotating Movement component. Of course, you wouldn't need C++ for the Material method.
Well, seems like once you put it into a blueprint, UE will treat it as separate objects and won't do auto-instancing with the static meshes. However, you're still avoiding having to rotate an object every frame, so it's substantially cheaper compared to using the RotatingMovement component (or any of the other non-shader rotation methods we discussed)
Wow, very great optimization tutorial! It's very interesting to optimize games, thanks! Hope you will do more tutorials for optimization and possible issues like shadows but in very optimized material
This obviously doesnt matter, but for reference what are the specs of the pc used for these tests? Particularly cpu/gpu setup Great info though, and excellently presented!
@@PendingKill Oh my the nostalgia, the FX-8350! how come you still run that bad boy in the year 2020? haha, with the more recent ryzen cpu's being relatively cheap that is. (unless you actually own two rigs.) I used to have one aswell. It was a beast back when it was released!
@@Skyflairl2p Haha it's served us well, though we're planning to upgrade that one soon :) the other machine we have is a Ryzen 3600 + RTX 2080. And yeah 8 cores was a flex back in the day.