Jump to content

ForEachEntityInAABBDo with hidden entities


Rick
 Share

Recommended Posts

What kind of options do I have with a 128x128 terrain with a bunch of trees, grass, and bushes on it and get reasonable speeds because right now it's pretty slow? I had a program generate the placement for the trees, grass, and bushes and it doesn't seem like it would be to overwhelming population wise. I don't know anything about poly count and what's to high but you can see below the kind of speeds I'm getting.

 

Slow.png

Link to comment
Share on other sites

Something is wrong if 4000 entities are being drawn. The Zone only had about 1000 at any given time. Perhaps you have large numbers of models that have complex hierarchies. I can't diagnose this further without seeing the scene files.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

There are the 3 models only (minus the character since when I just have the character it runs fine). Nothing out of the ordinary besides the bush having a bone (forgot to take that out), but I rendered without bushes and got the same result so that can't be it. They seem pretty normal to me. These are from Dexsoft.

 

I move the camera to that character models position, then offset it back and up and point at that character. Not sure if that would have anything to do with it.

 

I assume the model viewer would show the hierarchy you are talking about.

 

Grass.png

 

Bush.png

 

Tree.png

Link to comment
Share on other sites

So where does a person begin trying to figure out why frustum culling isn't filtering out the non visible models? Clackdor suggested trying the tree models that come with LE and I"ll do that tonight, but would seem odd if it was the models themselves.

Link to comment
Share on other sites

Check their AABB box extents, see that you don't have anything silly which is really extending them. Are you really creating 3800+ entities Rick, have you done a count in your code? That does seem like a hell of a lot given your veg density looks to be small and its only a 128x128 terrain!

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Link to comment
Share on other sites

128x128 with a grid size of 1x1 gives 16,384 tiles that could potentially have a tree, grass, or bush on it. All that information is stored in a sqlite table. I'll get the count in that table when I get home. I guess I didn't think 3800 was to high given how many tiles there are and the probability I gave for each tree, grass, bush to occupy a tile when generating the map. I'll double check the table count though when I get home just to make sure that matches. Some areas are heavier than others. I just moved my starting point to an open area and that's where I took the picture.

 

I'll check the AABB of the models in the model viewer. Forgot to turn that on when I made those screenshots. The trees were larger and I did scale them down in UU3D so I would imagine the AABB gets scaled when I do that, but will double check that also when I get home.

 

Thanks for the ideas guys.

Link to comment
Share on other sites

If all your entities are parented to one pivot, as they are when you load a scene, they will all be iterated through, at least. After loading a scene, the first thing to do is unparent everything from the scene root, which provides an easy way to keep track of what just got loaded.

 

However, you should use the vegetation system for stuff like this, as it is specially designed to be very efficient for static objects.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

So the vegetation system is more than just a tool to quickly place a large number of models?

Much more.

 

I think I have the ForEach... command working now with Lua, will upload tonight...

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

If all your entities are parented to one pivot, as they are when you load a scene, they will all be iterated through, at least. After loading a scene, the first thing to do is unparent everything from the scene root, which provides an easy way to keep track of what just got loaded.

 

However, you should use the vegetation system for stuff like this, as it is specially designed to be very efficient for static objects.

 

These aren't static objects. You can cut trees down, pick grass, and pick bushes for food. They will go away when harvested. Players can plant trees, bushes, and grass on any tile they want. With the top down view only a certain amount of models will be visible at any one time.

 

These also are not loaded with the scene. My scene is an empty terrain. The terrain is logically split into 1x1 tiles and I made a small program that randomly picked tiles for trees, grass, and bushes to be placed and stores that in a database table. I then load the scene, then loop through this database table to get the tile positions (which I then calculate their actual 3D position) and model name to load. I load them, then place them. This also won't just be for trees, grass, and bushes. You'll be able to build walls, floor tiles, chairs, beds, and other things that snap to this grid.

 

You do give me something else to look at though. At one point I did parent them all to a pivot because I was thinking I could hide the pivot then override the hidden child entities to show them (which of course didn't work). I'll double check that I don't still have that pivot in there.

Link to comment
Share on other sites

So my table that stores tile location and what model is on that tile there are 4182 records which means that's how many models there will be total on this 128x128, but as I said only 30-50 in camera view at any given time because of the top down view.

 

I am not parenting anything. I simply loop through each record in this table, load the model, calculate the location based on center point of tile location and position the model there at load time.

 

Here is a picture of one of the trees when I do show AABB in the model editor. Not sure how to read this as it has the outer orange line and outer blue line. I'm guessing the inner orange line is the actual AABB of the model and not sure what the other lines are.

 

So did some tests but the issue still remains why does it say it's drawing so many entities if so few are actually visible. I did notice if I would move to one edge of the map the entities drawn number would go down.

 

I have 746 trees and when they are just drawn I get 100 fps but it still says it's drawing all of them (15 were visible to camera)

I have 240 bushes and when they are just drawn I get 140 fps but again it says drawing all of them (5 were visible to camera)

I have 3196 grass and when they are just drawn I get about 30 fps and again it says it's drawing all of them (maybe 50 or so visible to camera)

 

I tried switching the tree model to the LE tree model but it errors out on me. Guessing it's because I'm running it outside the editor and doesn't some of those have password stuff on them because they are from like Dexsoft or something?

 

AABB.png

 

 

So I don't know how lights play into this all but if I remove all light sources in my scene it's much more reasonable and more accurate as to the number of entities the camera can see. So is this a bug of lights or just the reality of how LE works? I notice this in the editor also. This is exactly what I want, but with lights :P

 

no_lights.png

Link to comment
Share on other sites

You should also consider grouping models into 'cells' of say 16x16 tiles. I notice your cull time is the same as it takes to render. It will probably increase the number of things its rendering but reduce the time it takes to iterate and cull entities. As your map scales or you include more models this might be a good options.

Its a test and see what happens sort of thing.

Programmer, Modeller

Intel Core i7 930 @ 3.5GHz | GeForce 480 GTX | 6GB DDR3 RAM | Windows 7 Premium x64

Visual Studio 2008 | Photoshop CS3 | Maya 2009

Website: http://srichnet.info

Link to comment
Share on other sites

Occlusion Culling: http://www.leadwerks.com/wiki/index.php?title=OcclusionCulling

 

Its a pity the forum wiped because I sorted all this out in a thread once. Pretty sure the idea was that you group models together (model.group(parentmodel)? ) and then turn on OC for the group itself. What this would do its cut down on the number of objects OC had to iterate over massively.

Programmer, Modeller

Intel Core i7 930 @ 3.5GHz | GeForce 480 GTX | 6GB DDR3 RAM | Windows 7 Premium x64

Visual Studio 2008 | Photoshop CS3 | Maya 2009

Website: http://srichnet.info

Link to comment
Share on other sites

@Josh, if you look very closely you can see there are grass models like in the others scenes. Grass is making up most of the models so the count of 300 is accurate. Also, I'm using C++ now (got your msg just this morning). Was using Lua but switched the program to C++ because I was attempting the ForEachEntity function to see if I could work around this issue. I can create a zip file with this scene but remember that the actual LE scene from the Editor is just the terrain and the 1 character model. Everything else is loaded at run-time so not sure if you'll get the same debugging ability you are looking for with the scene. I'll package this up in a zip tonight.

 

Any chance that there are multiple entities loaded right on top of each other?

 

Not that I can see.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...