logo
Main

Forums

Downloads

Unreal-Netiquette

Donate for Oldunreal:
Donate

borderline

Links to our wiki:
Wiki

Walkthrough

Links

Tutorials

Unreal Reference

Usermaps

borderline

Contact us:
Submit News
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic TimeDemo shows incorrect FPS values when Level.TimeDilation != 1 (Read 2430 times)
Masterkent
Developer Team
Offline



Posts: 1323
Location: Russia
Joined: Apr 5th, 2013
Gender: Male
TimeDemo shows incorrect FPS values when Level.TimeDilation != 1
Jan 28th, 2016 at 1:59pm
Print Post  
When using the console command "TimeDemo 1", the indicated Average / Last Second / Lowest / Highest FPS values correspond to the respective real values multiplied by Level.TimeDilation. Such a multiplication doesn't make sense, because we don't get FPS neither for real nor for virtual in-game seconds (number of frames per virtual second is equal to number of frames per real second _divided_ by Level.TimeDilation, because Level.TimeDilation is the number of virtual seconds that correspond to a real second). For example, with Level.TimeDilation == 2 the game runs 2x faster (1 real second = 2 virtual seconds, 1 virtual second = 0.5 real seconds), so if our real FPS is 60, its equivalent for virtual seconds is 30, but the indicated FPS value is 120.

I think that TimeDemo should show FPS for real seconds.

Note: the case of Level.TimeDilation != 1 is not rare: DeathMatch games are typically played in hardcore mode where the default Level.TimeDilation is 1.1.
  
Back to top
 
IP Logged
 
Masterkent
Developer Team
Offline



Posts: 1323
Location: Russia
Joined: Apr 5th, 2013
Gender: Male
Re: TimeDemo shows incorrect FPS values when Level.TimeDilation != 1
Reply #1 - Jan 28th, 2016 at 4:13pm
Print Post  
I thought that TimeDemo works natively like Stat FPS, but it looks like the statistics is calculated using scripts. So, the root of the problem is that class Engine.TimeDemo is implemented with the assumption that parameter Delta of its function TickTimeDemo represents a time interval in virtual seconds. However, TickTimeDemo is called from Engine.Console.Tick

Code
Select All
event Tick( float Delta )
{
	local int I;

	if ( TimeDemo != None )
		TimeDemo.TickTimeDemo( Delta ); 


where Delta represents a time interval in real seconds (this behavior differs from Engine.Actor.Tick whose parameter DeltaTime is typically measured in virtual seconds). Hence, a lot of divisions by TimeDilation in class Engine.TimeDemo are performed needlessly and produce incorrect results in the end when TimeDilation differs from 1.

Fixed Engine/TimeDemo.uc (further modification is described below)

The comment

Code
Select All
// This is a built-in Unreal class and it shouldn't be modified. 


looks scary, but my tests showed that the modified script resolves the issue. Not sure what exactly was meant by "built-in" there.
« Last Edit: Feb 2nd, 2016 at 3:53pm by Masterkent »  
Back to top
 
IP Logged
 
Smirftsch
Forum Administrator
*****
Offline



Posts: 7923
Location: at home
Joined: Apr 30th, 1998
Gender: Male
Re: TimeDemo shows incorrect FPS values when Level.TimeDilation != 1
Reply #2 - Jan 28th, 2016 at 4:37pm
Print Post  
wondering what their intention was with that. However, can only agree (again) here Smiley.
  

Sometimes you have to lose a fight to win the war.
Back to top
WWWICQ  
IP Logged
 
[]KAOS[]Casey
Developer Team
Betatester
Offline


nedm

Posts: 3180
Joined: Aug 7th, 2011
Gender: Male
Re: TimeDemo shows incorrect FPS values when Level.TimeDilation != 1
Reply #3 - Jan 28th, 2016 at 7:10pm
Print Post  
Masterkent wrote on Jan 28th, 2016 at 4:13pm:
Code
Select All
// This is a built-in Unreal class and it shouldn't be modified. 


looks scary, but my tests showed that the modified script resolves the issue. Not sure what exactly was meant by "built-in" there.


Pretty sure a similar message is generated when ucc auto generates headers for you. I'm guessing what they really mean is don't mess with the global variables since those are modified from C++ end
  
Back to top
 
IP Logged
 
Masterkent
Developer Team
Offline



Posts: 1323
Location: Russia
Joined: Apr 5th, 2013
Gender: Male
Re: TimeDemo shows incorrect FPS values when Level.TimeDilation != 1
Reply #4 - Jan 28th, 2016 at 8:38pm
Print Post  
I wonder if removal of the global variable TimeDilation could break something. Maybe it makes sense to keep it.
  
Back to top
 
IP Logged
 
Masterkent
Developer Team
Offline



Posts: 1323
Location: Russia
Joined: Apr 5th, 2013
Gender: Male
Re: TimeDemo shows incorrect FPS values when Level.TimeDilation != 1
Reply #5 - Feb 2nd, 2016 at 3:36pm
Print Post  
Updated implementation: Engine/TimeDemo.uc
- Reverted the removal of global variable TimeDilation (it's harmless; maybe some mods use it, who knows...)
- Fixed text layout for non-default fonts (see functions PostRender, DrawTextLineExt)

Before fixing:


After fixing:
  
Back to top
 
IP Logged
 
Smirftsch
Forum Administrator
*****
Offline



Posts: 7923
Location: at home
Joined: Apr 30th, 1998
Gender: Male
Re: TimeDemo shows incorrect FPS values when Level.TimeDilation != 1
Reply #6 - Feb 3rd, 2016 at 6:23am
Print Post  
ok, updated it with that.
  

Sometimes you have to lose a fight to win the war.
Back to top
WWWICQ  
IP Logged
 
Masterkent
Developer Team
Offline



Posts: 1323
Location: Russia
Joined: Apr 5th, 2013
Gender: Male
Re: TimeDemo shows incorrect FPS values when Level.TimeDilation != 1
Reply #7 - Feb 9th, 2016 at 11:25am
Print Post  
I noticed another issue: TimeDemo.PostRender does not reset the canvas state before drawing the text. A custom HUD may leave the canvas object in a state that is not appropriate for drawing text in the given case - e.g. by setting DrawColor to black (black text is hardly readable) or making bCenter equal to true (this would mess up the layout completely).

Suggested resolution:

In TimeDemo.PostRender insert

Code
Select All
	C.Reset();
	C.bNoSmooth = true;
	C.DrawColor = MakeColor(255, 255, 255); 


before setting the canvas font.

Updated implementation: Engine/TimeDemo.uc
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint
Bookmarks: del.icio.us Digg Facebook Google Google+ Linked in reddit StumbleUpon Twitter Yahoo