49 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
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
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
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
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
Layla
58b4e79290 Improve buoyancy (#4919) 2026-06-06 17:20:21 +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
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
Layla
1d1e73bd30 Refactor physics resource (#4902) 2026-05-23 16:38:28 +01:00
Layla
dd3edcb7b1 add ResourceWriter.AddExternalReference (#4876) 2026-05-21 00:20:36 +01:00
Layla
1c59d2261c revert unstable box3d update 7 and 8 (#4840) 2026-05-15 09:35:11 +01:00
Layla
4ad92bebbe Box3d update 8 (#4834) 2026-05-13 16:31:18 +01:00
Layla
9e8afe731a move these few stubborn required files over to engine2 so I don't have to see entity2 project anymore (#4813) 2026-05-10 21:34:49 +01:00
Layla
17092f585b add Rigidbody.SleepThreshold as an advanced property (#4812) 2026-05-10 13:50:39 +01:00
Tony Ferguson
e99ad6a360 Add UprightJoint (#4538) 2026-04-15 10:44:31 +01:00
Sam Pavlovic
65bbb0997f CSM Exclusion Culling (#4491) 2026-04-08 10:44:46 +02:00
Matt Stevens
ef6416ed12 Fix shadows not working in native tools (#4442)
* Some dead config vars

* ShadowMapper work directly with SceneLight, we can't reliably create derived light types from native because the lightdesc is modified later

* Unused on light_environment
2026-04-01 17:17:09 +01:00
Lorenz Junglas
a9cf53c047 Vulkan Per-Thread-Data rewrite (#4407)
Rewrites Vulkan per-thread resource management to use a pooled PerThreadDataVulkan_t slot system with a TLS fast-path, replacing the previous thread-index/map/array approach and updating Vulkan call sites to pass PerThreadDataVulkan_t* instead of thread indices.

* Remove ThreadIndex, SetAssociatedThreadIndex & MaxDeviceThreads (see what breaks)

* Refactor per-thread vulkan data into a single pooled struct

Replace fixed-array per-thread Vulkan data with a dynamic slot pool.
Threads grab slots on demand, hot path is just a TLS read, completly lock-free

Two mechanisms manage slot lifetime:
- Ref counting: render contexts and the render thread AddRef to keep
  their slot alive as long as they need it.
- Idle reclaim: slots nobody is holding onto get recycled after N frames
  of inactivity. Keeps short-lived threads (async shader compiles, texture
  uploads) from leaking slots, while still letting a thread that calls
  GetPerThreadData() every frame hang onto the same slot and all its
  resources (command pools, descriptor pools, pipeline cache, etc).

Moved VkPipelineCache into the per-thread struct with lazy creation.

* Add CRenderDeviceVulkan::GetPerThreadData() acquires from pool

* Use PerThreadData eveywhere instead of ThreadIndex

And do proper thread data shutdown cleanup

* Main render thread gets it's own permaned PerThreadData instance

* Rework pipelinecache to use PerThreadData instead of VkPipelineCache directly
2026-03-29 23:08:08 +02:00
Matt Stevens
1ed034cecd Shadows (#4109)
* Shadows Rewrite: C#, bindless, flexible, quality options, less VRAM...

Introduces a new shadow mapper written entirely in C#, as well as
rewritten shader code for sampling shadow maps. This fully removes and
replaces Source 2's native shadow mapping giving us greater flexibility
and allowing us to open-source it all.

The main goal for the new shadow mapper is greater flexibility whilst
reducing complexity.

Older shaders are incompatible with the new lighting buffers, and will
need to be recompiled to receive lighting properly.

What's new:

- Bindless per-light shadow maps instead of a shared shadow atlas — this
  means games can avoid the shadow atlas cost if not using many shadows,
  but also allows games with many shadows to not be limited by atlas
  space.

- Directional lights have developer configurable cascade count (1-4) and
  control over split ratio (logarithmic/uniform blend via lambda
  parameter), useful for games where you may not need multiple cascades.
  User quality settings define a maximum cascade count which always
  overrides developer settings, allowing low end hardware to use fewer.

- Directional lights have a dedicated cbuffer and uniform fast path in
  rendering code, and are no longer binned and looped over with local
  lights. Every pixel on screen is always affected by a directional
  light.

- CSM cascade selection uses bounding spheres instead of depth
  comparison, with per-cascade texel snapping to eliminate sub-texel
  shimmer.

- Point lights use a TextureCube for cube shadows for much simpler
  rendering and mapping, along with hardware PCF filtering.

- Local light shadow resolution is derived from each light's screen-space
  size. Shadows below a configurable threshold are not rendered at all.
  Lights are sorted by screen size, and r.shadows.max caps the total
  count, culling least important lights first.

- User settings have been added for shadow quality (Low/Medium/High)
  controlling max resolution, max cascades, and PCF filter quality.

- Local light shadow maps use D16 depth format, halving memory compared
  to D32. CSMs remain D32 for precision at large distances.
  (Although this could be a TODO, I bet we could make it work in D16)

- ShadowHardness: New per-light property controlling shadow sharpness.
  Defaults to soft (0.0) and scales up to 4x sharper. For directional
  lights, hardness is automatically scaled per cascade proportional to
  texel density (wider cascades get softer shadows), and clamped so the
  filter never exceeds a full texel — ensuring consistent softness
  across cascade transitions.

- Shadow debug overlay showing all information about allocated shadow maps,
  their textures, cascades and more.

- Many new convars to control
  - r.shadows.max: Maximum number of shadow-casting local lights, sorted by screen size, least important culled first
  - r.shadows.maxresolution: Max texture size for a projected light shadow map (128–4096)
  - r.shadows.quality: Shadow filter quality (0=Off, 1=Low, 2=Med, 3=High, 4=Experimental Penumbra)
  - r.shadows.csm.maxcascades: Maximum number of cascades for directional light shadows (1–4)
  - r.shadows.csm.maxresolution: Maximum resolution for each cascade shadow map (512–8192)
  - r.shadows.csm.distance: Maximum distance from camera that directional light shadows render (500–50000)
  - r.shadows.debug: Show shadow debug overlay with CSM textures, cascade bounds, and memory budget
  - r.shadows.csm.enabled: Enable or disable directional light (CSM) shadows
  - r.shadows.local.enabled: Enable or disable local light (spot/point) shadows
  - r.shadows.depthbias: Rasterizer constant depth bias during shadow map rendering
  - r.shadows.slopescale: Rasterizer slope-scaled depth bias during shadow map rendering
  - r.shadows.size_cull_threshold: Screen size percentage below which local light shadows are culled

- SceneLight refactored into a base class with ScenePointLight,
  SceneSpotLight, SceneDirectionalLight. SceneOrthoLight removed.

- Simplified Light.hlsl: Light is now a class, DynamicLight merged into
  Light, ProbeLight and LightmappedLight no longer inherit from
  DynamicLight.

- GPULight/BinnedLight struct reorganized and trimmed: explicit typed
  fields instead of packed uint4 Params, shadow data replaced with a
  shadow index into a separate StructuredBuffer, removed embedded shadow
  matrices and atlas bounds.

- ViewLightingConfig cleaned up: removed ViewLightingFlags,
  Shadow3x3PCFConstants, EnvironmentMapSizeConstants,
  LegacyAmbientLightColor.

- Baked light mode flags fixed: BAKED lights (lightmaps only) no longer
  create shadow maps. MIXED_SHADOWS gated to Stationary lights only
  (was unconditionally applied). RENDER_ALL_GEOMETRY flag removed.
  DirectLightMode enum documented across Hammer entity definitions.

- Removed light cookie sheets; cookie UV derived from light transform
  (LightToWorld transpose). Cookie sampling simplified to a single
  bindless texture lookup.
2026-03-27 12:07:24 +00:00
Matt Stevens
7dd158deaf Null checks on resource barrier methods 2026-03-26 15:58:54 +00:00
Layla
248c23c2b9 Morph crossfade control (#4380) 2026-03-25 08:18:15 +00:00
Layla
782d37af6d Mesh trace all (#4385) 2026-03-25 08:15:44 +00:00
Layla
343bc0ace7 Add Model.SaveToVmdl and Model.SaveToVmdlAsync 2026-03-20 10:41:13 +00:00
Lorenz Junglas
54932b6725 (Shutdown) Leak Fixes (#4242)
* Remove unnecessary static singletons in MainMenu code

* Empty SceneWorld delete queues during shutdown

* Dresser cancel async load operation on destroy

* Use reflection to null references to static native resources on shutdown

This way we don't  have to remember doing this manually.

* Fix SoundOcclusionSystem using static lists to reference resources

* Sound System: Use weak references to refer to scenes

* Cleanup static logging listeners that kept strong refs to panels

* UISystem Cleanup, make sure all panel/stylesheet refs are released

* RenderTarget and RenderAttributes shutdown cleanup

* Rework AvatarLoader, ThumbLoader & HTTPImageLoader Cache

First try to go through ResourceLibrary.WeakIndex which might already hold the texture.

If there is no hit, go through a second cache that caches HTTP & Steam API response bytes instead of textures.
We want to cache the response bytes rather than the actual Texture, so stuff cached sits in RAM not VRAM.
Before avatars and thumbs would reside in VRAM.

* Fix rendertarget leak in CommandList.Attr.SetValue

GetDepthTarget() / GetColorTarget() return a new strong handle (ref count +1).
We need to DestroyStrongHandle()  that ref. So handles don't leak.

* Call EngineLoop.DrainFrameEndDisposables before shutdown

* NativeResourceCache now report leaks on shutdown

* Override Resource.Destroy for native resources, kill stronghandles

* Deregister SceneWorld from SceneWorld.All during destruction

* Ensure async texture loading cancels on shutdown

* SkinnedModelRender bonemergetarget deregister from target OnDisabled

* Clear shaderMaterials cache during shutdown

* Refactor Shutdown code

Mostly renaming methods from Clear() -> Shutdown()
Adding separate GlobalContext.Shutdown function (more aggressive than GlobalContext.Reset).
Clear some static input state.

* Deregister surfaces from Surface.All in OnDestroy

* RunAllStaticConstructors when loading a mount

* Advanced managed resource leak tracker enabled via `resource_leak_tracking 1`

Works by never pruning the WeakTable in NativeResourceCache.
So we can check for all resources if they are still being held on to and log a callstack.
2026-03-09 17:02:27 +01:00
Matt Stevens
f87bc803e2 scenesystem: this lock is doing nothing and we don't use slots anymore 2026-03-04 23:41:24 +00:00
Layla
f9a6260461 Physics out of bounds event (#4110) 2026-02-21 19:59:07 +00:00
Layla
fcc85487d7 Physics buoyancy (#3961) 2026-02-05 16:13:48 +00:00
Sam Pavlovic
9ad402acae GPU Profiler (#3972)
* GPU Profiler proto by hooking up timestampmgr, simpler and more robust than previous attempt, let's fill this up with useful stuff now

https://files.facepunch.com/sampavlovic/1b3111b1/sbox_Spw1PjMXty.png

* Track all layers for GPU Profiler

* Add SetManagedPerfMarker

* Filter out bullshit, smooth out better, sort timings by cost

https://files.facepunch.com/sampavlovic/1b0211b1/sbox-dev_5Oi1pmpstq.png

* Clear entries when we disable gpu profiler
2026-02-03 09:47:18 +00:00
Sam Pavlovic
1fcec6a92e Indirect Baked Lighting - DDGI (#3420)
* DDGI stub with rasterized path

* Debug probes and fix stuff

* Simplify all of this, add system later

* Iterate, start integrate

* Integrate depth, allow copying depth to another format

* Iterate, fix depth, send ddgi volume data to gpu, start integrating on lighting compositing, almost there

* DDGIVolume gets bake button, doesnt bake automatically, correct transformation

* DDGI Visibility Tests wip

* DDGI Volumetric Fog
https://files.facepunch.com/sampavlovic/1b2911b1/sbox-dev_UCziuQjdTQ.mp4

* Fix ddgi depth integration, iterate

* Simplify this and correct octahedral coordinates seams

* Iterate

* Probe is 8x8, do normalization directly,  cleanup

* Bias probe position, visibility adjustments, make eveyrthing smoother

* Unify integration in SampleProbeData, still need to clean it further

* Unify integrate passes

* Add view bias and use border as per papers, fixes most distortion when using visibility at the same time
https://files.facepunch.com/sampavlovic/1b0411b1/sbox-dev_laDCpwFxk5.png

* Cleanup and fixes for border, cleanup sampling code too

* Proper compositing for DDGI for maps that have baked lighting already, could still have more thought to avoid uncessesary branching

* DDGI System, allow for multiple volumes in scene, cleanup
https://files.facepunch.com/sampavlovic/1b0711b1/sbox-dev_xcJUeit2s4.png
https://files.facepunch.com/sampavlovic/1b0711b1/sbox-dev_c59O7Bea6p.png

* Rebase fixes, the way to do this sucks

* Caching tests, Texture.GetPixels3D seems a bit messed

* ddgi.texturecache texturegenerator, much simpler, caches texture nicely and doesnt lead residues on ram after uploaded

* Add LPVDebugGrid on managed, make DDGIVolume use it, dont save cache texture on disable, works way faster than gizmos

* Update volume only if it's enabled

* DDGI on AmbientLight.hlsl

* Simplify and fixes

* ExtendToSceneBounds, rebake envmaps when bake finished, normalbias

* RENDER_DEFAULT_STATE_RASTERIZER probably shouldnt remove override of rasterizer state

* Cleanup

* [Pick] Fix TextureCompiler not compiling 3D textures properly, make Texture.GetBitmap work with 3D textures

* Add NoPrepassCulling, avoids "rays" from probes that are inside geometry from leaking light

https://files.facepunch.com/sampavlovic/1b1611b1/sbox-dev_bQfsZlWwop.png

* Final adjustments and cleanupj, name this Indirect Light Volume

* Indirect Light Volume prefab

* Remove log infos, adjust sliders

* Whoops

* format

* Rebase fix

* Re-apply the currently tracked cull mode so the override state binds immediately, makes sure that SetLayerNoCull works as intended

* Enqueue probes that affect geometry first, this gives quicker iteration results
https://files.facepunch.com/sampavlovic/1b1911b1/Screen_Recording_2026-01-19_at_16.16.36.mov

* float16 guards for ddgi_integrate, avoid NaNs

* Texture.Save supports volume textures

* DDGIVolume saves using the super nice Texture.Save api instead of texutre generator

* Do the same color punchy look thing we do for envmap probes in ddgi probes
https://files.facepunch.com/sampavlovic/1b1911b1/ezgif-13a1dd53fc7688fe.gif

* Don't save ddgi async, just do it directly

* DDGI editor icon
https://files.facepunch.com/sampavlovic/1b2011b1/F1I0KaZt5j.png

* Shaders

* Format

* Add EditorSystem.Camera

* Move texture creation to DDGIProbeUpdaterCubemapper, build probes in order from the camera, use async instead of an update

* Dont multiply DDGI diffuse by AO, that's done on the shadingmodel, this gives accurate multibounce as well

* Update probes sequentially again, makes sure results are consistent, if we do near camera again, should do it with same logic to keep probes that affect geometry first too

* Move NoPrepassCulling to RenderToCubeTexture, can't figure out why behaviour is different between these but solves light leak issue

* Fix overriding array not working for depth textures, make this clearer

* Overriden rasterizer state actually overrides when doing SetCullMode

* Rework border logic, should be seamless now

* Experiment with shadow sharpness being soft, with borders being fine the variance shadow map stuff from DDGI paper looks correct
https://files.facepunch.com/sampavlovic/1b2211b1/sbox-dev_UNTiRmJ7Fw.png

* Make Depth Sharpness a Property instead

* Delete copy_border shader, do everything within the same shader with groupshared memory, actually sample borders correctly, this reduces octahedral border aliasing to a minimum
https://files.facepunch.com/sampavlovic/1b2311b1/sbox-dev_FqPPpRZ6MD.png
https://files.facepunch.com/sampavlovic/1b2311b1/Source2Viewer_TiqGxdYWwX.png

* Distance calculations use unbiased probe-space position so when we move ddgi transform it doesnt fuck visibility up

* Make DDGI Debug Grid use gizmo pooling so it follows gizmo visibility rules (hidden when gizmos disabled, not in cubemaps)

* DDGI Relocation proto, Moves probes out of geometry to unfuck artifacts
https://files.facepunch.com/sampavlovic/1b2311b1/ezgif-1afaed4e1c2ac9a5.gif
https://files.facepunch.com/sampavlovic/1b2311b1/ezgif-11a3e64fd2952590.gif

* DDGI less contrasty

* Parallelize relocation

* More resilient tracing tests & give option to deactivate if probe is fully inside of geometry instead of relocating those fully occluded

* Simplify LPVDebugGrid, remove all the fucking mess from it

* Simplify DDGIVolume, hide all the bullshit

* VTexWriter allows to save as uncompressed, make Relocation texture uncompressed since we want alpha to be flags

* Add Graphics.FlushGPU
Forces the GPU to flush all pending commands and wait for completion.
Useful when you need to ensure GPU work is finished before proceeding.
Can be called outside of a render block.

* DDGIVolume uses Graphics.FlushGPU instead of dumb Task.Await, density goes up to 10, Debug Grid updates if we change probes

* Format

* Doubt we are going to use flags, just store alpha as active state directly, makes it more resilient to eventual compression

* Sprite was calculating offset incorrectly and causing ambient lighting to be fucked, fog was fucked too
https://files.facepunch.com/sampavlovic/1b2611b1/sbox-dev_i3h4RcWncI.png

* DDGI should really be under Light not Misc

* Keep LPVDebugGrid render bounds infinite, SceneCusotmObject shouldnt change it from there

* Move RelocationTexture to same Generated behaviour so we dont override the property it while we are rendering, make probes default visible

* Remove shitty hack from scenecamera and make DDGIVolumeUpdater take scene renderattributes, makes DDGI bounces retrofeed from itself

Should fix terrain rendering being fucked in DDGI too

Will see to make this more generic

https://files.facepunch.com/sampavlovic/1b2611b1/sbox-dev_uzXYN0Qzw6.png

* Make Energy Loss an attribute for DDGI, I prefer a more contrasty look but there are scenes where you'd want more accurate energy conservation, first picture is an example where energy loss contrast makes it look worse

https://files.facepunch.com/sampavlovic/1b2611b1/sbox-dev_kdTH1qhEwR.png

https://files.facepunch.com/sampavlovic/1b2611b1/sbox-dev_gMoRxorzV0.png

* Progress system can be toasts

* Clean up progress system, always available now via Application.Editor.

* Added Scene/Bake DDGI Volumes

* Changed DDGIVolume to IndirectLightVolume

* Refinement steps for probe relocation

* Kill existing bake if disabled or ticking bake again

* EnergyLoss is Contrast and increase max density, keep default contrast to the value I'm happy with

* Don't call it the implementation name to the user

* formet

* Build shaders

* Bind dummy DDGI_Volumes buffer as default on high level

---------

Co-authored-by: Garry Newman <garrynewman@users.noreply.github.com>
2026-01-27 12:07:21 -03:00
Sam Pavlovic
c8a483ed6f Clustered Culling (#3755)
* Clustered prototype

* Cleanup

* Cleanup, clustered culling uses switch case for readability, put generic math classes in math folder,

* Decals evaluate as a sphere, simpler, API for envmaps and lights dont take positionSs anymore

* Revert this shit on complex

* TiledCullingLayer > ClusteredCullingLayer

* Remove references to UseClusteredLighting/UseTiledLighting, just make it work everywhere

* Remove old tiled culling files

* Remove ClusterFrustum.hlsl since we have a generic one

* Remove OBB as we just test simple bounds for decal

* Final cleanups

* Remove references to tiled culling from native engine

* Adjust toolsvis for clustered

* Rename tiled culling references to clustered culling in render pipeline and tools visualization

* Build shaders

* Format

* Fix fog's near frustum cull plane and clustered warning from Mr. Copilot

* remove the last crumbs from tiled rendering

* Update shaders

* skybox rendering  use ClusteredCullingLayer instead of TiledCullingLayer

* Volume fog still referencing MAX_LIGHTS_PER_TILE, should have it using clusters but slower for now
2026-01-15 13:56:11 -03:00
Sam Pavlovic
88e82c5287 Managed Skybox Pipeline + Skybox Tiled Rendering (#3780)
* Managed skybox pipeline

* Format

* Update engine/Sandbox.Engine/Systems/Render/RenderPipeline/Skybox3DPipeline.cs

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

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-15 12:57:47 -03:00
Sam Pavlovic
ac30658b29 Rasterizer override fix (#3633)
* RENDER_DEFAULT_STATE_RASTERIZER probably shouldnt remove override of rasterizer state

* Add CSceneLayer::SetLayerNoCull(), we need it to avoid light leaks when rendering DDGI probes

* Update src/rendersystem/rendercontextbase.cpp

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

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-04 08:50:06 -03:00
Layla
7a3cccfcb4 Rigidbody isbullet (#3649) 2025-12-22 21:35:49 +00:00
Layla
fa284e585b Physics filter pair (#3566) 2025-12-07 11:15:48 +00:00
Layla
fa4e01729e Wheel joint (#3497) 2025-12-01 12:47:49 +00:00
Sam Pavlovic
d753fa0e24 Vulkan Raytracing Support (#2409)
* Re-enable CreateBLAS in RenderDeviceVulkan

* Update SPVRemapper to suppot raytracing opcode remapping

* Null initialize BLAS on RenderMesh

* Clean proper to generate BLAS on mesh data loading

* SceneRaytracingSystem stub

* Glue SceneRaytracing

* Remove pipelines from SceneRaytracing for now, just do TLAS, tie it to SceneRaytracingSystem, updates only once per frame just like how we want in a clean way
https://files.facepunch.com/sampavlovic/1b0611b1/ngfx-ui_Ck3ckzQQFT.png

* Send Descriptor Set of Raytracing World to RenderAttribute

* RTAO example using RayQuery

* RayTracingShader API stub

* Set SM6.0 and dxlevel 120 as default

* Instead of making raytracing opt-in, add -nogpuraytracing to force disable it

* Add IRenderDevice::IsRayTracingSupported() to easily query support for it

* Fix IsRayTracingSupported()

* RTAO Adjustments

* Allow Rayquery through AS on Compute and Pixel shaders even if not optimal, avoids it crashing when acessing it on compute

* Strip CRaytraceSceneWorld to just generating TLAS, dont need anything else for now and we need a better way to handle UGC than what's there

* Bindless::RaytracingAccelerationStructure()

* Simplify interface too

* Stub for UpdateSkinnedForRaytracing

* Dotnet format and fix documentation, make RTAO run at correct stage

* Only support raytracing in tools mode for now

* Move raytracing stuff to Raytracing.hlsl

* Stub RTX shader

* Internal Raytracingshader and remove useless stuff exposed from it

* VfxProgramHasRenderShader should check for VFX_PROGRAM_RTX too, that's the source from everything else failing

* Add arbitrary entry point support to shaders, needed as RTX shaders use [shader("XXX")] instead of MainXXX directly

* RenderTools::TraceRays API, preliminary implementation, RTAO uses RaytracingShader

* Make RT support internal, allow RT on game

* Remove RaytracedAmbientOcclusion, will be on scenestaging when ready

* Update engine/Sandbox.Engine/Systems/Render/RayTracingShader.cs

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

* Fix rebase

* Update shaders

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-11-27 22:40:02 -03:00
s&box team
71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00