Hello PERPHeads,
Lately i have been seeing some questions in OOC regarding the net_graph 1 command, including "What does LERP do?".
In this topic i aim to explain what exactly the Net Graph is, what it's components mean and what it's used for. If demand is big for explanation on other Source Engine related matters i'd happily create a explanation for those too!
So here's the net graph in question with a legend of colors:
Source: Valve Developer Community Wiki
In the net graph you can see 5 words, which may be unknown or known to you, here's them explained:
FPS - Frames Per Second
This is a term that returns in every single game engine, and even in some software.
How a game essentially works is that a library, OpenGL or DirectX helps the backend of the game generate a picture, most of the times in 3D. How many of these "pictures" or "frames" are taken per second is your frames per second, this can differ on how many objects need to be "rendered" or "painted" and how powerfull your graphics card is.
IN - Incoming Packets
All networked games work with packets, and these are sent via a protocol, in our case TCP, which means that a handshake has to be made between the server and the client in order for packets to be transferred, other then in UDP, where you can never be exactly sure if a packet ever even arrives. A packet can for example contain a player's X position, when this changes the packet will need to be resend to the client in order for you to see the actual position of the player. If this would not be done on your screen the player would be stuck in the same X position and you would be unable to see him move. Thus incoming packets on your side, this is usually the biggest number.
OUT - Outgoing Packets
This number is always relatively small, as this is only packets that you send out, for example when you press the W button, the +forward command is activated, which will send out a packet to the server, stating that you just moved forward, the server will then broadcast this to all other players to make their screens update that you have just moved. For further explanation on packets read the Incoming Packets section.
PING - Packet Internet Groper
This is basically how long it takes for a packet to travel from you, to the server or from the server to you, this is always expressed in milliseconds. (m/s)
A smaller ping means a message arrives faster, which is better.
LERP - Linear Interpolation
This one is also fairly simple, but I'll go in some depth with this. Basically what this is good for is to make sure that your view on things is not gritty, when for example an entity falls, it's position will change on the server side, and this will be sent to you, now there's a very small delay in between you receiving the message and the server sending it, so what it basically does is decrease the position of the entity in smaller steps, for example instead of from 1 to 10 it will go: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 within steps, in Garry's Mod's scripting case you can even declare how long this should take. Here's an example of how LERP can make a coder's life easier...
A progress bar without LERP:
And here's a progress bar with LERP:
Lerp Syntax: Lerp( number t, number from, number to )
Source: Riekelt & Garry's Mod Wiki
Notice how the line count is much shorter, and the code looks somewhat neater.
I hope this has explained the net graph for you! If you have any questions make sure to drop them bellow!
Lately i have been seeing some questions in OOC regarding the net_graph 1 command, including "What does LERP do?".
In this topic i aim to explain what exactly the Net Graph is, what it's components mean and what it's used for. If demand is big for explanation on other Source Engine related matters i'd happily create a explanation for those too!
So here's the net graph in question with a legend of colors:
Source: Valve Developer Community Wiki
In the net graph you can see 5 words, which may be unknown or known to you, here's them explained:
FPS - Frames Per Second
This is a term that returns in every single game engine, and even in some software.
How a game essentially works is that a library, OpenGL or DirectX helps the backend of the game generate a picture, most of the times in 3D. How many of these "pictures" or "frames" are taken per second is your frames per second, this can differ on how many objects need to be "rendered" or "painted" and how powerfull your graphics card is.
IN - Incoming Packets
All networked games work with packets, and these are sent via a protocol, in our case TCP, which means that a handshake has to be made between the server and the client in order for packets to be transferred, other then in UDP, where you can never be exactly sure if a packet ever even arrives. A packet can for example contain a player's X position, when this changes the packet will need to be resend to the client in order for you to see the actual position of the player. If this would not be done on your screen the player would be stuck in the same X position and you would be unable to see him move. Thus incoming packets on your side, this is usually the biggest number.
OUT - Outgoing Packets
This number is always relatively small, as this is only packets that you send out, for example when you press the W button, the +forward command is activated, which will send out a packet to the server, stating that you just moved forward, the server will then broadcast this to all other players to make their screens update that you have just moved. For further explanation on packets read the Incoming Packets section.
PING - Packet Internet Groper
This is basically how long it takes for a packet to travel from you, to the server or from the server to you, this is always expressed in milliseconds. (m/s)
A smaller ping means a message arrives faster, which is better.
LERP - Linear Interpolation
This one is also fairly simple, but I'll go in some depth with this. Basically what this is good for is to make sure that your view on things is not gritty, when for example an entity falls, it's position will change on the server side, and this will be sent to you, now there's a very small delay in between you receiving the message and the server sending it, so what it basically does is decrease the position of the entity in smaller steps, for example instead of from 1 to 10 it will go: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 within steps, in Garry's Mod's scripting case you can even declare how long this should take. Here's an example of how LERP can make a coder's life easier...
A progress bar without LERP:
And here's a progress bar with LERP:
Lerp Syntax: Lerp( number t, number from, number to )
Source: Riekelt & Garry's Mod Wiki
Notice how the line count is much shorter, and the code looks somewhat neater.
I hope this has explained the net graph for you! If you have any questions make sure to drop them bellow!
Last edited: