Sandbox Logo
30 September 2022

September 2022

Cloud Assets!!
The Render API had been built over time, and has grown into a weird shape. I've spent a week or two this month cleaning up and refactoring.

It was a static class called Render. That seemed like a good idea at the time. The problem is that Render is a really common word to use as a function to render stuff - and when you do that then you have to namespace or alias the class in, which is pain. So now it's called Graphics.

The new library is a cleaner version of Render with more coherent naming. I've removed all the bullshit and boiled it down to essentials that we can guarantee to work all the time.
I added Render Hooks this month. They're kind of like our old post processing system except they have a few extra benefits:
  • Work on Scene Panels
  • Work on Tool Cameras
  • Work on Icon Rendering
  • Called multiple times during pipeline
I tried to design the render hooks to be as simple as possible while still being powerful. Generally with this stuff you mostly want to blit a material to the screen during a specific time in the pipeline, so I made that easy. You might also want to render a model with a specific shader, so I made that easy. You might even at some point want to create temporary render targets, so I made that easy too.

Above you can see how the render hooks are used in the character creator to create a pixel/noise transition when switching items.

You can read more about Render Hooks here..
I killed the outline effect a while back. Completely removed it. It didn't work so well, it was all hard-coded in c++, it was going to be removed eventually anyway. Everyone on discord was moaning about it. I'd removed something they needed. The lack of render hooks meant they couldn't make their own. I'd fucked it all up.

I didn't want to try to make one in the Post Processing system because it would have only worked in the game window. So that's what lead to me re-writing all the shit above. Sometimes when you open a door you also open ten others.

With the new glow outline effect you can specify the regular color, and also an obscured color, and a line width. It's all coded in c# and shaders, so you have the source, so you can modify as you wish for your uses.

You don't have to use the obscure color. You can set it to transparent to get something a bit more like the old effect.
It works great for now, I didn't want to end up spending a ton of time on it. I'm hoping at some point Sam could get on it and see if he can make it a bit smoother etc.
I moved the shader compiling outside of the game. Previously we'd compile them in process - which worked but it meant that the entire process froze up while it was doing it. Which was not good.

I also tweaked things so that reloading the shaders is a bit more reliable. The engine does have dynamic shader compiling, which compiles just the combos you're using.. which is really useful. Unfortunately it isn't that stable, so I've bypassed all that stuff until we have the stamina to work through it and make it reliable.

Shader compiling is a particular pain point right now due to the huge amount of combos they generate. It's something we really need to think about and experiment with. Why have the shaders got so many combos, are they needed, do modern gpus branch efficiently enough for us to avoid them, do render states need combos. It's all stuff we're going to think about at some point.
Before we had an editor and I knew nothing about Qt we had all of our compile notifications in game. I chucked them in the bin this and made some more useful ones.

One big benefit of these is that if there are errors or something you can make it so clicking on them will show you the log or whatever you want.
Previously you could render your own scenes, but it was a bit of a pain in the ass to do. You'd be calling a function with the camera position, rotation, field of views, znear, zfar, all that shit. Pain.

So I added the SceneCamera class which holds all those things and lets you call a single function to render to a Widget,  or an Image FIle, or a Texture, or the Screen.
This was a missing piece of the puzzle in the engine. It's unlocked a nice unified way to render a scene.. which means that any improvements add benefits in a bunch of different systems instead of just the main game view.
I started exploring making clothing icons. This was the real reason I started unifying the scene rendering and added SceneCamera. There was no good way to do this before.
Not gonna lie, they're kind of fucking shit right now, but the journey was long. We'll find a way to improve the way this stuff looks.
I have completely reworked the glass shader to simplify it some more. It was very annoying to work with before and had some issues with the refraction. This time I did a complete redesign and rework of the glass shader. We now merged all glass shader variants into one super shader and made it extremely intuitive and easy to use! Not only is it easier to use but also looks even better!

We've had basic leaderboard support for a while, as an extension of the PvP ranking system. This lead to it being pretty minimal and unreliable, so now we've got a new system built on top of Steamworks leaderboards.

Steam lets you store a couple hundred bytes of extra data along with scores, so we can use that to hold any extra info an addon creator wants to show in their leaderboards. For example, if I want to show how many levels each player completed on their best run, and how long it took them to do that, I can write a struct like this:
[Leaderboard.Type( "depth" )] public struct DepthScore { [Leaderboard.Field( Title = "Completed Levels", Format = "{0} Levels" )] public int Depth { get; set; } [Leaderboard.Field( Format = @"{0:mm\:ss\.ff}" )] public TimeSpan Time { get; set; } }
Then I can change my addon settings to choose which leaderboards should show up in the main menu, and it'll know which leaderboard types I've created by looking at my code:

