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.

FPSC Classic Product Chat / Possible code optimisation - thoughts please

Author
Message
Scene Commander
Support Manager
16
Years of Service
User Offline
Joined: 3rd May 2008
Location:
Posted: 9th May 2009 16:49 Edited at: 9th May 2009 17:57
Hi,

I've recently been looking through the FPSC code, I don't actually own DBP, so, I've only been viewing the code with the trail version and therefore can't test this idea, but it seems to me that by hiding objects over a certain distance with the addition of something along the attached lines at around row 6008 would improve performance.



The code is pretty simple and ideally would be changed to allow objects to fade in and out but I'd have thought that this would help performance, or am I missing something? (As I say I can't test this so can't see the affect it would have).

*EDIT* Should have said this is based on the V115 source.
Black Profductions
16
Years of Service
User Offline
Joined: 15th Sep 2008
Location: Argentina
Posted: 9th May 2009 16:51
it would be great, modders please, test it
You could discovered the best of fps creator

Wizzkid
AGK Tool Maker
18
Years of Service
User Offline
Joined: 14th Aug 2006
Location: Northern Ireland
Posted: 9th May 2009 17:58 Edited at: 9th May 2009 18:00
Myself and AppleSlicer are working on optimisations like this in WizMod



Scene Commander
Support Manager
16
Years of Service
User Offline
Joined: 3rd May 2008
Location:
Posted: 9th May 2009 18:00
Sounds like you've already tried this idea then?
Wizzkid
AGK Tool Maker
18
Years of Service
User Offline
Joined: 14th Aug 2006
Location: Northern Ireland
Posted: 9th May 2009 18:01
Yes, in the version available this has been reduced to 600.



Scene Commander
Support Manager
16
Years of Service
User Offline
Joined: 3rd May 2008
Location:
Posted: 9th May 2009 18:05 Edited at: 9th May 2009 18:11
Yep, 10000 was rather generous? Is your code similar to mine? Was wondering how well it works? (I really should buy DBP, but cash flow and all that!)
Nickydude
Retired Moderator
17
Years of Service
User Offline
Joined: 4th Nov 2006
Location: Look outside...
Posted: 9th May 2009 18:15
But what if you're looking down a long corridor? Wouldn't entities just 'pop' into view?

Scene Commander
Support Manager
16
Years of Service
User Offline
Joined: 3rd May 2008
Location:
Posted: 9th May 2009 18:25 Edited at: 9th May 2009 18:57
Agreed, which is why they would need to fade in/out, but it wouldn't be hard to adjust the entities alpha blend

There's a variable in the source,

entityelement(e).ai.alphafade

the easiest way would be to start to fade in from 0 to 100 (or it's set max) before showing the object and visa versa to hide it. The alpha fade just needs to be calculated on it's distance.

Something like this (please excuse my coding)



Should seem pretty smooth.

In fact this could be expanded by giving every entity an appear at distance, so smaller objects fade in later than larger ones, but this would involve a little more coding.
Airslide
19
Years of Service
User Offline
Joined: 18th Oct 2004
Location: California
Posted: 9th May 2009 20:39
The problem is that you would have to add a visibility flag to the entity since entity's can sometimes be hidden in other parts of the engine. You'd probably need a separate alpha fade variable too in order to avoid overriding the existing one when say, a character is fading out.

Apple Slicer
15
Years of Service
User Offline
Joined: 14th Nov 2008
Location: Oregon, in the rain...
Posted: 9th May 2009 20:47
Sounds like a LOD system there.

Airslide
19
Years of Service
User Offline
Joined: 18th Oct 2004
Location: California
Posted: 9th May 2009 20:59
Not really. An LOD system requires a low-poly version of the model as-well (or multiple stages of detail).

Scene Commander
Support Manager
16
Years of Service
User Offline
Joined: 3rd May 2008
Location:
Posted: 10th May 2009 05:33 Edited at: 10th May 2009 05:50
Quote: "The problem is that you would have to add a visibility flag to the entity since entity's can sometimes be hidden in other parts of the engine. You'd probably need a separate alpha fade variable too in order to avoid overriding the existing one when say, a character is fading out."


Hi Airslide, I have to admit, I haven't reviewed the entire source, but it seems to me that the code ignores disabled entities with the exception of AI and if an entity is hidden by another part of the engine it stay's hidden.... I'm sure I'm wrong but I'd love to hear your (or anyone's) comments...
Airslide
19
Years of Service
User Offline
Joined: 18th Oct 2004
Location: California
Posted: 10th May 2009 05:56
A) "hide object(obj)" should be "hide object obj"
B) You're still overriding the alpha fade - it will bug things out if say a character is fading out due to death and the player moves away, then the character's alpha will be overwritten and they will never properly fade out.
C) Since you are hiding it when you get to 0 it doesn't seem like you are ever showing it again. Plus, it would override any point in the engine where the entity is already being made invisibe/visible.

