Update 26.07.15

This week's update brings major terrain performance improvements, talking NPCs with lip-sync & subtitles, editor gets a docking system overhaul and a ton of mapping tooling. Plus our usual stream of performance improvements and bug fixes.

Talking NPCsby garry

Adds subtitles and lip sync to sound files. This is kind of how HL2 did it, except better.
image.png 666.33 KB
621345368-ae7553b5-4aea-406e-92b4-5206dba3319a.mp4 13.65 MB

Sound Import Settingsby garry

image.png 41.6 KB
Adds import-time processing options to sound compiles, driven from the sound's .meta and applied by the native sound compiler:
  • Force Mono — averages all channels down to one
  • Trim Silence — strips leading/trailing samples below a threshold
  • Normalize Loudness — surfaces the existing (previously unexposed) LUFS normalization, targeting -16 LUFS
  • Gain (dB) — fixed volume adjustment, ±24dB
All are no-ops unless set, so existing content compiles byte-identical. Loop points are resolved after trimming so they land on the timeline the user authors against in the sound editor. Changing a setting saves the .meta and force-recompiles the asset (raw vsnds aren't in the game-resource auto-compile path), debounced so slider drags and multi-select edits produce one compile per asset instead of a stale-compile storm.

Height Coverage Masking for Decalsby wheatleymf

image.png 4.62 MB
Height Coverage is a new feature for decals that allows using heightmap as an additional visibility mask. It will be available for use as long as your decal has a valid heightmap texture assigned to it. It it controlled by two properties in the decal component:
  • Coverage Amount: generates a height range mask based on current amount, where 1 is fully visible, and 0 is invisible.
    • This setting has a ParticleFloat type, which means that you can take advantage of decal's lifetime settings and use this not only for static effects, but also for animations.
  • Coverage Range: adjusts the smoothness of mask edges, where 0 will be sharp, and 0.5 is smooth. 
This is how it looks in action:
sbox-dev_l7OrlhfY9J.mp4 8.09 MB
Keep noted that it works as an additional mask, meaning that it will be applied on top of opacity/attenuation masks on your decal if you have them. While this mask is fully compatible with parallax, it is not necessary to use it all. 

For custom shader enthusiasts, I have also updated the documentation for Decals class, and provided new information about reading height coverage settings from byte buffer, decoding them, and applying them. 

Terrain Cullingby antopilo

Our terrain clip maps implementation was basic and prevented us from doing more advanced optimization techniques. This week, I went over almost every aspect of our terrain solution so that we can make it faster.

The mesh is now split into more granular chunks that we can test against the camera to perform culling. In most cases, the player is in the middle of the terrain where at least 70% of the terrain isn't in camera view. By discarding all of those chunks, we can get some nice performance improvements.
sbox-dev_Ms53Lyuavr.mp4 3.34 MB

This allows you to push more detail where it matters, in the camera view. The culling is more aggressive in the video to showcase the culling.
sbox-dev_ysnrDfAkxi.mp4 32.72 MB

Terrain Shading Optimizationsby antopilo


Our other big bottleneck was the sheer number of texture fetches.

We added a precompute pass so we can bake data ahead of time instead of recalculating it every frame while shading.  We moved to GatherRed where we were sampling neighboring texels and depth passes now do almost 0 work.

In the best case we went from 24 texture taps down to 1, and our benchmark rendering time was halved.
image.png 48.39 KB

We've also fixed some discrepancies in our height blending. Rocks pocking through grass should now behave accordingly instead of fading.
sbox-dev_W1FxOpA7Ua.mp4 5.54 MB

Serious Engine Mountby Layla

Serious Engine joins the list of mountable games (purchased and installed), you can play maps and spawn props & characters from games made in this engine.
616870146-08cf015b-d5ee-4bb9-9b0f-b9e6f38e334d.mp4 24.34 MB

First-Person Demosby ziks

Demo recording now properly supports first-person views by capturing properties like render tags and the Absolute flag. Additionally, we fixed a recording bug that could slightly misalign the values captured to separate tracks, leading to view models appearing to vibrate.
sbox-dev_hg2v4Kiix2.mp4 2.3 MB

Movie Keyframe Improvementsby ziks

Thanks to your feedback, we've got a batch of fixes and quality of life improvements for Movie Maker's keyframe editing mode. This includes fixing the last keyframe sometimes being skipped in compiled movies, saving the selected interpolation mode as a cookie, and adding a way to change the values of multiple keyframes in the context menu.
sbox-dev_1DgWch6iVF.mp4 699.44 KB

Advanced Docking Systemby matt

In the editor we have docks, Qt has these built in but they suck, so we used toolwindowmanager, this wasn't bad but had a lot of flaws - now we're using Qt Advanced Docking.

Overall this gives us a much more complete and polished IDE-style docking system which should be much more stable, without us needing to patch the docking system ourselves.

ADS gives us a more capable base for features such as:
  • Central widgets
  • Pinning and auto-hide 
  • Focus highlighting 
  • Richer tab menus
  • Closing groups of tabs
  • Floating dock groups
  • Better dock locking
  • Minimum-size handling
  • More consistent layout state
  • Future platform-specific fixes
Additionally the API is much simpler for creating and adding your own docks where code used to be duplicated with DockManager.RegisterDockType, that method is now gone.

Central Scene Widgetby Layla

For a very long time I've wanted to make tools that use a central widget with docks around it, with the advanced docking system we can now do that. The main scene editor already makes use of it so we don't need a dock per scene session.
image.png 1.19 MB
This saves our asses in a bunch of ways where you could close your scene dock and fuck your whole layout. And if you're mad you can't dock your scene inside your asset browser anymore, too bad.

Mapping Vertex Paint Improvmentsby bakscratch

Vertex Painting in the mapping tools was lacking some features, so I worked through a list of stuff I wanted and the community wanted.

This includes;

Flood FIll
sbox-dev_2H5XCw1vet.mp4 2.24 MB
Flood Fill - Noise
sbox-dev_5fiG1UPoF8.mp4 2.67 MB
Flood Fill - Occlusion
sbox-dev_svYoavyVha.mp4 5.01 MB
Flood Fill - Curvature
sbox-dev_cMr5IKvZ3s.mp4 5.24 MB
As well as supporting Invert and Clear Paint data.

Also some quick nice time savers too;

Improve Colour Lift
sbox-dev_iYop9v2JJs.mp4 5.07 MB
Quick Colour Pick
sbox-dev_mS0gEV17RR.mp4 5.04 MB
Scale Brush Distance
sbox-dev_QhYCMfWcfR.mp4 5.41 MB

Taskbar Jump Listby garry

Added this back, if you pin s&box editor to your task bar you can launch projects quickly with this.
image.png 153.85 KB

Performance metrics blunderby Lorenz

I'm going to bore you with some statistics. We recently started wondering why our individual frame stage timings showed a steady decline over the past months, while our global average frame time stayed relatively stable.


It takes no mathematician to see that something about our metrics tracking was fucked until last week:
image.png 398.26 KB

Two issues:

1. We were aggregating the data wrong. We used:
FrameTimeAvg = (FrameTimeAvg + FrameTimeNew) / 2.0f
This skews the average heavily toward the most recent timing. For example, say a thousand frames at 16ms have already been aggregated, then a single 100ms frame arrives. The average would jump to 58ms.
To fix this, we now use Welford's algorithm for an accurate rolling average.

2. We included idle time in our global frame time:
Idle time is the time the game spends sleeping between frames when a frame limit is set. That means a client locked at 60 FPS would always report 16.6ms, even when the actual work per frame is much lower. We now track idle time separately, so we can monitor the real time spent computing a frame.

image.png 211.09 KB
As you can see in the graph, idle takes up a significant chunk of the overall frame time, since most clients run with a fps limit.

TL;DR We've been chipping away at performance in recent months, but improvements weren't really visible in all our metrics. We improvedo the metric tracking and will keep chipping away.