CullingService V2 - Custom Client Sided Culling/Streaming Module

Its very boring to go through a lot of steps to apply this service in games with alot of assets and if you ever think to update it then hopefully use the new parallel feature since it may give another advantage to this module but more importantly hope you can make it more clear and easier to setup your module more quickly As I see more ways to improve this module’s setup procedure.

(TL;DR, becasue the response got long: configurable code unavoidably requires configuration, if this is a serious barrier to you + this is relevant to your experience - I’ve added some console code to help you out)

I think there’s some kind of miscommunication. CullingService is not designed or intended to be some kind of automatically initialized/self-determining system. That’s very much in the vein of StreamingEnabled, which indiscriminately streams everything in and out (more or less).

CullingService is designed to be configurable. This lets you reap the benefits of streaming objects in and out while still maintaining very precise (at least relative to the default engine options) control over your experience.

However, the clear downside of a configurable system is that it requires configuration! Like most things (ex: redoing a UI framework, shifting data/replication handling, etc.), converting an existing experience over is going to be more time-consuming than starting at the onset. It can be necessary, but it’s definitely not flashy development - we can agree on this, I’m sure.

With that said (and assuming you have good naming conventions in your experience, i.e., not “Model” everywhere). You can expedite the process with some simple console work.

Run this in your console
for _, Model in ipairs (workspace:GetChildren()) do
	if not Model:IsA("Model") then
		continue
	end
	
	local MediumFolder = Instance.new("Folder")
	MediumFolder.Name = "Medium"
	
	for _, Child in pairs (Model:GetChildren()) do
		Child.Parent = MediumFolder
	end
	
	MediumFolder.Parent = Model
end

Wrote without testing - should work, but it’s possible there is a typo

Add the 5-6 necessary folders (per instructions)
Open the plugin, initialize it, click the auto button.

And, your place should be set up.


With that said still, if you’re averse to steps, then it’s very possible this is simply not necessary for your experience. If your experience from a programming perspective isn’t detrimentally affected by StreamingEnabled, that might be better for you - it’s definitely easier (because it’s a toggle setting). If you’re not overly concerned about performance controls, then this simply might not be relevant to you.

I was just saying, good luck tho.

Hey! This is a awesome module so far, it is really something I wish Roblox could support natively already for larger more open and detailed worlds.

I was just curious if this supports models with varied rotation, scaling, and colors?

For example, can I use this module to cull in and out a field of flowers that are randomly larger or smaller than one another, or rotated to grow with the direction of a hill?

I’m not sure, but I have tested around a bit, and found that it doesn’t seem to work, unless I have done something wrong.

Anyways, thank you for the amazing free module so far!

1 Like

Heyo!

Right now CS doesn’t support that, but that’s a really interesting suggestion. This is definitely something that’s possible to implement, the only drawback(?) would be that each time you would generate an experience it would be somewhat different. Maybe that’s a positive in some ways, though. Definitely possible to add, and I’m looking into it.

Could you explain a little more what you mean by this? Is it that the model isn’t properly rotating when you rotate the anchor point, that generating the anchor point doesn’t respect rotated models, or is this in the line of randomization?

Update

  • Fixed a bug that prevented large regions from being effectively created
  • Added GoodSignal compatibility and API calls (this should now make it easier to easily create client-sided events utilizing motion)

New API Functions

module:CreateSignalForModelCullIn(ModelName: string)
Returns a Signal which is fired every time a model with the name provided is culled in. Signal provides the model as a first argument

module:CreateSignalForModelCullOut(ModelName: string)
Returns a Signal which is fired every time a model with the name provided is culled out. Signal provides the model (in this case, nil) as a first argument

module:CreateSignalForModelCullInAtRange(ModelName: string, RangeName: string)
Returns a Signal which is fired every time a model with the name provided is culled in. When the Signal is fired, it provides the model (in this case nil) as the first parameter

