samp-streamer-plugin
samp-streamer-plugin copied to clipboard
LoD-based streaming for custom assets
Chatting with a friend today about polycounts and player constraints in SA:MP and he said why don't I just use LoD models and allow players to adjust their own detail level.
Since 0.3.8 is coming soon and servers will be adopting new objects, it would only make sense to give the streamer plugin LoD model pool functionality.
The idea is, you'd create a dynamic object with a pool of model IDs it could choose from based on player distance. A per-player multiplier would also be useful so players can specify their detail level.
I'm still thinking about the API for this, will update this issue when I've got a concrete idea of a good way to express multiple models for an object without being too verbose.
I'm assuming you mean something like native SetDynamicObjectLODModel(modelid, lodmodelid, float:loddistance); & native SetDynamicObjectLODMultipier(playerid, float:multiplier); // 1 by default ?
Interesting idea!
Yeah something like that, though I was thinking of a way to do it in a one-liner to ease readability and consolidate everything that's required for an object creation into a single function.
Or, alternatively, it could be done completely separately on a per model basis instead of a per object basis. Something like:
SetDynamicModelLOD(modelid, lowdetailid, Float:lowdetaildistance)
For example:
SetDynamicModelLOD(2000, 48275, 50.0);
This would make objects that use model 2000 display as 48275 when the player is over 50m away.
And SetDynamicObjectLODMultipier would be pretty much be perfect.
Or, alternatively, it could be done completely separately on a per model basis
Yea that’s what I meant as well :) that’s why I used modelid as param name ^^
Ah didn't notice that, yeah I think that would be the best solution.
I might take a whack at implementing this but I'd like to hear some user feedback and some input from Incognito on possible ways to optimise it.
It could be done pretty easily by maintaining an unordered map with the model ID as the key and the low detail model ID and draw distance as the value. Example: boost::unordered_map<int, std::pair<int, float> >. You would just do a lookup on the object's model ID before the object is created and replace the object's stored values with the new values. The multiplier would simply be stored per player.
Adding LODs on a per-model basis is not sufficient. There would be no way to modify the LOD object, if you wanted to set the material for example. There are two approaches to this I can think of, either add minimum streaming distance to parameters of dynamic objects, so that you can specify how close must the LOD objects be to disappear, or add something like SetDynamicObjectLod(objectid, lodobjectid) that would hide the LOD object if the base object is visible. This is the way the game does it for IPL objects.
The first method seems easy to implement and extend, but it must be ensured that between transitioning from the LOD object and base object, it wouldn't disappear.
This would be advantageous not only for custom assets. I already have a use case for this on 0.3.7.
In that case, would Streamer_ToggleItemInvAreas suffice?
Basically, yes, but it would mean creating an area for every LOD-building.
Yea, true :/
If you would be setting the object material then why even bother with custom objects? It would be nice to have a concept build and see how it goes for the people testing it. Only if people would really request X feature for LODs then it should be considered. Should take advantage while 0.3.8 is still on RC