You can see there's also support for leaderboards that get periodically re-created, perfect for Daily (or Weekly or Monthly) Challenge modes.

Here's how my custom leaderboard type looks in the main menu:
The basic Steamworks leaderboard system is already live, and custom leaderboard types as shown above should be coming in the next Pain Day.
We're all suckas for a nice bokeh

Since we're revamping the post processing pipeline, I had a nice opportunity to recode how Depth of Field works, the new API makes it a love to work on it.
The code itself is much simpler and the quality of the blur is much much nicer, you can get big bokeh circles without much impact to perfomance, it filters through antialiased edges like hair.

Camera focus is physically accurate now, the closer the focused subject is, the bigger will be the circle.

You can play around with it using the devcam command and pressing tab.
I moved the "standard" post process effects to use RenderHooks. I removed some useless shit and put the rest on the F2 devcam menu (go into devcam and hold tab).
You can use them in your game like this..
Another month of new assets for the Citizen. We've gotten ourselves a bunch of new clothing hair. 
Including...
  • Tight Pony Tail 
  • Sweatpants
  • Sleeveless Jumper
  • Polo Shirt
  • Beanie
  • Hard Cap
  • A bunch of Reskins of previous clothing
  • Police Hat
  • Buttoned Shirt
I've been experimenting with jigglebones this month, trying out some jiggle physics on hair and hat assets, hoping to use these more on assets for the citizen moving forward.  As as this, we've seen developments in the hair asset's quality, pushing for higher quality details on hair. We should see some more hairstyles next month. 

I did a blog last month about how everyone bitches that the sausage men aren't hl2 characters. The team had a few discussions and Dan tried a new wrinkley skin.
And at first I wasn't sure. I kind of hated it. Then after a week I looked at the flat old skins and I hated them. So now we're all in on wrinkley imperfect skin.
Obviously we need different levels of imperfect, but even the least imperfect should have imperfections.

I really love this direction, the further away from the clean and trendy metaverse characters the better.
ModelDoc now has a new node called MorphFrame. It gives you an editor to create a morph pose which then gets compiled to a single frame animation, ready to be used in AnimGraph.
Before this, we would have to create morph poses in an external application and import them in. Now we can just create them directly in our tools.
AnimGraphs had a node called DirectPlayback which allows you to manually play a sequence but we had no way to set it. You can now control this node in code.
The advantage of using the direct playback node over just playing a sequence is that the sequence gets blended with the rest of the graph.
One of our development dreams is that instead of installing asset packs when creating stuff, you can select from a library of uploaded assets. Not so much an asset store, but more like a huge unlimited filesystem of stuff that other people have uploaded.

That came a bit closer this month as we enabled accessing models from asset.party. You can browse cloud models in the asset browser like everything else. You can even open them in modeldoc to take a look.
So check that video out. What's happening there is I'm purposely opening models that I haven't previously downloaded so you can get an idea of how it doesn't really matter that they're on the internet. 

So when I double click on them it's downloading the actual model and then opening it in modeldoc. How awesome is that shit?

There is a LOT we need to do here to make it truly work. Discoverability, ordering, sorting, categorization, ratings, moderation. These are probably going to be the hardest things to get right with this system, but we'll work through all that shit.

I've spent the month getting cloud assets into Hammer and it all works great. You can drag models from asset party right into the map. You can even open the browser and drag straight from the website into the map!

The assets that the map uses are saved with the map file, which means that when you save the map and return to it in 6 months, opening the map in Hammer will automatically grab all that stuff so it'll continue to work.

We're going to be looking at getting other asset types in over the next few months. Things like materials, prefabs and sounds are what we have in mind.
Cloud assets was one of our unknowns, one of the tent-poles on the todo list that we wasn't sure would work out. This month we got it working and even with the tiny bit of content can already see the huge potential. We'll spend the next couple of months refining, exploring and improving this stuff.

You have no idea how happy the Graphics/RenderHook system makes me. So clean and easy to use. It was so fun to write, I learned so much about Source 2's View/Scene/Render system. I love that feeling where something seems so huge and complex then you grok the shit out of it and then it seems so simple and malleable.

I could not be happier with our progress this month, it all feels like a huge jump forward, unlocking seven more possible jumps. I am loving my job right now! ❤️