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.

Dark GDK / Slow Game

Author
Message
NoviceNate333
6
Years of Service
User Offline
Joined: 7th Dec 2012
Location: United States
Posted: 31st May 2013 05:12
Hi I have ran into a problem and I need some Expert help .
I have been working on this game for around 5 or 6 days now and I have drawn Rocks trees and grass to the screen. I am using the distance formula to hide objects that are far away.
Distance = Square Root((x2-x1)^2+(y2-y1)^2))
It is a kind of small terrain. So im wondering why does it run sooo slow is there anything i can do to increase the performance with out diving into the low level directX api stuff.
right now its running at around 30 fps and when i added a post processing effect for depth of field it went down to only around 10 and that is not tolerable. I can post my code if you can find a better/ more efficient way to do it.

Mr Bigglesworth
11
Years of Service
User Offline
Joined: 4th Mar 2008
Location:
Posted: 31st May 2013 07:54
Post your code. Are your rocks and trees high poly (what is their polycount)? What are your computer specs?

It shouldn't be running that slow unless you have a massive amount of objects or they are really high poly.
NoviceNate333
6
Years of Service
User Offline
Joined: 7th Dec 2012
Location: United States
Posted: 1st Jun 2013 06:06
Since my Code is in separate files I thought it would be logical to post the files. Also my computer specs are average. They are enough to play skyrim on high settings soo they should be enough for this. I have a quadcore 3.10 ghz processor 4Gb of Ram a 1 Gb NVIDIA Graphics card. Also Some of the code is unfinished so its not all exactly organized, but i used separate files and classes so i can keep reusing my code for the future, but I am thinking of switching to leadwerks.

Attachments

Login to view attachments
NoviceNate333
6
Years of Service
User Offline
Joined: 7th Dec 2012
Location: United States
Posted: 1st Jun 2013 06:10
Also about poly count the grass is just two perpendicular billboards there are 50 rocks in whole scene and i would say they may be at around 500 and the trees prob between 500 and 800, and dont have all of the terrain showing at the same time. I am not sure if it actually works but i scaled down the sky to hide some of the hills in the distance.
Rudolpho
13
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 1st Jun 2013 11:18 Edited at: 1st Jun 2013 11:21
Your code looks OK to me (I only read the hiding parts though), but I am unable to test it since I don't have DGDK1 on this computer.

Anyway, what you could do is use squared distances for comparisons instead; in that way you will save yourself some unneccesary execution time on the square root operations. You could also look into frustum culling and combine that with distance culling; that should be able to reduce the number of rendered objects to between 1/2 and 1/4:th on average, maybe more depending on your field of view and vantage points. You could also (obviously) reduce the clipping distance. One clever thing is to set it to a factor of the objects' average size so that grass won't be rendered unless it's, say, closer than 50 meters away while trees will still be seen at 400 meters distance. For more complex objects like the trees you could also use several LOD meshes that you switch between based on the distance.

I manage to get decent speeds in my game engine using the above approach. I also use a separate culling thread that checks distances between the camera and all scene objects over time; as such it is possible that not all objects are culled in sync with each screen refresh and we thus get rid of the slowdown that may occur because of checking / updating all objects (of course you have to use some kind of locking mechanism to ensure that the culling thread is paused while the actual rendering takes place).

Hope that helps


Edit:
Quote: "I am not sure if it actually works but i scaled down the sky to hide some of the hills in the distance."

That will not help (unless you set the camera range accordingly). DGDK does not support native occlusion culling.


"Why do programmers get Halloween and Christmas mixed up?"
NoviceNate333
6
Years of Service
User Offline
Joined: 7th Dec 2012
Location: United States
Posted: 2nd Jun 2013 06:08
When i got rid of the square root operation my FPS jumped from 28-31 to 45-46. WOW haha that is a dramatic change! Also Rudolpho How would i go about creating lod objects for the trees im thinking a 2d billboard would be a good lod object but how would you implement it would you create just as many lod objects and hide and show them based on distance, or is there some way to just alter the appearance instead of instancing 1000 new objects.

one other thing I have never heard of frustrum culling what is it and how does it work
NoviceNate333
6
Years of Service
User Offline
Joined: 7th Dec 2012
Location: United States
Posted: 2nd Jun 2013 09:47
Sorry for the double post but I did the frustrum culling by hiding all trees and grass that is off of the screen, and I added lod to the trees so you can see them from much farther away. I did actually use a 2d billboard and made a plane object that faces the camera. I have topped out at 51 fPS. Is there anything else I can do to get to 60?


greenshot download
Rudolpho
13
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 4th Jun 2013 02:40
What are your system specs?
Are you using any heavy duty shaders or are your models overly high-poly? How much floor covers (ie. grass) are you using? It sounds a bit weird that you shouldn't get a higher framerate.

Still so, 50FPS is completely playable so if you aren't going to be adding more content that would be likely to further slow it down (which I'm assuming is your intention however) it should be good enough.


"Why do programmers get Halloween and Christmas mixed up?"

Login to post a reply

Server time is: 2019-09-19 20:38:02
Your offset time is: 2019-09-19 20:38:02