To do this effectively you'd have to add a visible flag to entityelement and then set that at every point in the source where the engine hides/shows the object. There's also other reasons why that actual particular bit of code won't work but they aren't important to the principal.

Scene Commander
Support Manager
16
Years of Service
User Offline
Joined: 3rd May 2008
Location:
Posted: 10th May 2009 06:00 Edited at: 10th May 2009 06:16
Airslide:

All good points, may I email you?
Scene Commander
Support Manager
16
Years of Service
User Offline
Joined: 3rd May 2008
Location:
Posted: 13th May 2009 03:58
I guess that's a no..

Many thanks for your support.
Dar13
16
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 13th May 2009 04:10
Other DBPro code optimizations are in this thread and this thread. The mathematical ones in the second one seem to be extremely helpful as there are hundreds of realtime calculations(LOTS of dividing by constants), so there should be an increase in speed.

...
Scene Commander
Support Manager
16
Years of Service
User Offline
Joined: 3rd May 2008
Location:
Posted: 13th May 2009 04:42 Edited at: 13th May 2009 04:50
Hi,

I don't think you quite understand.

I was making a suggestion on optimization of the FPS source not DBP..

I hadn't intended to originally comment on DBP but since you offered the links... I don't find it a great language, it's extremely non-standard regarding syntax and consider it's performance well below par in comparison to similar languages.

Despite that I think the FPSC is worth some effort and had hoped to offer some advice on performance (untested as stated)

BTW, firstly, if anyone feels they should doubt my right to comment on programming issues, I've been involved in software development since 1981, I've had several of my personnel projects published and had been involved in numerous others.

Secondly, these comment's I'm sure won't make me the most popular person on the forum but I can't believe the lack of community spirit on this forum... Every man for him/her self apparently (And I'm referring to this direct forum, not the modeling/scripting/etc forums where I've seen some real community spirit!..

Sorry about the rant folks... Needed to get that of my chest...

Edit: Apologies to Dar13 who on re-reading his links, I now think was trying to be honestly helpful...
Dar13
16
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 13th May 2009 21:04
@Scene Commander: I meant that those tips could help optimize the code DBPro compiles to make FPSC, not the DBPro source. Sorry for the misunderstanding.

There is so much run-time math going on, I thought people could afford to optimize it as much as possible.

I really like your game demo you released quite a while ago, too.

...
Scene Commander
Support Manager
16
Years of Service
User Offline
Joined: 3rd May 2008
Location:
Posted: 14th May 2009 07:53
No problem Dar13..

Quote: "There is so much run-time math going on, I thought people could afford to optimize it as much as possible. "


I totally agree, one of the first things I noticed is the massive number of repeat calculation in the main cycle.

Quote: "I really like your game demo you released quite a while ago, too"


Many thanks.. That project isn't dead but we've been having a number of performance issues on low end machines and a build game problem which kept crashing one level upon loading, I believe this issue was solved in one of the updates and hopefully we'll get back to the project in earnest.
Avid
17
Years of Service
User Offline
Joined: 24th Jun 2007
Location:
Posted: 14th May 2009 20:31
Does anyone know if the DX files already support LODs? I know it's a feature of X files, but is it taken advantage of?

Visit my site http://www.fpsmodels.com for models and media for fps creator.
Dar13
16
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 15th May 2009 22:33
@Avid:There is no LOD in FPSC at all.

...
veltro
User Banned
Posted: 15th May 2009 23:05
entityelement(e).plrdist=sqrt(abs(tdx#*tdx#)+abs(tdy#*tdy#)+abs(tdz#*tdz#))

but abs (x * x) is equal to (x * x)

so the abs functions can be removed
Scene Commander
Support Manager
16
Years of Service
User Offline
Joined: 3rd May 2008
Location:
Posted: 16th May 2009 07:59
Quote: "but abs (x * x) is equal to (x * x)"


Actually the above line is a direct port from the FPS code, and although I haven't studied the full code I assume that at some point it's possible for tdx...y.. or z to become negative (in fact I can't see how it wouldn't), hence the need to use ABS.
veltro
User Banned
Posted: 16th May 2009 14:48
a negative number multiply by itself gives always positive result, isn'it?

-2 * -2 = 4
2 * 2 = 4
djmaster
User Banned
Posted: 16th May 2009 16:48
Negative with negative is positive,negative with positive is negative and positive and positive is positive.Thats all the science.

A.K.A. chargerbandit
[href]http://chargedstudios.ultimatefpsc.com/[href]
Scene Commander
Support Manager
16
Years of Service
User Offline
Joined: 3rd May 2008
Location:
Posted: 16th May 2009 21:00
Quote: "Negative with negative is positive,negative with positive is negative and positive and positive is positive.Thats all the science."


Ah, yes, didn't spot that as I simply cut and pasted the line from the code to save time..

I feel rather stupid now..
Airslide
19
Years of Service
User Offline
Joined: 18th Oct 2004
Location: California
Posted: 16th May 2009 23:09
In AirMod SE I removed the abs() from the distance checks along with a lot of the sqrt() references (instead I'm squaring the comparison - or multiplying it by itself to be exact, apparently that's even faster).

There are lots of little optimizations to be made in FPSC and to be honest I'm amazed it runs as well as it does.

Scene Commander
Support Manager
16
Years of Service
User Offline
Joined: 3rd May 2008
Location:
Posted: 17th May 2009 03:37 Edited at: 17th May 2009 03:54
Quote: "There are lots of little optimizations to be made in FPSC and to be honest I'm amazed it runs as well as it does"


I agree.

As stated I haven't made a major effort to work through the code and I must say again that I really don't like DBP but reading through the FPS source it is inspiring me to buy it simply to alter FPS code.

It seems to me that maths functions are replicated for almost every function when a simple single variable definition would suffice.

My guess would be that the code was written for possible change, although the comment regarding ABS, make sense but I'm guessing are old school, I remember a day when ensuring you had an absolute value was a safety net for future coding rather than bad code... (I actually remember a time when you could crash a machine for trying to display certain ASCII files..).... Feeling very old now..

Having said that the FPS code reads to me like a project built on the fly and had I written it originally I'd almost start from the beginning for any migration...

Edit... Airslide, I'm interested on your thoughts on sqrt(), is the DBP actual functions slower than the basic maths? and does anyone have statistics to back that up?
Dar13
16
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 17th May 2009 04:07 Edited at: 17th May 2009 04:09
@Scene Commander: There are lots of threads about this and there was even one that had several people doing tests, and it was proposed that vector-based distance checking would be faster than sqrt().

Check out Van B's post about halfway down the page. Since FPSC is already in grid-form, it shouldn't be too hard to implement.

-EDIT-Just rethought my idea and relooked at the source, I think this would have to have a rewrite of the culling, rendering, and loading code of FPSC.

...
Scene Commander
Support Manager
16
Years of Service
User Offline
Joined: 3rd May 2008
Location:
Posted: 17th May 2009 04:16
Thank's Dar13

Do you have a link?
Dar13
16
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 17th May 2009 04:21
Ahh, here it is.

...
Scene Commander
Support Manager
16
Years of Service
User Offline
Joined: 3rd May 2008
Location:
Posted: 17th May 2009 04:33
Many thanks,

Interesting and useful...
Dar13
16
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 17th May 2009 04:38
No problem. Glad to help.

...
Scene Commander
Support Manager
16
Years of Service
User Offline
Joined: 3rd May 2008
Location:
Posted: 17th May 2009 04:50
Hi,

Having read through the link Dar13 sent me, I'm still concerned.. How can any language require more time to process basic math than the formula itself?

I'm now thinking this is the wrong part of the forums..
Scene Commander
Support Manager
16
Years of Service
User Offline
Joined: 3rd May 2008
Location:
Posted: 17th May 2009 04:59
Quote: "In AirMod SE I removed the abs() from the distance checks along with a lot of the sqrt() references (instead I'm squaring the comparison - or multiplying it by itself to be exact, apparently that's even faster)."


Airslide, interesting, and what performance increase have you seen?
Dar13
16
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 17th May 2009 14:44 Edited at: 17th May 2009 15:05
The vector function is straight coded in C++(three times faster than DBPro) while the only the sqrt() and abs() is so DBPro has to do it manually, which is pretty dang slow.

-EDIT- Sig test.

Login to post a reply

Server time is: 2024-10-16 01:20:54
Your offset time is: 2024-10-16 01:20:54