My first plugin, "PolyCounter"

Hey guys :slight_smile:
So, I noticed in feature requests some people were asking for a poly count/triangle count property on meshes or meshparts.

I made a plugin that, using httpservice, allows you to count the polygons in your game or under a specific selected instance(recursive).

This takes into account all roblox native meshes(head,cylinder,torso,etc), any mesh with an ID, union operations, and parts.

It’s rather fast, and it saves a MeshId - > PolyCount key value pair in ServerStorage for caching.


Functions

1. Count

Returns the poly count under a specific instance, or the game if no instance is selected.

2. Heat Map

Colors all objects interpolated from green to red based off their poly count over a max threshold specified in Settings. Clear this map with Clear.

This primarily is useful for meshes and UnionOperations.

If an object has 5k polys and you set the threshold to 5k(default), it’ll appear red. 2.5k will appear orange, and so forth.

This is mainly used to pinpoint meshes or singular objects with high poly count.

https://i.gyazo.com/530e4d6a5c1296b5bc6b6d24dc127c9d.jpg

3. Heat Map 2

This is similar to Heat Map 1 in that it colors objects based off their poly count, but it is used to determine high polygon counts in a specific area or polygon density. This is obviously more intensive.

Essentially, instead of it coloring solely on the poly count of itself, it’ll color it based off the total polycount of itself and all objects within a radius around it.
Setting the threshold of red to 5k and the radius to 10 studs produces this.
My selected instance is “Town”, and as you can see the roof lit up in red due to the high poly pokemon and the stables due to the high poly horses.

https://i.gyazo.com/fd6e8fbbf99df9b625d488a11234f5a6.png

I may have made a mistake here or there, and do let me know with feedback and bug reports :slight_smile:

I made this to hopefully help out some members of the community that wanted to see how their place was doing poly-count wise.

This plugin was mainly a simple way to get the poly count of any instance, but the other functions could be helpful if you can get past the minute or so of lag(I’m working on improving performance).

29 Likes

Awwwesoome

3 Likes

Great idea, I think something like this should be included in studio by default.

Count is quite useful for our current workflow. I’ll actually be using this!

Turned on heatmap in my detailed map and made CPU usage go to 100% (did complete eventually after ~20seconds)

4 Likes

Great plugin! Definitely going to be using this.

Also this x100000:

2 Likes

I’d love an official feature :smiley:

Also, I have a few suggestions that could improve this more.

  • Allow us to set not only a max but also a min poly count so only high poly areas end up getting highlighted
  • Fade from green to yellow to red instead of just green to red
  • Have sliders to easily adjust poly-count settings with a place where we can also input an exact number we want
  • Choose our own colors maybe?
1 Like

Looks like Heatmap 2 is having issues determining poly-heavy parts – it highlighted a normal part without meshes red:

It colors it based on the selected object(s) polys + all the polys of objects around it within a set radius.
Honestly I’m not sure if it works too well, it uses FindPartsInRegion3 to collect the poly count in a radius.

1 Like

Glad you found it useful!

Not quite sure what you mean.
This is how it determines the color, pretty simple but it should go from green to yellowish to red.

return Color3.new(0,1,0):lerp(Color3.new(1,0,0),clamp((count/max),0,1))

Ah, I thought it meant that parts would be colored relative to the highest-poly part in the place – IMO that should be a feature as well.

1 Like

The biggest bottleneck I see, since the performance issues can probably be alleviated, is that meshes are downloaded on some webserver which then shoots back what you need to find out the number of triangles – this can take more than a few minutes. That webserver isn’t even guaranteed to remain up.

It’d be really great if we could get a TriangleCount property for meshes as well to alleviate that and the time it takes to fetch triangle info. Or, better yet, move TriangleCount up to BasePart so we don’t have to deal with manually defining triangle counts per primitive mesh or downloading triangle count from a webserver again whenever a new subclass of BasePart is created. Maybe @TheGamer101 knows who to send this to?

The performance issues are because of the decal instancing for the heat maps. I’m going to switch over to just colouring and de-texturizing and that should fix that problem. There is no web server really to get the triangle count. It simply does an HTTP GET on the asset ID from a roblox proxy and parses the mesh format

The proxy is hosted on a websever.

I’ll look into how feasible doing this is, it seems like adding a TriangleCount property for meshes would be relatively quick (I haven’t looked at this at all though so maybe not). The use case is kind of niche so it might not be super high priority but I definitely think we should add this.

I think either @spotco or @twberg would possibly be good people to look into this.

2 Likes

I know, but I thought you meant I was using my own.
As for it taking a few minutes, perhaps if you have slow connection?
I have a decent connection and it took me about 5 seconds to fetch about 100 different assets.

Regardless, it would be a neat feature to have natively and that’s part of the reason I made this