Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Ways to lower the polys in view?

Author
Message
CocaCola
16
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 1st Sep 2010 03:08 Edited at: 1st Sep 2010 03:08
OK how would I go about doing this? I have an idea but I wouldn't know how to start coding it, like how would I make it so objects x, y, or z spaces away don't get rendered (Like so when your really far away from a object it pretty much disappears then when you get closer it comes back, so you don't have to use so many polys in big levels)? So it could be a HUGE map, but your only loading so many polys at a time?

I want coke, not Pepsi!
Visigoth
21
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 1st Sep 2010 04:44
you have to keep doing distance checks to the objects. Then, use hide/show object.
Or, you can use LOD.
See the ADD LOD TO OBJECT command.
CocaCola
16
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 1st Sep 2010 04:52
how do I do distance checks? And if you just hide the object won't it still render the polys?

I want coke, not Pepsi!
Omen
19
Years of Service
User Offline
Joined: 7th Nov 2006
Location: Maple Grove, MN US
Posted: 1st Sep 2010 05:13 Edited at: 1st Sep 2010 05:20
Hiding an object doesn't cause the mesh to render, but it _does_ keep the object in the engine's multi-object loops. Here's one way you could do it...



but if you REALLY wan to make your life easy, you'd use 2 cameras: a NEAR camera and a FAR camera. The near camera is used for "details" like grass or building architectural details -- this camera has a very short range, like 60 meters. The far camera has a range that is (for all intents and purposes) infinite (say 20000 meters for example) but the far camera excludes the objects being shown in the near camera. This instantly gives you the same effect of high LOD for items near the camera and low LOD for objects further away with no distance checks required.

CocaCola
16
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 1st Sep 2010 07:03 Edited at: 1st Sep 2010 07:04
why wouldn't something like this work? (object 1 player, object 2 object you wanna hide)

in the main loop?
So if object 2 is 1000 places away it doesn't show.

I want coke, not Pepsi!
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 1st Sep 2010 07:33 Edited at: 1st Sep 2010 07:33
Doing a distance check on every object in the scene is going to kill your frame rate. If you split the scene into a grid then make an array that stores the grid section each object is located in...

Then you can check which section the object is in and if it's close enough to the camera, draw it. This eliminates the maths used in calculating distances, but there is a quicker way I can think of but wastes a bit of memory: If we make the array based on the sections instead of the objects we can simply check the sections closest to the camera for objects to draw, the memory wastage is because arrays are not dynamic in DB, so we'd have to make each section capable of storing all objects at once. If n is the number of objects and m is the number of sections we'd need n*m array entities, and out of that (n-1)*m would be unused!

CocaCola
16
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 1st Sep 2010 07:39
Quote: "Doing a distance check on every object in the scene is going to kill your frame rate"


even with

????

I want coke, not Pepsi!
Omen
19
Years of Service
User Offline
Joined: 7th Nov 2006
Location: Maple Grove, MN US
Posted: 1st Sep 2010 08:44 Edited at: 1st Sep 2010 08:45
@CocaCola

You really don't want to be doing distance checks against every object every frame. You could use a counter so that you are only doing 1 distance check against 1 object per frame (or more likely totalObjectCount / targetFPS) to go through all objects each second... but eventually it will become a significant hit on framerate as you start adding in more and more objects into the scene (how many clumps of grass will you need for example to have a realistic looking field?).

IMHO, you have to use a combination of tactics... multiple cameras, LOD meshes, splitting up your scene into sections, fog, careful use of the camera distance, even using potential visibility sets to cull entire group of objects (or sections of your map) when they are not visible (for example when behind s-curves) will all help.

Scraggle
Moderator
23
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 1st Sep 2010 11:49
You might also want to look at EXCLUDE OBJECT ON, it is more efficient than HIDE OBJECT ... assuming you don't need to perform multi-object checks.



Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 1st Sep 2010 13:00
To be really honest, as far as my experience goes with this distance view topic, the only thing that REALLY does anything to the frame-rate, at least in DBPro, is the stuff VERY close to the camera. (it is very annoying sometimes because ONE single polygon with alpha brings the fps in my case under 10...)

For example i have a complex test scene i've made for developing purposes for my RTS, and once first there was no limit on the 4 corners of it the camera couldn't pass, I went out from the scene, and not so far it was already 60 fps instead of the average 30 (i have a crappy machine...)

I also checked it now, and it was an additional 1 or two frames plus per second when hiding the scene lying in the distance... So why bother at all with this distance thingy, it all just uses more processing power than would be there without it. Of course with VERY big terrains it may not be this simple, but there i guess a simple way of making the level into sections with checking the distances at the array level, and hide or show those is plenty enough.

...or exclude... what it actually does 'Scraggle', i've never heard of that command?
Scraggle
Moderator
23
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 1st Sep 2010 13:49
Try this small example:



When you have tried it, make a note of the fps then comment the hide object line and uncomment the exclude object line, then try it again.

On my laptop I get 500 fps with hide object and 1250 fps with exclude object on.

As I understand it, hide object still sends the polygons to the render engine but they don't get rendered. Exclude object on doesn't send the polys anywhere.



Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 2nd Sep 2010 00:39
Quote: "See the ADD LOD TO OBJECT command."


Thanks Visigoth. I'd missed that one. I wonder if it works on limbed terrains such as Advanced Terrain?

Quote: "Of course with VERY big terrains it may not be this simple, but there i guess a simple way of making the level into sections with checking the distances at the array level, and hide or show those is plenty enough."


That's done automatically for you in the update terrain command for Advanced Terrain.
CocaCola
16
Years of Service
User Offline
Joined: 23rd Mar 2010
Location: CocaCola.x CocaCola.y CocaCola.z
Posted: 2nd Sep 2010 02:09 Edited at: 2nd Sep 2010 02:16
@scraggle I got better FPS with hide object (200-350 with exculde, 300-450 with hide), and I would something like this be better?



I know that you would have to make a function or something for i but wouldnt that be better?

I want coke, not Pepsi!
Jeff032
18
Years of Service
User Offline
Joined: 13th Aug 2007
Location:
Posted: 2nd Sep 2010 05:43
Quote: "As I understand it, hide object still sends the polygons to the render engine but they don't get rendered. Exclude object on doesn't send the polys anywhere."


It doesn't seem like the polygons are sent when using hide object. Excluding appears to skip some other calculations.

Kevin Picone
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 2nd Sep 2010 05:48
If you want to reduce the poly's in scene then you need to look into occlusion as per old school tools like Visible Worlds

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 2nd Sep 2010 14:05
Quote: "@scraggle I got better FPS with hide object (200-350 with exculde, 300-450 with hide), and I would something like this be better?"


Weird. I get the same results as Scraggle:

hide object - 1042
exclude object - 2440.
James H
19
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 2nd Sep 2010 21:04
I did some tests a long while back that showed using them together gave even better performance. I`m nowhere near my own machine for a week or so, but from what I remember the same tests showed better results for hide vs exclude when there is an excessive polycount. I think that the stress on gpu memory was the reason; I think that perhaps exclusion allows the system to put the object data to one side probably by utilising sytem/graphics shared memory because I carried out the tests on the same gfx card on 2 machines; one with a couple gig ram, and one with shared memory enhancements on the mobo with 4 gig ram; I created so many objects the framrate was down to a few fps on the first machine whereas the second machine showed around 20-30 fps for the same amount of objects. Thought it might be worth mentioning.
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 3rd Sep 2010 22:46
What kind of beasts are you all sitting in front of, my fps won't go over a hundred with a clear backdrop!
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 3rd Sep 2010 23:03
I just had the idea of the 'exclude object' command may on the other hand take more time than 'hide object' to do the job. Just a theory, which came up during thinking about what is the sense on having both commands.

If this would be true:
Exclude /include - ideal for example large amounts of stuff to load in at the beginning of the program, and activate when needed.
Hide /show - for things like 'manual' LOD and stuff...

Any thoughts on this? Maybe some other easy little benchmarking snippet could decide... i would write one, but the version of DBP running with me is still a one that doesn't recognize this command.
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 6th Sep 2010 11:01 Edited at: 6th Sep 2010 11:12
I made an infographic to explain this topic better.


Login to post a reply

Server time is: 2026-07-23 09:15:05
Your offset time is: 2026-07-23 09:15:05