Jump to content

PAC - "How do I make my shit efficient?"


Jun Nagase

Recommended Posts

First I'd like to address some of the rumors that have been going around with PAC.

 

No matter what you say, you will never convince me that 16mb for a PAC is a lot. Maybe in 2010 it'd be considered a lot for a head and hair model but that's just shy of a decade ago.

 

And it isn't as if the -amount- of shit we download directly connects to the number of frames we lose. How can I say this?

Rendertime. You've probably heard this before. This is PAC calculating how much time it takes for someones PAC to render fully. It's directly tied to how much strain it puts on your own computer to render the PAC, and thus tied to how many frames you will lose by having it rendered.

This will vary from person to person. It seems inconsistent too; some have great PC specs but still lose a lot of frames, some lose a lot less with similar specs. It's Garry's Mod, a strange amalgamation of god knows how many different things that the Source engine was never supposed to do in the first place. It will never be consistent. I say this as someone who got GMod when it was called Garry's Mod 9 and was still a free mod that required you to own HL2 to play.

The number of things that go into determining what your FPS experience is is incalculable. Sure there's obvious pointers like "don't run shit in the background" and "less addons = less lag and loadtime" and "less pac = less FPS loss"

And that's all true, but that is a lot like saying less weight on a car will make it more fuel efficient. Yes it will, but it doesn't tackle it where it matters; the engine. Sadly said engine isn't something we can really tweak with garry's mod.

You will never see a scenario where everyone has the same FPS unless that FPS is 0 (because someone crashed the server).

 

And secondly, model imports.

There are two types of model imports; .obj (or old) and .mdl (or new)

 

.obj is an old PAC3 importing method. It's a lot simpler and faster to do than .mdl however it has an exponentially increased rendertime impact. These used to be the only way, since we did not always have PAC4 and I did not always know how to import into gmod (and thus create .mdl imports), so many people still use .obj imports and they are likely the largest factor when it comes to FPS loss from imported models.

FPS loss comes from more than just models. The materials used play part, the events play part, the general complexity plays large part. Not just models.

 

.mdl import is the new fancy PAC4 method of importing a model. It basically loads a model same way as it loads any other model in gmod. All models you see in gmod are .mdls, it's what the source engine was built to render and it's the by far most efficient. You take a .obj import head with ~1.2ms rendertime (on my PC) and convert it to a .mdl import and it can drop to ~0.2-0.3ms rendertime.

These imports are just as efficient in their rendering as any other model in garry's mod. You know why? Because they are the exact same type of model as every other model in garry's mod.

The only difference is it's loaded through PAC, but they are no different than if you chose to put an existing model on your PAC rather than an imported model when it comes to rendertime impact.

 

 

 

First I will address the models since these are what I have the most personal experience with. Later I will add things like efficient structure and removing redundant parts of a PAC (don't have several heads in one and just hide the ones you don't need).

563e5d0df0d41fde1f932a905e5f23f9.png

