• Advertisement
Sign in to follow this  

Rendering solution for saving and increasing performance

This topic is 2398 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
So what rendering method are you using now? What GL functionality are you using?

Share this post


Link to post
Share on other sites
What GL functionality are you using?[/quote]

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?[/quote]


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;
}
cAppMain::onUpdate(); //Updates messages/events

if (!cAppMain::bInActive){
cGLDriver::UpdateWorld(); //Matrix calculation of each registered object (If changes where made)
cVgVoxelFactory::onUpdate(); //Updates the voxelfactory, recalculates voxels (If changes where made)

cAppMain::lpMainViewport->UpdatePickings(); //Updates the pickings - editor only
cVmSidebar::UpdateSidebar(); //Updates the sidebar - 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();

}

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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 ...

Share this post


Link to post
Share on other sites

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 ...[/quote]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.

Share this post


Link to post
Share on other sites
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.[/quote]

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"

Share this post


Link to post
Share on other sites

[quote name='Lunatix' timestamp='1308942732' post='4827324']
I believe you, but the eye can only see 24 fps.


http://www.100fps.co..._humans_see.htm
[/quote]

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement