• Create Account

## Rendering solution for saving and increasing performance

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

10 replies to this topic

### #1Lunatix  Members

143
Like
0Likes
Like

Posted 23 June 2011 - 04:40 PM

Hey there !

I am working on an indie game in time, currently on editors and the engine. Screenshot?
Well, the engine runs very good, (don't worry about the FPS, screenshot is a bit outdated, i increased the performance in the last week).

So, i like to implement a rendering process function, that increases performance by rendering only something like "35 FPS"

Currently, the functions looks like:
// main loop
while(!bQuit){

UpdateMessages(); //What messages from windows?
UpdateRenderingObjects(); //Calculations, like "was object x moved? if true, recalculate its model matrix

RenderWorld();  //Renders everything
FlushStates(); //Reset keystates and... other stuff
}

So, i like to implement a resource saving process, but i had have no idea, so i ask you for your solution, how do you implement something like this?
You like voxels? Then you may like... http://gameworx.org/?p=36

### #2V-man  Members

813
Like
0Likes
Like

Posted 23 June 2011 - 06:14 PM

So what rendering method are you using now? What GL functionality are you using?
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

### #3Lunatix  Members

143
Like
0Likes
Like

Posted 24 June 2011 - 12:43 AM

What GL functionality are you using?

I'm using VertexBufferObjects for the geometry data and a few "deprecated" calls for displaying the colors in the sidebar. (See the screenshot in my first post).
The geometry is shaded, colored and lighted via Deferred rendering and Screenspace Ambient Occlusion.

I don't use glut or something else, i have my own engine with C++ and glew.

So what rendering method are you using now?

Currently i have a loop like this, but it doesn't work realy good. It is an very old code fragment from one of my "BlitzBasic3D" codes, maybe 5 years old.
But in Blitz3D, there was a function "RenderWorld( float FrameTween = ?)" placed inside the updating loop too:

My focus was mostly the engine, the shaders, the rendering scripts, and and and... and now i thought about a newer and better rendering loop ;)

int main(int argc, char* argv[]){

if (!cAppMain::Initialize(argc,argv)){
cCoreConsole::cout<<"Unable to initialize client\r\n";
cCoreConsole::Flush();
return 0;
}

bool        	bQuit   		= 0;
float			FrameEllapsed	= 0.0f;
float			MaxFrames		= 35.0f;
unsigned int	FramePeriod		= 1000.0f / MaxFrames;
unsigned int	FrameTime		= GetTickCount() - FramePeriod;

while(!bQuit){

unsigned long iCalcStart = GetTickCount();
unsigned long AcTime = GetTickCount();

do{
AcTime = GetTickCount();
FrameEllapsed = AcTime - FrameTime;
}while(!FrameEllapsed);

int FrameTicks = FrameEllapsed / FramePeriod;

for (int ticks=0;ticks<FrameTicks;ticks++){
FrameTime = FrameTime + FramePeriod;

if (cAppMain::onEvent()){		//Returns true, if the user hit the [x]button
bQuit = true;
break;
}

if (!cAppMain::bInActive){
cGLDriver::UpdateWorld();		//Matrix calculation of each registered object (If changes where made)

cAppMain::lpMainViewport->UpdatePickings();		//Updates the pickings - editor only

cAppMain::lpMainViewport->UpdateViewport();		//Updates the movements in editor

cUIManager::ClearKeyStates();	//Clears the keystates, to avoid double clicking
}

cCoreConsole::Flush();
cGLDriver::Flush();
}

if (!cAppMain::bInActive){

cAppMain::lpMainViewport->RenderScreen();			//Renders all things to screen
cVmSidebar::RedrawSidebar();						//Renders the sidebars color changer
}

cLuaObjectBuffer::FlushTimer();
}

cAppMain::onShutdown();

}


You like voxels? Then you may like... http://gameworx.org/?p=36

### #4V-man  Members

813
Like
0Likes
Like

Posted 24 June 2011 - 02:04 AM

Using VBO is good. Some info about them here. http://www.opengl.org/wiki/Vertex_Buffer_Object
http://www.opengl.org/wiki/VBO_-_more
http://www.opengl.org/wiki/VBO_-_just_examples

other than that, you need to determine your bottleneck. Perhaps gDebugger can help
http://www.opengl.org/wiki/Debugging_Tools
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

### #5Lunatix  Members

143
Like
0Likes
Like

Posted 24 June 2011 - 06:03 AM

Sorry, i think you misunderstood my problem ;)

My problem aren't the/any bottlenecks (there are bottlenecks, i have located several of them and fixed them, increased the speed from 50ms/frame to 24 ms per frame since yesterday)
My problem is the rendering method itself.

The Player "sees" only 24FPS with his eye, so i think rendering 35 FPS per secound is enough, the rest of the time should be spend on calculations. So i don't search for bottleneck optimizations, i search for a good rendering loop, saving time for calculations.

I don't know, what to search for in google, "rendering loop" or something else doesn't realy gives good results ...
You like voxels? Then you may like... http://gameworx.org/?p=36

### #6Hodgman  Moderators

49431
Like
0Likes
Like

Posted 24 June 2011 - 06:37 AM

The Player "sees" only 24FPS with his eye, so i think rendering 35 FPS per secound is enough...

ugh... The player can "see" over 200FPS (if they had a 200HZ monitor instead of a 60HZ one).
Films only look good at 24fps because they have motion blur. Without motion blur, animation at 24fps looks absolutely horrible.

So i don't search for bottleneck optimizations, i search for a good rendering loop, saving time for calculations.
I don't know, what to search for in google, "rendering loop" or something else doesn't realy gives good results ...

I'm not quite sure what you're looking for either -- perhaps you want to run your update and rending code each at a different FPS? If so, check out the standard link.

### #7Lunatix  Members

143
Like
0Likes
Like

Posted 24 June 2011 - 01:12 PM

Yes, this was exactly what i searched for! Thank you very much =)

ugh... The player can "see" over 200FPS (if they had a 200HZ monitor instead of a 60HZ one).
Films only look good at 24fps because they have motion blur. Without motion blur, animation at 24fps looks absolutely horrible.

I believe you, but the eye can only see 24 fps. So, if i choose to display 40 - 60 fps, it looks good to player... or am i wrong ? I will not "cap" it at 35 - but i want to implement a function that says: "35 fps - all other resources to the computing behind the scenes. if the computing behind the scenes don't need all of this resources -> display more fps"
You like voxels? Then you may like... http://gameworx.org/?p=36

### #8King Joffrey  Members

150
Like
1Likes
Like

Posted 24 June 2011 - 01:41 PM

I believe you, but the eye can only see 24 fps.

http://www.100fps.com/how_many_frames_can_humans_see.htm

### #9V-man  Members

813
Like
0Likes
Like

Posted 25 June 2011 - 05:53 AM

I believe you, but the eye can only see 24 fps.

http://www.100fps.co..._humans_see.htm

That's a pretty good link. Thanks.
Also, even for movies, 24 FPS looks crappy even if they use motion blur. That's why I hate going to the movies.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

### #10OpenGLBook  Members

116
Like
1Likes
Like

Posted 25 June 2011 - 11:29 PM

That's a pretty good link. Thanks.
Also, even for movies, 24 FPS looks crappy even if they use motion blur. That's why I hate going to the movies.

IIRC:

I worked as an optician for quite a while, and when I received my training there was a similar question. Turns out that the brain can distinguish visual changes up to about 60 Hz, that's why when you see a car wheel rotate (or a helicopter's rotors), at a certain point, the wheel seems to rotate backwards or stand still since your brain has to interpolate between images that have almost no visual changes.

Also, when you shake your hand really fast in front of your face, it seems blurred, which is also your brain "filling in the blanks" with blur past 60 Hz. One last example, which is fun: take a pencil, one that hasn't been used much yet so it's plenty long. hold lightly at one end, and shake it so that the other end moves smoothly up and down (along the Y-axis so to speak). Whilst in motion, the pencil will seem like it's bending due to the brain interpolating.
Thanks, Eddy

### #11Narishma  Members

119
Like
1Likes
Like

Posted 30 June 2011 - 01:25 PM

In addition to what the others have said, rendering with a high frame rate also helps a lot with input latency.
Good article on the subject: http://www.gamasutra.com/view/feature/1942/programming_responsiveness.php

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.