This is a cutout of a head import that I took from 20MB to 7MB. As you can see, the largest file here is 1.5MB from the .vvd (which I dont' know how to make more efficient)

The largest texture file is 1.4MB, on par with the uniform textures used in our current 2.0 Mobile Infantry uniforms pack loaded on the server.

Now, most of you may see these and think "Okay well, what does all of these things mean? Why is this there and that necessary? Can't you cut there that and this?"

Allow me to explain.

 

Detail_ textures:

These textures, such as the detail_skin2.vtf are textures that are used to emulate a higher resolution texture than it actually is. Take the head.vtf, the head's texture file, then add the detail_ texture to it and it applies a small scale version of the detail_ texture ontop of the head.vtf texture which means you see what looks like little skin details without the need for 2048x2048 textures.

They add a lot of detail (hence their name) to a texture, allowing you to compress the original texture more and reduce overall file sizes.

 

_n textures:

These textures, such as the Eyes_N.vtf, are normalmaps. They basically direct how lighting affects the model, creating an illusion of depth and detail where none exists.

normal_mapping_compare.png

In the case of the eyes, "why do you need a texture for the eyes?"

Well as it happens, without one applied your eyes wont shine. Eyes are wet (hopefully yours are, otherwise go see a doctor), and wet things shine.

5C84991E8DC5906AEFDEE4BB931249855EEC4DB5

As you can see, the eyes have that white shine on them. Without that, it looks awfully weird when you look around. You tend to notice the lack of a shine.

 

vtf and vmt:

VTF are the actual textures themselves.  VMT directs the model to which textures to use, so in the VMT it says the primary texture is the head.vtf, and it says the bumpmap (aka normalmap) is the head_n.vtf etc.

 

 

 

Okay, so how much quality does one lose from optimizing a model import?

Well, take a gander at the two heads above again. One is 20mb, the other is 7mb. Can you tell which?

Probably not. Maybe if you look closely at the eye shine.

The left one is the old 20mb uncompressed version, and on the right is a 7mb compressed version (the same from the first image I posted)

As you can tell, you obviously don't lose a lot of detail, and any that you do lose is next to impossible to tell. And I can all but certainly compress it further to ~5 - 5.5MB.

With use of detail_ textures (which you can tell are small) and normalmaps, you can reduce the diffuse texture size a lot (diffuse being the face.vtf texture itself).

 

In this case I opened the head.vtf file, exported it with the 'vtfedit' program, then opened the exported .jpg in paint.net, resized it to 1024x1024 (you'll never need higher, you'd be fine with 512x512 too) and exported it as a .jpg again (ctrl + shift + S) and when prompted I set the quality to 99% rather than 100% (which also wont show). This reduced the filesize from ~5MB to the 1.366MB you see above.

Very simple and easy to do, if not a bit INCONVENIENT to do for several textures.

 

Okay so, what can -I- do to help my own FPS?

Well, PAC has a lot of nifty settings for you to mess with in Q Menu > Utilities > PAC

You can turn it off entirely, which I personally tend to do on larger drops where I kinda need the frames.

Or, you can set a max render range so PACs X distance away wont render.

Or, you can set the max rendertime so anything that strains your PC more than X .ms will not be rendered, effectively hiding the PACs that impact the most.

Or, you can disable specific pieces of a PAC, like urlobj which is the old .obj model imports that have such a heavy rendertime impact.

You can also set it so PACs outside your field of view wont render.

Or if you really want to, you can blacklist OR whitelist (meaning ONLY certain people's PACs YOU choose will render, rather than having to choose whose NOT to render).

 

And in general, what can I do to reduce my rendertime?

Well, less is -always- better. There's no beating around the bush with that, less is always less.

However, going through your PAC and reducing redundant pieces will help too. Animations you don't use, pieces you don't really need like aviators or 5 pouches etc.

And of course as mentioned above, compress your textures. You can download any model you're using by putting the model link into your browser instead which lets you download the model. Open it up and fiddle with it yourself. Smaller textures have less rendertime.

 

And if you get into importing models yourself, cut out redundant parts of it like the mouth (which I neglected to do on the model above). Less is better, even if it's just a little. A lot of little adds up to a lot.

 

Edit:

Oh shit I forgot, open console and write "gmod_mcore_test 1" that will also help with FPS in a good number of cases. Do it before you join server ideally

 

If anyone has questions or comments or concerns, feel free to poke me on discord and I'll happily help out or have a chat.

Link to comment

Also as for rendertimes?

Here's an example of how your rendertime should look like.

D53BD03920A3BF85FA11B7DD26B03D172D74C2CC

Here's a simple headhack with head + hair models (the 7MB one from before and uncompressed 20.8MB hair, havent' gotten around to the hair yet)

"0.729ms? that's a lot!"

 

 

 

Well, let's take off a few things since I did this in SP and not the server.

FAD25CED3F53A231F23B9F19640B9E46B3424CAC

0.044ms from just existing

 

5959CDAA6873F63BAEF4CE229984B440D9AD230A

0.447ms from the MI model (which you wouldn't have to put on yourself on the server because y'know, it's your playermodel.)

 

So, head w/ hair and helmet and a few things to hide the neck comes at around 0.238ms rendertime.

I've seen much much higher on PACs that don't even use any imported models.

Again, it aint about the model imports, it's about all your shit.

ALL OF IT.

  • Useful 1
Link to comment
×
×
  • Create New...