Difference between revisions of "Demo"

From P2SR Wiki

Line 73: Line 73:
 
===Software needed for frameblending===
 
===Software needed for frameblending===
 
* [https://github.com/jonese1234/srcdemo2/releases SrcDemo²]
 
* [https://github.com/jonese1234/srcdemo2/releases SrcDemo²]
* [https://github.com/dokan-dev/dokany/releases/tag/v0.7.4 Dokan] (needed library for SrcDemo²)
+
* [https://github.com/dokan-dev/dokany/releases/tag/v0.7.4 Dokan 0.7.4] (needed library for SrcDemo²)
* (Optional) [https://download.oracle.com/otn-pub/java/jdk/15.0.2%2B7/0d1cfde4252546c6931946de8db48ee2/jdk-15.0.2_windows-x64_bin.exe Java Server JVM] for better performance
+
* [https://www.microsoft.com/en-us/download/details.aspx?id=40784 VCRedist 2013]
 
+
* (Optional) [https://download.oracle.com/otn-pub/java/jdk/15.0.2%2https://www.google.com/intl/en/policies/terms/B7/0d1cfde4252546c6931946de8db48ee2/jdk-15.0.2_windows-x64_bin.exe Java Server JVM] for better performance
  
 
===Setup===
 
===Setup===

Revision as of 18:41, 31 January 2021

Demos


Overview

1280px-Source engine logo and wordmark.svg.png

Demo files are used in Portal 2 as a form of proof for runs, and a way to carefully analyze a segment of the game.

For More information on the .dem file format visit the Valve Developer Wiki

How to Record a Demo

In the developer console, type record demoname, where demoname is the name of your desired demo file.

The demo files are stored by default in your portal2 folder (SteamLibrary\steamapps\common\Portal 2\portal2)

Demo Playback

Demos can be played back in game for viewing, or for external recording with playdemo demoname where demoname is the name of the demo file you recorded to. Use stopdemo to stop demo playback. startdemos plays a sequence of demos (for example: demo, demo_1, demo_2, etc).

SAR has and improved version of the startdemos commands for demo viewing.

  • sar_startdemos
  • sar_stopdemos - Stops the demo queue.

You can use the command demoui for more options while watching demos, or you can use shift + F2.

Stopping Demo Recording For Single Player Challenge Mode

If a demo recording is not stopped in Single Player Challange Mode, the timer will become inaccurate up to .4 seconds. Meaning when you carry over demo recordings, your times in single player cm could be .4 slower than they would have otherwise been. This does not impact coop Challenge Mode.

To stop demos, simply use the stop command. This can be bound to your restart level key. bind key "stop;restart_level". The reload command will also stop demo records, and restart your level in Single Player Challenge Mode, however it is worth noting that the command will load from a save point in full game, and not work at all for coop Challenge mode.

Saving Demos to a Subfolder

You can save demos to a subfolder by naming the file with a pre-existing folder name, followed by a backslash, and the demo name.

  • NOTE: If the folder does not exist, Portal 2 will not create a folder for you and your demos will not be recorded.

(Ex: record foldername\demoname)

Easy Recording Methods

If you aren't using SAR to handle demo recording, the most common way to record demos easily in Challenge Mode is to bind it to your w key along with +forward. For example, bind w "+forward;record demo"

Challenge Mode

Challenge Mode Demo Tutorial

SAR Demo Recording Tools

SAR has many useful features for demo recording. Particularly during full game runs. These features are mention on the jerrypedia page for SAR.

Blenderiste09's fork of SAR (linked on the SAR Jerrypedia page) includes the commands

  • sar_record_at_demo_name
  • sar_record_at (default value 0)
  • sar_record_at_increment (default value 0)
Note: sar_record_at does not work for the orange bot in coop.

sar_record_at_demo_name takes a value for the name of the demo the functions will record. Example: sar_record_at_demo_name demoname.

sar_record_at has a default of 0, which will not record a demo, but any value higher is the number of ticks in game that will go by before a record starts. For example, to start on the second in-game tick: sar_record_at 2.

Note: If you pause the game with the esc key on the frame that the demo is set to record, the recording will not be processed. Preforming a console pause (pausing by opening the console with ~, the pause will not interrupt the recording.

sar_record_at_increment will add a number after your demoname (Example: demoname_2) if set to 1. This acts as version control, to avoid overriding demos you might have wanted to revisit, but does stack up new demos until the game is restarted, so if you use this feature, it's a good idea to periodically delete demos.

Demo Rendering

gaming's guide on demo rendering

Frameblending

Software needed for frameblending

Setup

Folders

  • Make 2 folders in the Portal 2 folder, one for the raw frames and one for the blended frames and then set the paths for them in SrcDemo².

Binds

  • Start Render bind: startmovie <renderpath>; demo_resume (replace <renderpath> with the path to the raw frames folder you made)
Important: In the render bind you need to name the images aswell.
  • Optional "tick 1" bind: sv_alternateticks 0; demo_pauseatservertick 1; demo_resume

Settings

Good settings for SrcDemo²

This is what the settings from above should look like. Video by Swagatron, rendered by gaming

Video output

  • PNG is a lossless, compressed image format. Good for losslessness while keeping disk usage minimal.
  • TGA is a lossless, compressed image format. Good if the disk is very fast but the CPU isn't.
  • JPEG is a lossy, compressed image format. Good if running low on disk space.
Recommended: PNG.

Final video FPS

The amount of frames per second you want your video to have.

Recommended: 60 frames per second.

Motion blur blend rate

The amount of frames you want to be blended into one frame.

Recommended: 32 frames per frame for 360 simulated shutter angle.
             16 frames per frame for 180 simulated shutter angle.

Simulated shutter angle

The simulated shutter angle of each frame. Now you may ask, what is shutter angle? Well, here's a striking example of how important getting the right shutter angle is. This is the same scene, recorded at multiple shutter angles.

Windflowershutterangle.png


This is a camera with a 180° shutter angle:

Shutterangleanimation.gif

As you can see, each physical frame of the film is exposed to photons 50% of the time. For a 30 frames per second video, a new physical frame is made every 1/30th of a second. However, since it is only exposed 50% of the time, only 1/60th of a second's worth of exposure has gone onto the frame. The other 1/60th of a second is simply gone, not recorded. As you can imagine, a higher shutter angle means a longer exposure time. For example, a 270° shutter angle, the frame would get 3/120th of a second's worth of exposure, and 1/120th of a second would be gone. With a 360° shutter angle, the frame will get the full 1/30th worth of exposure, and nothing will be lost.

Recommended: 360° shutter angle for higher amount of blended frames.
             180° shutter angle for lower amount of blended frames.

Use gaussian blending

Use gaussian blending method instead of linear blending method. Examples down below. The image on the left is an example of Linear blending and the image on the right is an example of Gaussian blending.

Regular-blend-reference.png Gaussian-blend-reference.png

Recommended: Have it disabled, use Linear Blending.


Frameblending the demo

Set host_framerate to whatever number SrcDemo² displays and press "Activate". Play your demo, go to tick 0 and pause. Then you need to get on tick 1 by inputting these commands:

  • sv_alternateticks 0
  • demo_pauseonservertick 1
  • demo_resume
Note: I recommend binding these 3 commands to a key for ease. See the bind above.

Now you have to set sv_alternateticks back to 1.

Note: Don't bind this 4th command in the same bind as the other 3.

If you did this part correctly, when you open demoui (open by pressing Shift+F2 or by typing demoui in console), it should show that you are on tick 1. Now press your start render bind and wait until it finishes. Once it finishes type endmovie in console. Now just put all the frames together in some editing program.