“You know how long I been waiting for this?”
Looking forward to what I can learn from diving into the place file. Thank you for this!
To clarify something - the line about memory usage should maybe read as:
- Aim for < 1.3GB client memory usage, especially on phones (aim to support phones with 2GB of memory and up - this article isn’t about memory usage, but this is good intel)
I cover this exact topic in my RDC talk in a little more detail.
Why isn’t BulkMoveTo used here as well? Couldn’t the models’ PrimaryParts be passed in?
Probably could have! Try it out.
Would it be best to test on physical low end hardware for this? Since I notice that the more RAM you have on the device the more Roblox allocates/takes up. For a mobile device that has 12GB of RAM total, Roblox often takes up 2-3GB even on an empty baseplate for example, which makes it hard to judge your own place’s memory usage.
Isn’t PivotTo supposed to perform nearly identically to BulkMoveto?
PivotTo
is identical to BulkMoveTo
but only if you’re trying to move arbitrary content, such as in plugin or library code where you don’t know what it will be operating on.
If you know and control the exact structure of the thing being moved you can do much better via BulkMoveTo
and usage of assemblies.
My thinking was that although I could have optimized the pet rendering to use bulkMoveTo, I already show how to do that in the coin section.
For the pets I more wanted to illustrate avoiding doing an expensive operation (pivotTo and raycasts in this case) by checking for value changes.
PivotTo also has the nice effect that you don’t need to build your pets as welded assemblies (even though they are in this case) - they can just be a glob of anchored parts and it’ll work.
would it be faster using BulkMoveTo
on model’s parts or would PivotTo
win in terms of time? Might be asking same question but more specific.
(considering what we move in bulk is known and does not change, just have to take care of CFrame math)
Also to readers: Semi-Transparent parts with decals/textures do not batch. I’ve once spotted this problem and managed to reduce 100+ drawcalls from the entire game map.
This is a very great article! I love it when experienced developers make detailed and understandable articles about complicated topics for developers who are not familiar with those topics yet.
However, I’m also kind of disappointed that this article was aimed at developers who prefer to make much money rather than good games. For example: Your recommended triangle budget of 500k triangles and 500 draw calls is immediately used up just by using Terrain and some fairly detailed meshes (with PBR textures, around 20k tris each).
This just gives me the feeling as if Roblox does not promote innovation at all but rather prefers cashgrab games which are quick and easy to make (which I wouldn’t doubt they would). Now I know that Roblox is working on innovative features right now, such as the new (but iirc not yet available in live servers) aerodynamics feature. This is a very good feature and I love that Roblox is actually working on it, but the issue is that I wont be able to make much use of it due to other bottlenecks such as Renderdistance for flightsimulators. Just making a map that is big enough for a realistic flight simulator is already impossible due to Roblox’s terrain being absolutely HORRIBLE and unoptimized (and also because it takes up an unbelievable amount of RAM which causes your Roblox Studio to crash).
That said, I know this isn’t the right place to complain about things like these, however I’ve been waiting to get accepted into the feature requests Forum group for over a year or two now and I haven’t been accepted yet.
Thank you for taking your time to read this
First, the caveat: Don’t prematurely optimize, just use PivotTo
until you’ve established that you’re moving around enough stuff for that to be a bottleneck.
To absolutely maximize perf moving non-physics-simulated objects:
-
If you have a lot of similar things which you want to move around, where the internal structure of each of those things does not change and is under your control: The fastest by far is to combine all the parts into a single assembly with Welds (root part anchored and others unanchored) and
BulkMoveTo
the RootParts of each of those assemblies. -
If you have a bunch of assorted stuff whose behavior is not uniform, where you calculate the updated positions in different ways / at different times, same as above but set
.CFrame
on the root parts rather than spending extra effort setting up arrays forBulkMoveTo
. -
If you’re writing a tool / library, and have a model with unknown contents to move, use
PivotTo
on the model.
Anything behind the terrain in that screenshot is going to count towards the scene draw call count, as well as any ParticleEffects and Clouds (if you have a Clouds instance inside your terrain). But anything off-screen won’t be rendered.
just thought I’d let you know since the render stats you posted shows there are 26,243 other potential instances that might be rendering in your game
BTW, if you wanna see exactly how much something is impacting render performance, try deleting it and noting the draw call count before and after. Also make sure you don’t have anything selected, since selections in studio impact performance rather heavily.
Regarding using terrain, most of the time a terrain will stay under 250 draws and 250k triangles. It just means if you’re going to use terrain, plan for it to be half your game
Appreciate the in depth detail,
Mostly definitely learned some new techniques.
Useful for beginners. Though ultimately most will come to quickly realize that no, roblox does not exactly help you with those things nor it is exactly such a bangin’ engine. While these methods can help, ultimately they pale in comparison with what you could do to optimize in like every other 3D game engine out there EXCEPT roblox. We can’t even stream textures man! Talk about keeping the memory below 1.3 gigs yet we don’t even have a decent way to yknow, not run max resolution models on 2x2x2 stud models from like 200 studs away.
I’m not sure how you expect roblox to run at max graphics on a 2 gb of ram phone just via optimizing the standard toddler casino. The roblox client alone takes like tons of memory and any optimizations you could do can barely get the memory to budge at runtime. Anything you could do in studio CAN help a bit but ultimately youre still faced with the issue that the entire game world will always be held within memory without any proper way for you to ACTUALLY stream its contents in and out.
Also, streaming enabled is in fact, not good for very large maps (unless your definition for very large maps is like MAX 2048 studs of simple geometry). Streaming enabled in fact, sucks, and it sucks hard. Yet ultimately the roblox provided streaming is our only REAL way of actually making a difference due to the fact that the thing is actually capable of not loading the entire map when the client is loading, saving most users from memory related crashes. Streaming out everything is an entirely different story though (its slow and does nothing to improve memory afterwards).
Oh and im pretty sure meshes and unions are NOT as light as BaseParts as you might have said. From my experience with them they tend to be a double edged sword when it comes to optimization. It’s true that you could replace large part volumes with a singular mesh and save tons of performance however the same cannot be said about everything else. My general idea on how to properly use meshes and actually optimize them is in cases in which you could merge at least over 10 parts while also cutting down their geometry within blender or other 3D modeling software for further performance enhancements. But for short, a block BasePart is way easier to render than a block Mesh/Union. Same goes for all the other shapes. You should be conservative with meshes.
I dont know man, but i dont think youre being honest with yourself when you constantly boast about roblox. I don’t think roblox is trash but its clearly inferior to absolutely everything else out there. I’m just sayin, you could be getting paid more if we all had actually good proper ways of optimizing our games without make-believe optimizations (such as parenting stuff to nil to simulate the streaming in and out of geometry . Trust me, this is the only way i also have of optimizing my maps at runtime and it sure is a piss poor way of really doing things and won’t save systems with low memory).
Oh little nitpick but honestly it would have been nicer if these optimizations were applied to something else and not a super basic toddler casino. Those aren’t exactly hard to not make run like crap by default.
The Iphone 6s came out in 2015.
This is a photo of my iphone 6s running this project at max quality graphics. It runs at a stable 60fps. It does warm up, but it doesn’t thermal out.
Notice you can see to the horizon.
Same phone, memory usage here is about 780MB.
(Sorry had trouble getting the fps counter on exactly 60, my fps counters a little twitchy)
Great guide!
What’s a good way to budget your CPU? The problem is that if you don’t have an older device it is hard to test. Is there any other good practice around CPU usage or benchmarking? Is 16ms on the CPU a lot? What about 5ms? How can I find the optimal?
Useful for beginners
Cut out the downplaying. This is useful for all developers of different skillsets, not just beginners. I’ve been developing on here for 16 years now and there’s stuff I learned.
I’m not sure how you expect roblox to run at max graphics on a 2 gb of ram phone just via optimizing the standard toddler casino
Oh little nitpick but honestly it would have been nicer if these optimizations were applied to something else and not a super basic toddler casino. Those aren’t exactly hard to not make run like crap by default.
If all you got out of this article was how to optimize a “toddler casino”, then you missed the entire point of it and you’re again downplaying/belittling a very well thought out and useful community resource from someone who’s likely been making and optimizing games since before you were in diapers.
The techniques discussed here apply to any game of any style and scope. Every huge AAA open world game uses a lot of the high level stuff discussed here(even though specifics here are of course Roblox related)
If you can’t extract useful information out of it fine, but it’s more of an issue with your ability to comprehend and apply the information - and not an issue with the scope of the article.
Also, streaming enabled is in fact, not good for very large maps (unless your definition for very large maps is like MAX 2048 studs of simple geometry). Streaming enabled in fact, sucks, and it sucks hard. Yet ultimately the roblox provided streaming is our only REAL way of actually making a difference due to the fact that the thing is actually capable of not loading the entire map when the client is loading, saving most users from memory related crashes. Streaming out everything is an entirely different story though (its slow and does nothing to improve memory afterwards).
Streaming enabled isn’t perfect, but it is most certainly helpful for large maps especially with terrain - and saying it does nothing to improve memory is comically wrong, it kinda sounds like you’re just saying stuff without any real data backing it
i dont think youre being honest with yourself when you constantly boast about roblox. I don’t think roblox is trash but its clearly inferior to absolutely everything else out there. I’m just sayin, you could be getting paid more if we all had actually good proper ways of optimizing our games without make-believe optimizations
Where in this article is he just “boasting about roblox”? None of the stuff here are “make believe optimizations”, it’s all very well documented here with data and performance stats to back it up. Something you haven’t done with absolutely anything you’ve said
It’s rough without being able to test on device.
As a general rule, my iphone 6s is about 3x-4x slower than my PC in terms of CPU, meaning if I take 4ms of cpu on my pc, my phone is taking 12ms-16ms. Which may or may not be useful for you.
… and I know it’s no help, but a refurbished old iphone will set you back about $50