Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/19/24 18:45
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (AndrewAMD, 7th_zorro, TedMar, Ayumi, kzhao), 756 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 3 1 2 3
Re: A7 optimization thread [Re: XD1v0] #284344
08/12/09 21:50
08/12/09 21:50
Joined: Nov 2004
Posts: 55
Michigan
S
splashmaker Offline
Junior Member
splashmaker  Offline
Junior Member
S

Joined: Nov 2004
Posts: 55
Michigan
I recently tried the infinite terrain sample from the A7.80 update. The vegetation seems very unoptimized because each grass is a single mesh. The debug panel says there are 2000 entities visible at once crazy . Like mentioned before, use a single mesh for many small objects. This reduces the list the cpu has to send to the rendering chain and takes load off of the cpu.

To make many objects out of one mesh I have an idea that should work. In your modeling application you group all the objects into a single mesh and save it as one mdl file. For example, you could have hundreds of trees in a single mdl file. Arrange the trees in a grid pattern. Keep each tree farther away from the other trees than the maximum length of one tree. You then make a rough measurement of that distance. In the code do a distance check on all the verts to all the verts. Depending on how many verts there are this could take a few seconds since it is a distance check on number of vertices in the mesh squared shocked . Now all the distances that are under the maximum length of a tree are associated with a single tree (via indexed array 1,2,3,4...). Keep which tree the vertices are attached to in a file (each vertice has a unique number that stays the same), then you just have to read from the file upon the game loading. The trees can be individually positioned by creating an array of positions for each tree and checking the array with the index in the text file. If you wanted to put the trees on a terrain you would just use c_trace for each tree and update the array.

Now when the game loads, it modifies the position of all the vertices using ent_set_vertex, and if a tree where rotated you could call ent_fixnormals(). The initial setup of the trees is cpu hungry, but once done has no load on the cpu. Only one call to the rendering chain has to be made for one hundred trees. It is even possible to move individual trees where you want to while the game is running. Waving in the wind can be done by a vertex shader without any modification. This approach may be similar to what speedTree uses, I'm not sure though.

Hopefully you understood some of what I was trying to explain. tongue

Re: A7 optimization thread [Re: splashmaker] #284362
08/13/09 00:50
08/13/09 00:50
Joined: Jul 2004
Posts: 4,206
Innsbruck, Austria
sPlKe Offline
Expert
sPlKe  Offline
Expert

Joined: Jul 2004
Posts: 4,206
Innsbruck, Austria
A7 has a nice WED feature that says export as MDL. you can automatically group all your in WED placed trees and export them as ONE model wink

Re: A7 optimization thread [Re: sPlKe] #284436
08/13/09 11:49
08/13/09 11:49
Joined: Oct 2002
Posts: 806
Zapan@work Offline
User
Zapan@work  Offline
User

Joined: Oct 2002
Posts: 806
I think this won't be a good idea because you can't use correct-LOD for the trees (one model) anymore! Also coll. dectection, shaders, events etc. will be very slow. This is not a good scene-managment!

Re: A7 optimization thread [Re: Zapan@work] #284528
08/13/09 19:14
08/13/09 19:14
Joined: Nov 2004
Posts: 55
Michigan
S
splashmaker Offline
Junior Member
splashmaker  Offline
Junior Member
S

Joined: Nov 2004
Posts: 55
Michigan
@sPIKe: Thanks for the tip, that would be a quick and easy way to place them by hand.

Quote:
I think this won't be a good idea because you can't use correct-LOD for the trees (one model) anymore! Also coll. dectection, shaders, events etc. will be very slow. This is not a good scene-managment!

Good point. laugh There is never going to be a perfect way to do something, it always depends on the situation.

Why would the shaders/events slow down?

My example may be a little misleading, rather than doing this for trees, (usually collision detection is needed as well as lod) you could just do it for grass/brush that has no collision detection. You may even be able to group dense regions of trees into meshes and still have collision/lod working. There is always a balance that depends on your game though. wink

Re: A7 optimization thread [Re: splashmaker] #284629
08/14/09 10:43
08/14/09 10:43
Joined: Oct 2002
Posts: 806
Zapan@work Offline
User
Zapan@work  Offline
User

Joined: Oct 2002
Posts: 806
This will be slow because:
* for shaders you use also LOD -> trees which are far away don't need a "treeWind"/"SpecBump" Shader, for example, so you switch them of (for each tree which is "far" away)
* events will be slow because the collision detection must alwas check the compelte model (more polygons) instead of checking some bounding-boxes of some trees and then check the polygons of these entites which got hit -> much faster

Re: A7 optimization thread [Re: Zapan@work] #285021
08/16/09 16:50
08/16/09 16:50
Joined: Jul 2004
Posts: 4,206
Innsbruck, Austria
sPlKe Offline
Expert
sPlKe  Offline
Expert

Joined: Jul 2004
Posts: 4,206
Innsbruck, Austria
i said you can do this, not that its good to do so laugh

basically, id genereally sue clipping and removing of trees in the distance. place a boudler or something in front of the view you have to walk around. dont make flat terrains. you can clip alot that way...

Re: A7 optimization thread [Re: sPlKe] #310666
02/16/10 13:01
02/16/10 13:01
Joined: Jun 2008
Posts: 146
London
T
Truth Offline
Member
Truth  Offline
Member
T

Joined: Jun 2008
Posts: 146
London
thanks for the optimization tips, how do i pause unseen entities?

Re: A7 optimization thread [Re: Truth] #310673
02/16/10 13:59
02/16/10 13:59
Joined: May 2009
Posts: 1,816
at my pc (duh)
darkinferno Offline OP
Serious User
darkinferno  Offline OP
Serious User

Joined: May 2009
Posts: 1,816
at my pc (duh)
you can read up about the CLIPPED flag, basically:

if(my.eflags&CLIPPED)
-run code

Re: A7 optimization thread [Re: darkinferno] #310717
02/16/10 17:20
02/16/10 17:20
Joined: Mar 2006
Posts: 2,252
Hummel Offline
Expert
Hummel  Offline
Expert

Joined: Mar 2006
Posts: 2,252
I played around with this idea about one year ago:
http://hummel.slindev.com/bilder/everywhere_grass.png
Instancing should be still faster and easier to use but you get a usefull amount of performance through this method too.
You can handle the clipping of the 'groups' by linking it to the clipping of an invisible box using the mentioned CLIPPED flag.

Re: A7 optimization thread [Re: Hummel] #310838
02/17/10 10:22
02/17/10 10:22
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
Try to avoid the usage of the trigger event and trigger_range.
Those range checks have to be done all the time and for many entities it's many checks each frame.

If you don't need it, turn off GLIDE for c_move. It's slow.

Depending on what kind of level you're aiming for try to block the view of the player to allow better clipping. It makes sense to use BSP then (pro only).
Probably not suitable for outdoor levels.

Instead of scaling down textures on blocks, scale up everything else to get the same result. It's faster.

Remove and purge unused stuff.

Page 2 of 3 1 2 3

Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1