122 Commits

Author SHA1 Message Date
Sam Pavlovic
6a20f0bda5 Static Shadows Cache (#5147)
* Simpler light caching

* Simpler cube cache as well, benchmark on RX580 goes from 248ms to 55ms

* Fix logic

* CRenderContext::CopyTexture copies slices for cube in one GPU command

* Do texture copy in a layer so that we handle it all in sequence during scenesystem rendering

* Use Transform Version instead of key, get cache texture only when we actually want it, as cheap for the cpu as it was before

* Only do static caching if our light is static

* Shared cache code for lights (including static cache) instead of duplicating

* Potential fix for pull request finding In the vkCmdCopyImage path, dstOffset.y is set from nDestX instead of nDestY. This will copy to the wrong Y position (and can trigger out-of-bounds clamping/validation errors when nDestX != nDestY).

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-07-30 18:12:46 +00:00
Layla
3691807fe8 Model builder bindings (#5421) 2026-07-27 21:56:08 +01:00
Matt Stevens
b72c5e2ae4 rendersystemvulkan: built-in shaders are offline compiled & embedded spir-v, removing runtime dependency on dxc
# Conflicts:
#	src/rendersystem/rendersystemvulkan.vpc
2026-07-27 16:52:47 +01:00
Layla
7246e48a8b add import scale with unit presets, remember options (#5435) 2026-07-27 10:15:12 +01:00
Matt Stevens
209c921fd3 Add Nvidia DLSS alongside FSR3
Uses vulkan-native NGX integration instead of Streamline.

Also fixes a pre-existing bug where the temporal upscaler wasn't recreated on
display-resolution change.
2026-07-27 01:34:55 -07:00
Layla
c3611421b7 Middle mouse close scene tabs (#5367) 2026-07-21 17:56:46 +01:00
Antoine Pilote
d15dd2096e Support for multi-drawcall LODs in clutter GPU-driven path (#5308)
* Support for multi-drawcall LODs in clutter GPU-driven path

* store arg offset in variable instead of hardcoding it

* use flat draw index

* dotnet format
2026-07-15 09:27:29 -07:00
Layla
a4af9e7702 Unfuck rendering widget (#5362) 2026-07-15 11:41:10 +01:00
Layla
f16409dc4a fix viewport overlay ownership (#5343) 2026-07-14 12:34:05 +01:00
Layla
bf6b842faa fix all tool default dock layouts, add DockManager.SetSplitterProportions (#5341) 2026-07-13 17:07:41 +01:00
Layla
40bb3beb11 fix dock swapchain (#5332) 2026-07-13 09:47:24 +01:00
Matt Stevens
18da35110c Qt Advanced Docking System (#4041)
* Add Qt-Advanced-Docking-System 5.0
* Bind new CDockManager, dock areas
* Use Valve's CSS & images for ADS as a baseline, load stuff from disk instead of embedded in c++
* dockmanager.css in tool styles, auto loads and hotloads
* Rewrite DockManager
* delete toolwindowmanager
* Delete the 50 different ways to create/add/register a dock, you just add a dock, that's all u need
* More dockmanager rejigging
* restore all editor dock layouts and asset browser on the new docking system
* remove last toolwindowmanager remnants, add ADS to third party legal notice
* build classic default layout in code for main editor reset/first-run, add relative area AddDock overload
* relativeTo placement API, restore correct default layouts for all tool windows, register [Dock] types closed instead of eagerly docking
* styling pass
* disable ADS built-in stylesheet load, styling comes from editor stylesheet
* lock picker browser tabs against closing/dragging, make ActionGraph reset layout actually reposition docks
* add DockManager.OpenDock, dedupe layout code in EditorMainWindow/ActionGraph
* CloseDockWidget internal
* add "Close Tabs to the Left/Right" to dock tab context menu
* expose dock MinimumSizeFromContent
* only offer close left/right tab options when open tabs exist on that side
* move "Close Tabs to the Left/Right" out of the ADS lib into a components factory
* guard dock tab context menu against pinned docks with no dock area
* fix crash when pinned tab is destroyed before delayed auto hide timer fires
* recreate scene widget swapchains when Qt recreates their native window on dock reparent
*  wrap all sbox changes to the dock lib in #ifdef SBOX
* save a plain window rect as fallback for when Qt rejects saved geometry on mixed-DPI monitors
* expose DockWidget Float/IsFloating
* always restore window geometry from a plain saved rect instead of Qt's DPI fragile geometry blob
* route all window centering through one screen aware helper that handles mixed DPI monitors
* restore window geometry onto the screen it was saved on
* don't close live docks when a dock type unregisters, hotload substitutes them in place

---------

Co-authored-by: Layla <1667289+aylaylay@users.noreply.github.com>
2026-07-12 12:41:08 +01:00
Garry Newman
b16e2c28b2 Sound import settings: mono, trim, normalize, gain + preview improvements (#5324) 2026-07-11 20:14:31 +01:00
Layla
5f08062cb7 force reload map physics after hammer compile so collision rebuilds (#5315) 2026-07-10 14:48:53 +01:00
Garry Newman
4fd85ce69d Add SkinnedModelRenderer.SpeakSound with baked viseme lipsync; remove dead native code (#5306)
// SkinnedModelRenderer - the only new entry point for speaking
SoundHandle SpeakSound( SoundEvent sound, GameObject mouth = null )
SoundHandle SpeakSound( SoundFile sound, float volume = 1, float pitch = 1, GameObject mouth = null )

// SoundFile - the authored lipsync track, read from the compiled vsnd
VisemeTrack Visemes { get; }   // null = no track (or not loaded yet, see IsValidForPlayback)

// VisemeTrack - visemes over time, authored in the sound editor
IReadOnlyList<VisemeFrame> Frames { get; }
float Duration { get; }
bool Sample( float time, Span<float> weights )

// VisemeFrame - one viseme span (struct: Viseme, StartTime, EndTime)

// Visemes - the standard 15-viseme table, OVR order
static IReadOnlyList<string> MorphNames { get; }
static int Count { get; }

// MorphCollection - the one shared viseme blend (sounds, voice chat, editor preview)
void ApplyVisemes( ReadOnlySpan<float> visemeWeights, float scale = 1, float smoothTime = 0 )

// ModelMorphs - per-model viseme weight table, cached managed-side (no interop on lookups)
float GetVisemeMorph( int viseme, int morph )
float GetVisemeMorph( string viseme, int morph )

// ResourceCompileContext - inject managed data into natively-compiled resources
void WriteBlock( string blockName, ReadOnlySpan<byte> data )   // four-char block names, eg "LIPS"
void WriteBlockJson( string blockName, object obj )
JsonObject ReadMeta()                                          // the asset's .meta, registers a compile dependency
T ReadMeta<T>( string key, T defaultValue = default )

// ResourceLoadContext - read blocks back when the resource loads (Resource.OnLoaded, engine-internal for now)
// public ref struct, only valid during the load callback
bool Exists( string blockName )
ReadOnlySpan<byte> ReadData( string blockName )
string ReadString( string blockName )
T ReadJson<T>( string blockName, T defaultValue = default )
2026-07-09 20:04:02 +01:00
wheatleymf
5c104266b7 Height Coverage for decals (#5163)
- Optional feature for decals that have a valid heightmap texture
- Controllable with "Coverage amount" and "Coverage range", first property is a ParticleFloat which allows animating it based on decal's lifetime
- Only contributes to existing opacity + attenuation mask
- Build shaders

https://files.facepunch.com/wheatleymf/1b2411b1/sbox-dev_eQfK467sN5.mp4
2026-07-09 16:57:34 +02:00
Sam Pavlovic
4bac5ecb58 Fix World drawing over GameOverlay/Viewmodels in Depth Prepass (#5270) 2026-07-07 14:40:04 +02:00
Garry Newman
ca96c2a945 Make Inventory, BaseWeapon, AmmoResource, Screenshake first party (#5245)
https://sbox.game/dev/doc/gameplay/inventory-weapons/

Added

InventoryComponent - a slot based inventory, hotbar or shared bucket slots, with a starting loadout
BaseInventoryItem - base class for inventory items, with hooks to veto switching, holstering and dropping
BaseWeapon - a GMod style base weapon - fire modes, magazines and reserve ammo, reloading, dry fire, ballistics, spread, crosshair and HUD
BaseWeaponModel - view/world model base with muzzle flash, brass ejection, tracers and animation hooks
Ammo types are resources (.ammo) - weapons share reserve pools by type, clamped to a max reserve
BaseWeapon.ShootBullets / ShootBullet - bullet tracing with damage, impulse and hitbox tags
Weapon hold types editor
Animgraph enum parameters can be set by option name - Renderer.Set( "holdtype", "pistol" )
NpcUsage on BaseWeapon - engagement range and burst behaviour so NPCs can use any weapon
ICameraModifier - cameras compose their view through an ordered modifier chain, read the result from CameraComponent.View
CameraEffectSystem - screen shake, directional punches and tilts, with world epicenter falloff - camera.AddShake / AddPunch / AddTilt
EnvShake component - shakes the view, rumbles controllers, kicks physics
TracerEffect - an animated tracer line, ITargetedEffect for effects that fly at a target
SceneAnchor - a world position that can follow an object or bone
SkinnedModelRenderer.GetClosestBone( worldPosition )
Vector3.WithAimCone can take a custom Random for reproducible spread
Improve/Fix

PlayerController searches parents for IPressable when pressing
PlayerController camera runs through the modifier chain - IEvents.PostCameraSetup is obsolete
SoundPlayer preview uses shortcuts - Space toggles playback, Ctrl+Space restarts
Fixed Radius( 0 ) traces missing everything
Fixed NRE in AssetPreviewWidget
Removed

Removed CameraComponent.ISceneCameraSetup (obsolete since October, nothing uses)
2026-07-04 12:46:59 +01:00
Layla
11b9bef734 add drawCount and stride params to indirect draw calls (#5215) 2026-07-02 11:28:28 +01:00
Lorenz Junglas
3a47ca858a Flush Vulkan pipeline cache after SceneLoad (#5231)
Should reduce initial stutter after first time scene load.
2026-07-02 12:19:21 +02:00
Lorenz Junglas
d85b2a794a Improve GPU profiler (#5224) 2026-07-02 07:29:38 +02:00
Antoine Pilote
5cbff413b4 Clutter culling (#5108)
Adds GPU culling
Fixed collision not working for painted instances
LOD is selected on the GPU now

Improvements on our benchmark: 32ms down to 8ms in some cases
2026-07-01 12:22:54 -07:00
Matt Stevens
c8e838d05d Revert "Depth of Field 3 (#5086)"
This reverts commit 27d012d833.
2026-06-24 10:07:19 +01:00
Sam Pavlovic
27d012d833 Depth of Field 3 (#5086)
* Depth of field rewrite with tile classification, indirect dispatches, remove focal range (bullshit)

* Clear Vertical/Diagonal DoF blurs across passes so we dont have artifacts from previous one across tile boundaries

* Dont waste more memory than we need for tiles

* Command list texture clears were being deferred to it's own context, do it on the same context immediately

* Do DoF after viewmodel & AfterViewmodel hook actually runs after viewmodel

* Since we precalculate the DoF max range per tile we dont really need this weird logic for optimization

* Fix shitty 1px line for dof when it intersects geometry
https://files.facepunch.com/sampavlovic/1b1411b1/sbox-dev_3p4zfSfTDx.mp4

* update shaders

* Readd focus range but make it almost as far as FarZ by default

* format

* Adjust tests for new behaviour for DoF, reset buffer data on command list
2026-06-24 05:41:22 +02:00
James King
4d05f33b9b Fix g_flTime in shaders when exporting movie (#5124)
* Use managed Time.Now instead of Plat_FloatTime in CSceneSystem
2026-06-19 18:45:54 +02:00
Layla
ddfca8546c add Collider.ComputePenetration with tests (#5073) 2026-06-14 10:22:48 +01:00
sboxbot
49443fc842 [Particles] Add localspace following bones with ModelEmitter (#5023)
* Particle follow bone
* Add SkinnedModelRenderer.BoneWorldTransforms, PreviousBoneWorldTransforms
* Batch parent space bone reads instead of one call per bone
* Add nogc to the bone setters and parent space read too
* Cache the bone parent array in the world space loop
* Store skinned model renderer on the particle instead of trying to resolve them all, all the time

Co-authored-by: Pol <polepie@gmail.com>
2026-06-13 18:34:37 +01:00
Layla
c8fbe9f51b Terrain editor trace (#5080) 2026-06-13 18:12:30 +01:00
Garry Newman
0e02916f6a Clean InteropGen (#5051) 2026-06-11 10:36:53 +00:00
Sam Pavlovic
a9b392990c Pipeline Texture Slots (#4986)
* Add PipelineTextureSlot to assign a render target's color texture to a stable, pipeline-level bindless slot, being able to be produced and consumed entirely on a GPU stable index

* Compiled shaders

* Clean up

---------

Co-authored-by: Matt Stevens <matt@mattstevens.co.uk>
2026-06-08 15:08:14 +00:00
Matt Stevens
6aaa90fea2 Add Tracy profiler integration (non-public) (#5028)
Adds Tracy 0.13.1 support which is a profiler designed for game engines
that can track both CPU and GPU in frame boundaries at a much higher
resolution than ETW based profilers like Superluminal.

Most of this is restoring VPROF defines in 1000 places, hooking up GPU
zones, memory tracking and more.

This is only enabled on non-public developer builds due to the overhead
in this sort of profiling.

https://files.facepunch.com/matt/1b0811b1/tracy-profiler_P9pUMg6Y8n.png
2026-06-08 14:40:00 +01:00
Layla
58b4e79290 Improve buoyancy (#4919) 2026-06-06 17:20:21 +01:00
Layla
5a40d9eed3 add Mesh.AddSubMesh, render meshes support multiple materials (draw calls) (#4990) 2026-06-03 14:45:53 +01:00
Garry Newman
d27c236689 UI additions and optimizations (#4968)
ADDED
css min(), max() and clamp() for lengths
css-wide keywords inherit, initial, unset, revert (incl. shorthands)
added currentColor keyword to css
colors can parse oklch(), lab() and hwb()
added css text-align: justify
css white-space: pre-wrap and break-spaces
added css word-break: break-word
parses css image-rendering: crisp-edges (point sampling)
added css inset shorthand
now parses 1–4 values in the css border-width shorthand
added css transition-duration, -delay, -property and -timing-function longhands
css :has() now supports descendant selectors
added css opacity percentages
added css overflow: auto (maps to scroll)
added css gap: normal
added css filter: none
css transform: scale() now takes comma-separated args
css animations now accept ms units
added more css justify-content, align-* and text-align keywords (start, end, …)
parses css dvh/svh/lvh/dvw viewport units (treated as vh/vw)
parses css object-fit: scale-down (treated as contain)
added css margin-block / margin-inline (+ the logical margin sides)
added css padding-block / padding-inline (+ the logical padding sides)
added css inset-block / inset-inline (+ the logical inset sides)
added the css flex-flow shorthand
added the css font shorthand
added css font-size keywords (xx-small … xxx-large)
css letter-spacing and word-spacing now accept normal
added css font-smooth: none
css aspect-ratio now accepts the auto form
css font-family now maps generic families (serif, sans-serif, monospace)
added css flex-flow
added css font

FIXED
fixed css !important dropping the whole declaration
css line-height without units is now a multiplier
fixed css calc() division and full-expression parsing
fixed the css flex shorthand for single-number and three-value forms
fixed the css transition shorthand when the property is omitted
css font-family now uses the first family in a comma stack
colors now parse fully in the css background shorthand
an unknown css @-rule no longer drops the whole stylesheet
css variables no longer match on partial tokens
injected css variables are kept across stylesheet hotloads
fixed css selector specificity overflowing when comparing rules
css background: none now resets the background (image and colour)
css filter: none now overrides a filter set by a base class
css transform: none now overrides a transform set by a base class

IMPROVED
css rule matching is ~3–5× faster on large stylesheets (rules indexed by class)
~2× fewer allocations in css transitions (snapshot styles once, not per property)
finished css animations no longer re-layout every frame
less GC in css sibling/child selector queries (no list copies or wrappers)
less GC diffing active css rules (no LINQ or hashsets)
faster, lower-GC Yoga layout wrapper
css stylesheet hotload now watches newly imported files
2026-06-02 19:19:23 +01:00
Sam Pavlovic
377785234b GPU Resource Viewer Iteration (#4959) 2026-06-01 10:16:27 +03:00
Sam Pavlovic
34d1a7017d GPU Resources Viewer (#4750) 2026-05-28 11:31:24 +03:00
Layla
66718ac559 populate model inspector with more useful info about meshes (#4939) 2026-05-27 19:21:33 +01:00
Lorenz Junglas
95a8e59221 Ship steamclient.dll again (#4928)
* Ship steamclient.dll again

* Add workflow that updates binaries every month
2026-05-27 16:52:00 +02:00
Lorenz Junglas
a4da4caa26 Audio System Refactor (#4925)
* Remove some dead native sound code

* Rewrite managed audio system to be lock-free

Use a snapshot triple buffering approach (main thread collect snapshots -> mixingthread processes), similar to how we handle batch drawing (mainthread collects snapshots -> render threads processes)

* Remove/Rework managed steam audio abstraction

* Add just Steam Audio effects, build ourselves via vpc

Compile steamaudio with AVX1
2026-05-26 19:49:54 +02:00
Lorenz Junglas
5862307569 Phsysic query optimizations (#4923)
* Get rid of native physic query allocations

Keep thread local result buffers

* Reduce vtable lookups for physic queries

Virtualizing has a measurable perf penalty here since these callbacks are very hot.
Devirtualize by using CPhysicsShape/CPhysicsBody directly instead.
2026-05-26 19:33:39 +02:00
Matt Stevens
0cc57f66a8 overlay_frame stats: redesign, add batching, culling, etc info, add levels of verbosity
* 3 levels of detail
* redesign with headers and color coding
* added batching + culling info
* added aggregate object info
* added texture pool usage, streaming requests
* added native gpu stats summary string

https://files.facepunch.com/matt/1b2411b1/sbox_nQniekb544.png
2026-05-26 15:32:43 +01:00
Lorenz Junglas
071492c376 Steamworks & steamclient update (#4803)
* Updated SteamWorks to latest remove client binaries

Should also give use latest GameNetworkingSockets which include a bunch of fixes

* Remove remaining unix ffmpeg libraries

* Remove outdated api from bindings

* Add some new API to bindings

* Launch steam with no authentication, if auth fails

Some Steam SDK version seems to have introduced explicit failure when authentication is failing (e.g. steam nor running).
If auth fails we now fallback to no auth (e.g. for local developement, CI).

* Set registry entry to steamcmd install dir
2026-05-26 13:54:11 +02:00
Layla
746753f1ca Mesh to model dialog (#4914) 2026-05-23 18:43:25 +01:00
Layla
24c353d31e Runtime mesh morphs (#4905) 2026-05-23 18:42:15 +01:00
Layla
1d1e73bd30 Refactor physics resource (#4902) 2026-05-23 16:38:28 +01:00
Layla
68c95187bf VmdlWriter also writes PHYS block (#4873) 2026-05-21 00:18:26 +00:00
Layla
dd3edcb7b1 add ResourceWriter.AddExternalReference (#4876) 2026-05-21 00:20:36 +01:00
Antoine Pilote
01c5fc2b2c Clutter LODs for instanced models (#4786)
* add LOD switching for clutter model instances

* DrawModelInstamce with correct LOD level

* removed some useless comments. move stuff around

https://files.facepunch.com/antopilo/1b0711b1/sbox-dev_AcVXDWDDah.mp4

* use biggest scale axis to determine screen coverage for clutter lod level

* clamp LOD in managed

* clamp lod in native

* rename lod Count to maxLodCount
2026-05-19 10:04:55 -07:00
Carson Kompon
67bcdf37af CameraComponent.RenderToBitmap UI drawing fixes (#4448)
- This adds a `CameraComponent.RenderToBitmap(target, renderUI)` overload so you can render out bitmaps from a Camera without the UI (useful for in-game screenshot tools that use the player's camera which already contains a HUD)

https://files.facepunch.com/CarsonKompon/2026/May/19_10-23-WigglyGoldenmantledgroundsquirrel.png

- Fixed an issue where the UI would scale improperly (as seen in the BEFORE image above), so now the UI will scale to the size of the bitmap when choosing to render the UI

https://files.facepunch.com/CarsonKompon/2026/April/01_12-55-PositiveWildebeast.png
2026-05-19 10:24:56 -04:00
James King
99d99e7aff Add GpuBuffer.CopyTo, small rendering API fixes (#4847)
* GpuBuffer.SetData accepts a ReadOnlySpan
* Add RenderTools.CopyGPUBuffer
* Add RenderAttributes.Set(uint) so it doesn't use the float overload
2026-05-19 13:19:17 +01:00