Sandbox Logo
01 June 2022

May 2022

Sound stuff, tool stuff, shader stuff
I spent a week doing a refactor of a bunch of stuff. If you like that nerd stuff you can read about it here.

The general reason was that now we have tools in c# there are a lot of things that needed re-organising to allow more synergy.

Another thing we started to do was move the first person shooter stuff out of the base addon. I don't think our base engine should be providing that stuff. We should be trying to make the engine genre agnostic.

This worked out pretty good, and I was happy to see that the engine version stuff I built a while ago kicked in and hid all the incompatible addons until they were updated.
We're exploring ways to present the citizen's clothing items in a nicer way. I made a mannequin model for Rust which worked out pretty good - so I thought I'd try the same for s&box.
I made this tool a while back and never mentioned it. In the old days we had a bunch of stuff that recorded startup times. Slow startup times are one of my pet hates, so I'm keen to keep an eye on that stuff. Probably because I start the game 300 times a day.

So with this, in tool mode, we can selectively pick sections of code to time. It's not like a Unity profile or anything, it's more for longer running actions, or transitional phases. Like start-up times, or map loads.. anything you wonder why it's taking so long.
It always felt awkward that we depended so much on Valve's internal shading code to compile shaders, you'd have broken intellisense, would have to rely on private, undocumented methods, wasn't a fun time.

This month I've rewrote all the base surface shading code from scratch for addon shaders, this makes shader authoring much more straightforward, it uses the support for classes and inheritance on VFX that we talked about last month.

Shaders that use our previous Material API should be backwards compatible with it, it'll use StandarMaterialShading which works the same as the previous Valve-based shading, and should compile much faster too! 

If you want to make your own you just have to inherit and obey the simple ShadingModel contract and our internals deal with the rest. 
As an example on how to use it in various ways, I've added a simple Toon shader to show how to expand and create your own shading model without basing it on the Standard Surface Shading. 
In the future the plan is to unify and replace Standard and Complex using this new shading model base.
We now have a convar to debug light probe volumes.

This is a feature some people were asking for after seeing them in Deskjob so we replicated it and found it to be useful for us too.

Our goal is to have all entities in C# so I recreated all of the constraints and removed the bullshit ones.



You can preview what a sound will sound like now using this little tool at the bottom of the sound editor. I really just made this to test while I was developing but it ended up being really useful.

I'm  hoping it'll be even more useful in the future when we make it so sounds can differ based on distance etc.
This month I focused on a new gamemode called Strafe, a skill-based movement game that times you how long it takes to reach the end of a map.  With the help of Layla we've weeded out an edge case in physics trace results giving inconsistent or unexpected results.  In Strafe this issue was causing players to abruptly lose all their speed.


I've left a Strafe dedicated server running for a few days, the only instability so far has been from my own broken code causing it to shut itself down.  It makes me happy to see that servers can stay up hosting players and changing to new maps from time to time without issue.
I added a way to enable DSP effects. They're probably less needed now we have Steam Audio working to make shit echoey as fuck, but they're still useful for some other stuff. Like making everything all muffley when you're underwater, or deafening you when a grenade goes off by your head.

We don't have a way to define new effets yet, but there are a ton already defined by default. Here's how to make it sound like you're underwater.
Audio.SetEffect( "underwater", 1 );
You can make them automatically fade out too.. which is useful for things like the flashbang effect.

Audio.SetEffect( "flashbang", strength, velocity: 20.0f, fadeOut: 4.0f * strength );


We previously had an inspector that was written in c++ and used Valve's built in FGD property sheet stuff. This has been deleted now, and double clicking a c# defined resource will open the C# inspector in a window.


We were previously using UI panels for all HUD drawing. It doesn't always make sense to draw stuff like this using CSS.. crosshairs are a good example of that. So now you can draw straight to the screen.
There's a few primitives available, lines, rects, circles, rings.. but I stopped short because I want to draw these shapes using specialized shaders.. that way we can build in antialiasing and shaping. 

But before that happens I want to make the shaders an asset like everything else.. so we'll use these as stop gaps for now.

This month I've spent the time rewriting how steam audio is integrated within the engine & updated it to the latest version. This makes baking steam audio significantly faster, opens up real-time options and better integration of sound within the environment

Video settings have been cleaned up more and migrated to our own video settings manager. MSAA was also added to be customizable too. We're still planning to extend and make changes to this over the coming months
Placing a rope particle system inside a length (rope) constraint entity In Hammer is lame, and makes adjusting the rope later more difficult than it needs to be, so I added an option to spawn the rope particle to the length constraint directly.
Something that was a leftover from Source's quake roots is light "styles", which allowed each light to change its brightness based on a string pattern. 

It isn't 1998 anymore, so I removed that old system and replaced it with a simple curve editor. The new system also has more finer control over looping of the animation, so you can do fancy turn on effects.

We worked at some clothes to test the technical limits this month. We wanted to test things like overlaying, transparency and following the morphs of the face.

The tattoos, stubble and makeup here all follow the morphs of the main face, so they don't look weird. The hair fades to the head smoothly instead of being alpha clipped like our other hair styles.
Right clicking a folder in the asset browser now gives you the choice to create custom assets..
The quality and performance of VR rendering have been bad for quite a while. I've spent the month improving a lot of major and minor things with VR.

render resolution


Render resolution was tied directly to window resolution (1080p by default), considering most headsets render at 1440p or higher this made the game always look like blurry shit, so now it uses what SteamVR tells it to properly.

auto-fidelity


I've fixed and tweaked the auto fidelity system from Half Life Alyx to work better for us in s&box.

It makes a lot of sense for the experience s&box provides, where maps / games can go from simple to highly demanding - in VR you always want to maintain a constant FPS so auto-fidelity will adjust the render resolution automatically rather then you needing to fuck with your settings constantly.

Oculus Positional Timewarp


I've also improved how we work with Oculus by submitting the depth buffer to the VR compositor it significantly improves their positional timewarp making dropped frames much less sickness-inducing.

More performance


There's still a lot of performance left on the table, we're not quite hitting good enough frame rates for a stable VR experience yet.

I was hoping to get stereo instancing in this month, but I'm dependent on our transform system being moved to structured buffers. That should give us a shit load more FPS though.

I've added a simple API to provide haptic feedback to each hand, you can adjust the duration, frequency, and intensity. Generally, you'll want to be calling this in Simulate in response to actions like the player picking something up or shooting.
Input.VR.LeftHand.TriggerHapticVibration( 0.25f, 100.0f, 1.0f )

I've replicated the tiling support from Dota 2 Hammer's fast texturing tool that people were asking for, this should work more or less the same way.
We couldn't pose ragdolls in hammer and spawn them in game as physically simulated entities in that pose, now we can.

I added a toggleable fullscreen layout ( Shift + Alt + Z ) to Hammer.
Useful for getting a fuller picture of what your map will look like in-game.
Right clicking an image file will give you the option to create a material based on it. It'll try its best to fill in all the texture fields based on what it can find.
A similar thing happens when right clicking on sound files.
We got a good way towards having audio mostly sorted this month, but I can already see it's going to take the rest of next month up too. I'm really eager to get a curve property working. It should open up a lot of dynamics when it comes to sounds and other similar resources.. and is so much more intuitive to use rather than defining mins and maxes. 

There was some talk on Twitter about whether we should let people release their games independently of s&box. I think it's a great idea and it's something we should work out. The hardest part would be getting Valve's blessing.. because our license isn't gonna cover this.. but apart from that I can't see any good reason not to do it.

Much love ❤️