module:CreateSignalForModelCullOutAtRange(ModelName: string, RangeName: string)
Returns a Signal which is fired every time a model with the name provided is culled out. When the Signal is fired, it provides the model as the first parameter

Example API usage (direct from my project, which makes a boat sway with the waves when culled in)

local function ListenForShips()
    for _, ShipName in pairs (AllShipNames) do
        local ShipAdded = CullingService:CreateSignalForModelCullIn(ShipName)

        ShipAdded:Connect(function(Ship: Model)
            HandleShip(Ship)
        end)
    end
end
2 Likes

Two things,

One I think you should add a setting to use an objects Pivot Points keeps it up to date with modern day roblox technology plus I’m pretty sure the current positioning function your using is deprecated.

Two, It seems like not all the objects in a region load and its random at that. I’d suggest looking into it as it doesn’t seem like its a guaranteed your objects will get loaded

CullingService Testing.rbxl (224.6 KB)

1 Like

Thanks for the bug report! I found the issue - it was an attempted optimization that affected that way that anchor points were initially sorted. The issue should be fixed now (fixes applied to your repro file attached). Fixes are also live on GitHub, test place, and Roblox Library.

Thanks for the suggestion about pivot points, it’s not something I was familiar with before, but it looks to be a handy feature. I’ll look towards migrating to that soon, appreciate the heads up!

CullingService Testing Fixed.rbxl (224.2 KB)

I swear this doesnt work for me. It just doesn’t seem to spawn in when I test the game

Hi, if you send me a repro file, DM, or add me on Discord, I’d be happy to check it out and see if there’s an issue with set-up or a bug.

I got it to work on a new baseplate; I’m guessing something in the old Roblox place is bugging it out. Thank you for replying tho

CullingService V2

Download

GitHub Repository
Roblox Library Model
Roblox Library Plugin
Example Place

Key New Features

  • Added animation framework for developers to control streaming aesthetics
  • Added five animation presets: Rise, CartoonRise, SpaceShuttle, Transparency, and Blink
  • Fully modular (previously involved some hard coding related to the default ‘Short,’ ‘Medium,’ and ‘Long’ distance folders)
  • Significantly more reliable (now employs back-up checking)

Animations?!?!?

Yup, developers can now add animations to CullingService as a way of controlling the aesthetics within their project. Perhaps you want to make culled objects subtly load into the background by fading their transparency in? Maybe, you want a very obvious cartoony load-in: rather than hiding the streaming process you’d like to embrace it! Who knows! CullingService includes a very easy to use animation system that essentially lets you freely tailor the callback animation directly. This handler contains a Template module and 5 presets to serve as examples.

Previews of 3 Presets
Transparency

Rise (for that subtle feel)

CartoonRise (for that cartoony simulator-y feel)

To activate an animation package (or your own), go to Settings → Animation Package and change that value to the package name. If it is nil, no animation package will be provided.

Ex:

local module = {
    ["Animation Package"] = "CartoonRise", --// Defaults to nil for backwards compatability

    --// The rest of the settings....

Create your own animation package, just modify the clone the Template in CullingService → AnimationPackages and modify from there. It should be pretty self-explanatory and the 5 presets are intended to be used as references.

Note: these have not been benchmarked, but all presets ran in Studio at a comfortable 240-270 FPS (which is my average FPS anyways). FPS may be affected based on the complexity of your animations and the numbers of instances being animated at any one moment

Full Modularization

CullingService previously had a few points in the code that were hard-coded to the module’s base (range folders of ‘Short’, ‘Medium’, and ‘Long’). This has been removed, so that developers can add as many range folders as they want. This allows developers to better specify the ranges for certain instances (ex: giving terrain elements, landmarks, or particular instance types their own ranges). Hopefully, this lets developers take even more control of their experience.

Bug Fixes and Other Random Stuff

Check the GitHub commit if you’d like more details (as well as the side-by-side comparison of code changes)

How to Upgrade to V2

Just replace the old CullingService modules with the new one. There are a few small changes to the Settings, so I would recommend loading in the new Settings module and then just manually setting them again (if you aren’t using the out-of-the-box configuration). Because there are a couple new settings, CullingService V2 is not completely backwards compatible with V1.

Don’t fret though, the conversion is minimal. Your models are also fine. The plugin was not updated and does not need a redownload or update.

Legacy Downloads

CullingService V1 Legacy Model.rbxm (25.2 KB)
CullingService V1 Legacy Testing Place.rbxl (113.3 KB)

Because CullingService V2 is not backwards compatible, the latest V1 variant has been included for your convenience. This should function perfectly fine, however, I highly recommend using CullingService V2 for more control.

Enjoy!

7 Likes

Small V2.1 update

  • Added ‘Reset Anchor Points’ to the plugin, which allows you to select anchor points, cull them back in, and then delete the anchor points in one fell swoop. Perfect for that “whoops, didn’t want that to be culled out… crap how do I reset this??” moment. Realistically, this new button + auto add selection are probably the only two buttons that you need.
  • String formatting fixes to the plugin
1 Like

V2.2 update

  • Added Setting ‘Ignore Y Dimension’. This performs magnitude calculations ignoring the Y dimension (because anchor points tend to be higher than the actual player position when applied to large models). For any experience utilizing large structures (ex: buildings, tall trees, etc.) this will make things calculate more logically.

This change is backwards compatible, you only need to update the CullingService script. You can update your settings module by manually adding the entry [“Ignore Y Dimension”] = true (or false) to your module.

V2.3 update

  • Added ManualCulling with CullingSerivce:ManualCull(Position: Vector3). This allows you to manually cull around a specific point on the map and will halt culling around the player. This will be ended when calling CullingService:Resume(). Useful if you want to manipulate the camera in a custom manner and then cull around the camera vice the player (ex: intro screens)
  • Added manual refreshing, essentially calling the functions that cull around the player with CullingService:Refresh()
  • Added AutoStart Setting (backwards compatible with previous Settings). Setting this to ‘false’ will mean that CullingService does not start once initialized. You will have to then call CullingService:Resume() for CullingService to begin cull objects in/out. For backwards compatibility, if the setting does not exist, it will default to enabling AutoStart (previously normal behavior)
  • Removed Settings[“Paused”] (for consistency - use the methods CullingService:Pause() and CullingService:Resume() for future work)
  • Bug fixes and improvements
4 Likes

Hi, I can’t seem to be able to set up this, I made a model with the 3 folders in it, and i placed a part in the easy one. However, On step 9, i select the model and then click generate anchor points and the primary part is created, but there are no anchor points on the workspace AnchorPoints folder. I think this is the main problem, but then when i click the Add Selection to Model Storage button, it gives an error on the output:

cloud_7064741679.PluginCode.CullingPlugin.Culling:136: attempt to index nil with ‘FindFirstChild’

Can anyone help me please?

The issue with custom culling systems is that they use replicated storage which still costs memory, this issue is not present with Streaming Enabled. Correct me if I’m wrong.

I know this is kinda late but uh do you still recommend using this service? Or is this outdated

It depends on your use case.

If you want precise control over which assets are streamed/culled, at what ranges, how that looks, etc. then yes, I would recommend this. To further expand, the biggest overall advantage of CullingService is complete control while still getting performance benefits from streaming/culling. This can be essential for very ambitious projects where StreamingEnabled’s more-or-less one size all implementation either blocks you from being able to fully realize what you are trying to create or may possibly cause an impediment with future updates that are rolled out indiscriminately. With CullingService, you control everything.

If that does not apply to you and you want a fire and forget method, then I’d recommend utilizing StreamingEnabled. Roblox is investing lots of time into this and its default engine behavior which allows for better under the hood optimizations and performance (at the expense of less control by the creator).

Hello it doesnt seem to be working for me I tried to compare my file to the demo file and im not sure what I did wrong

My discord is zirdic if you want to communicate there

test.rbxl (144.2 KB)