Tips for improving performance
by Rick Austinson · in Torque Game Engine Advanced · 05/22/2009 (5:20 pm) · 15 replies
All right, So I'm quite new at this and I could use a few tips and tricks for making my levels perform better. Everything started out looking great, but as I add more and more assetts, the FPS is starting to drop and its starting to get a bit laggy. Right now there is upwards 125,000 tris in the environment, spread out among dozens of models(with no one model over 10,000). Everything is built properly with no wasted tris, I am a skilled moddeller, but this practice of getting things into game engines is a bit new. Its already starting to lag and I've got easily another 200-300,000 more tris worth of models that will be added.
Basically, I really don't know how to do anything much beyond drag and drop, so forgive my many n00b questions that will follow. Thank you in advance for any advice.
Basically, I really don't know how to do anything much beyond drag and drop, so forgive my many n00b questions that will follow. Thank you in advance for any advice.
#2
05/22/2009 (5:51 pm)
Hey Michael, you seem like somebody good to network with, what do you say we pool or ignorance? Are you on any instant messenger programs?
#3
2. Smaller textures are better, but not better than less textures. The magic texture size is 256x256. It's hard to stick to that nowadays, but there are still plenty of things that can be done.
3. Use LOD on your models. Take advantage of the LOD small sizes to use smaller textures also.
4. Less models is better than more models. For example, if you combine two small models you always put together in on large one, you get a win.
5. Use DDS textures when possible.
There are 5 things that can help with your speed, I am sure there are plenty more.
05/22/2009 (6:07 pm)
1. Less textures is better than more textures.2. Smaller textures are better, but not better than less textures. The magic texture size is 256x256. It's hard to stick to that nowadays, but there are still plenty of things that can be done.
3. Use LOD on your models. Take advantage of the LOD small sizes to use smaller textures also.
4. Less models is better than more models. For example, if you combine two small models you always put together in on large one, you get a win.
5. Use DDS textures when possible.
There are 5 things that can help with your speed, I am sure there are plenty more.
#4
Also, I have been painstakingly re-texturing all of my models with jpegs because I cannot get DDS files to work, is there some trick to using DDS?
Thanks for the suggestions, I'll start putting them into play.
05/22/2009 (6:11 pm)
Can you explain how to set LODs? I have heard that term used dozens of times all over the forums but I cannot find any explanation of how it works, what it does, or what 'LOD' even stands for. Also, I have been painstakingly re-texturing all of my models with jpegs because I cannot get DDS files to work, is there some trick to using DDS?
Thanks for the suggestions, I'll start putting them into play.
#5
DDS should be exported in DXT1 or DXT5 compression, and use mipmaps.
LOD: Level of Detail. When the model changes size on screen (via distance) the LOD changes to a different model with less tris. So as you get further away, the model gets smaller, then changes to a new lower tris model.
How you do it kind of depends on what program you use for modelling, but as a rule of thumb: "detail" nodes are what controls it. Has to be set up in model and exported like that.
Tris. Do you really need 10k tris models? You can fake a lot of small details with normal mapping.
Check out the documentation --> artists section of the site. For tutorials on these sorts of things. It's found under "Support" on the menu bar of every page of the GG site. Also read tutorials on modelling programs that you don't use, they can still be useful in understanding what you should do.
05/22/2009 (6:49 pm)
1024x sized textures devour memory. 512x don't cause much of a noticeable hit over 256x.DDS should be exported in DXT1 or DXT5 compression, and use mipmaps.
LOD: Level of Detail. When the model changes size on screen (via distance) the LOD changes to a different model with less tris. So as you get further away, the model gets smaller, then changes to a new lower tris model.
How you do it kind of depends on what program you use for modelling, but as a rule of thumb: "detail" nodes are what controls it. Has to be set up in model and exported like that.
Tris. Do you really need 10k tris models? You can fake a lot of small details with normal mapping.
Check out the documentation --> artists section of the site. For tutorials on these sorts of things. It's found under "Support" on the menu bar of every page of the GG site. Also read tutorials on modelling programs that you don't use, they can still be useful in understanding what you should do.
#6
Thanks for explaining LOD, I was familliar with the concept but hadn't heard the terminology. It's going to take some doing but I suppose I could incorporate it if things get desperate enough.
As for the high tri-counts, its not what you think. These arent tiny models we're talking about here, all the smaller stuff has much smaller counts. It's things like a giant level-spaning suspension bridge that get huge. I am actually very liberal with my polys, after all, waste not, want not. I've spent a lot of time painstakingly optimizing my models for the best compromise between detail and tri-counts. They are well-built.
I suppose I should also probably mention; in the case of my project, it's menat as an environmental showpeace, there are no actual game-play elements invovled, you just kind of wander around an explore, so its really all about the models.
I'll look over those tutorials, thanks for the imput.
05/22/2009 (7:10 pm)
I'll start reziing all my textures to 512, do you know a way to remap the textures to DDS in torque? I use DDS for everything by habbit, but when I first began work on this project I couldn't get the DDS textures to work so I began paintakingly remapping everything in Max into jpegs. However, if I have to go back to max, I will loose dozens of hours of painstakingly importing and placing models. In fact I'd essentially have to start work on the level all over again. Thanks for explaining LOD, I was familliar with the concept but hadn't heard the terminology. It's going to take some doing but I suppose I could incorporate it if things get desperate enough.
As for the high tri-counts, its not what you think. These arent tiny models we're talking about here, all the smaller stuff has much smaller counts. It's things like a giant level-spaning suspension bridge that get huge. I am actually very liberal with my polys, after all, waste not, want not. I've spent a lot of time painstakingly optimizing my models for the best compromise between detail and tri-counts. They are well-built.
I suppose I should also probably mention; in the case of my project, it's menat as an environmental showpeace, there are no actual game-play elements invovled, you just kind of wander around an explore, so its really all about the models.
I'll look over those tutorials, thanks for the imput.
#7
05/22/2009 (7:36 pm)
You won't have to remove your models you've already placed. Just make sure to name the new ones the same as the old ones and place them in the same folders. Your scale and transforms will remain.
#8
Another thing you can do to help your performance is create low-poly convex collision meshes to surround your object, rather than use polysoup. You'll get the most benefit by creating convex shells for any objects with a lot of high polygon density. This way everything will still look high poly, but collision calculations and some shadow calculations will use the lower-detail collision meshes.
Also if you have any smaller high poly density objects that don't really need to have dynamic shadows cast on them, turn off the shadow receiver flags for those.
05/22/2009 (7:59 pm)
Just to elaborate on what Mike said; when you export your models into DTS, the file extension is usually stripped off of the texture names. So, for instance, if you have a texture named blueunicorn.jpg, the DTS just has the texture named "blueunicorn", and looks for a file in the same folder with that name followed by any of the acceptable file extensions. So you could use blueunicorn.jpg, blueunicorn.png or blueunicorn.dds (or a few others). So if you're using a JPG you can just convert it to DDS and not have to re-export or anything, as long as the texture layout is the same.Another thing you can do to help your performance is create low-poly convex collision meshes to surround your object, rather than use polysoup. You'll get the most benefit by creating convex shells for any objects with a lot of high polygon density. This way everything will still look high poly, but collision calculations and some shadow calculations will use the lower-detail collision meshes.
Also if you have any smaller high poly density objects that don't really need to have dynamic shadows cast on them, turn off the shadow receiver flags for those.
#9
You could find this out by checking out any profiling stats, which is enabled from scripts. It can show you where Torque is spending most of its time.
Shadows in TGEA could be a real performance hog if you weren't careful. They eat CPU (because they use the already slow collision scheme [ugh] and process the geometry in a depth partition and potentially could use several draw calls each to render depending on the geometry they are projected onto) and unfortunatly the BlobShadow class is the same in that regard.
05/23/2009 (12:41 am)
In the end, your slowdown could be anything. I think it sounds like you're CPU bound (but it obviously depends on what rig you're running).You could find this out by checking out any profiling stats, which is enabled from scripts. It can show you where Torque is spending most of its time.
Shadows in TGEA could be a real performance hog if you weren't careful. They eat CPU (because they use the already slow collision scheme [ugh] and process the geometry in a depth partition and potentially could use several draw calls each to render depending on the geometry they are projected onto) and unfortunatly the BlobShadow class is the same in that regard.
#10
I am actually really not having many performance problems with my game, its just starting to get a little laggy, and thats usually when I have 3 instances of 3D studio MAX open in the background. As much as I'd love a high-end workstation, I am currently working off of a machine that is less than steller. But disabling shadows should be a pretty quick fix, thats a start. I do expect to spend weeks tweaking an optimising this game, just getting a few tips ahead of time.
Thanks.
05/23/2009 (12:49 am)
Wow, that thing about the textures is so awesome! That actually makes torque better than any game engine I've used in that sense, will definitely make my conversion process easier! Whew. Everything's actually already saved in DDS, so the swap over will be about 30 minutes(as apposed to the 30 hours I was afraid it would take). Just got to double-check all the filenames. I am actually really not having many performance problems with my game, its just starting to get a little laggy, and thats usually when I have 3 instances of 3D studio MAX open in the background. As much as I'd love a high-end workstation, I am currently working off of a machine that is less than steller. But disabling shadows should be a pretty quick fix, thats a start. I do expect to spend weeks tweaking an optimising this game, just getting a few tips ahead of time.
Thanks.
#11
My theory is that TGEA(and T3D also) is running at full CPU time, and background process end up breaking in at fixed intervals, basically pausing Torque for some MS, causing it to act laggy.
05/23/2009 (1:00 am)
Im working on tracking down an side issue i have been having; would you be so kind as to enter $Pref::timeManagerProcessInterval = 20; into the console (might be any number from 5 to 50) and see if that remove the laggy behavior? I had noticed anytime i run many CPU intensive tasks at the same time of TGEA level design the TGEA rendering become chunky and jittery (Also may go away if you run in fullscreen mode).My theory is that TGEA(and T3D also) is running at full CPU time, and background process end up breaking in at fixed intervals, basically pausing Torque for some MS, causing it to act laggy.
#12
2. Use LOD levels for geometry.
3. Use visible distance that discards object's render at great distance.
4. Devide your space into zones (like flipped Portals),limit your render.
05/23/2009 (4:36 am)
1. Use Mip levels with textures (DDS for example),that is good for your texel render.2. Use LOD levels for geometry.
3. Use visible distance that discards object's render at great distance.
4. Devide your space into zones (like flipped Portals),limit your render.
#13
Also, swaping all the jpegs for DDSs worked fantastically. Even though the textures are on average only 200kb smaller, it does seem to boost performance. Also things just look better with DDS, superior format by any measure.
Hey Caylo, I tried typing in your command, and it actually did seem to have a noticable effect on the performance. But I only had 3Ds MAX and Photoshop open at the time. I will keep it on hand and let you know. Like I said, I usually have a ton of stuff open.
Thanks!
05/23/2009 (10:01 pm)
So first off, disabling 'recieve sunlight' on all my meshes in-game brought about a pretty dramatic boos in performance. It actually works out better because for some reason the sunlight was making everything looked washed, like the gama was cranked up way to high. I don't really need the shadows anyway, not the objective of my 'game'.Also, swaping all the jpegs for DDSs worked fantastically. Even though the textures are on average only 200kb smaller, it does seem to boost performance. Also things just look better with DDS, superior format by any measure.
Hey Caylo, I tried typing in your command, and it actually did seem to have a noticable effect on the performance. But I only had 3Ds MAX and Photoshop open at the time. I will keep it on hand and let you know. Like I said, I usually have a ton of stuff open.
Thanks!
#14
DirectX textures (DXT or DDS) are kept in their compressed format in memory and passed to the graphics card still in it's compressed format where specialized chips on the graphics card decompress as required.
DXT1 (no alpha channel) typically gets around an 8x compression so your 1024x1024 texture will be around 524k instead of 4mb, DXT5 textures (with an alpha layer) get around a 4x compression ratio so around 1mb in size for 1024x1024
That's why things are noticeably faster with DDS, plus the smaller the textures and fewer you use the more chance you'll already have that textured cached on the Graphics cards RAM (VRAM) and not have to reload from System Ram.
As mentioned by others LOD's are crucial to good performance and being as aggresive as you can with them will really help, not to mention simply not rendering objects that are too far into the distance
05/25/2009 (7:09 am)
@Rick - the benefit with DDS textures isn't with the filesize on your harddrive, when you read in an JPG/PNG extra it is stored uncompressed in memory and usually takes up 4Bytes per pixel (1 byte each for RGBA) so a 1024x1024 texture would use around 4,194,304 bytes (around 4mb).DirectX textures (DXT or DDS) are kept in their compressed format in memory and passed to the graphics card still in it's compressed format where specialized chips on the graphics card decompress as required.
DXT1 (no alpha channel) typically gets around an 8x compression so your 1024x1024 texture will be around 524k instead of 4mb, DXT5 textures (with an alpha layer) get around a 4x compression ratio so around 1mb in size for 1024x1024
That's why things are noticeably faster with DDS, plus the smaller the textures and fewer you use the more chance you'll already have that textured cached on the Graphics cards RAM (VRAM) and not have to reload from System Ram.
As mentioned by others LOD's are crucial to good performance and being as aggresive as you can with them will really help, not to mention simply not rendering objects that are too far into the distance
#15
How can you set the render distance in Torque? Right now the game is basically drawing stuff across the map, and that's not really neccssarry or helpful to me.
Also it would be helpful if someone could point me in the direction of a guide that explains how to set up LODs in Torque, I have quite a few objects that could benifit from it.
Thanks again,
S&G
Rick
05/25/2009 (5:10 pm)
Hmm, I did not know any of that stuff about DDS, thank you kindly for the lesson! It's very useful to keep in mind, also it explains why there was such a dramatic perfomance jump. How can you set the render distance in Torque? Right now the game is basically drawing stuff across the map, and that's not really neccssarry or helpful to me.
Also it would be helpful if someone could point me in the direction of a guide that explains how to set up LODs in Torque, I have quite a few objects that could benifit from it.
Thanks again,
S&G
Rick
Torque Owner Michael Briganti