Commit Graph

87 Commits

Author SHA1 Message Date
Antoine Pilote
95d0af4972 Terrain buffer safety & api improvements (#3954)
* Added HasTerrain attribute for buffer overflow safety if reading terrain data before terrain has been initialized on the GPU

* Fix terrain leaking gpu buffer if disabled or deleted

Set HasTerrain flag to false once all terrains are gone

* Exposed more terrain helpers in TerrainCommon.hlsl

- GetWorldHeight
- IsInBounds
- SampleColor

* built shaders

* built terrain shader

* Changed Has() to terrainCount instead

* Make count 0 if disabling the last terrain

* built shaders
2026-01-30 01:02:34 +00:00
Conna Wiles
791c5113cd Re-enable Animation Events when PlayerController is Enabled after being previously Disabled (#3942) 2026-01-29 12:03:36 +00:00
Lorenz Junglas
997db6d283 Scene.PreCameraRender fixes (#3931)
* Readd ScenePanel hack I remove, turns out it's needed
* Don't create material every frame for bloom layer
Fixes main thread assert for mirrors
2026-01-28 16:09:03 +00:00
Sam Pavlovic
787e8b3399 Indirect Light Volume Fixes (#3920)
* Encode DDGI depth properly, use a proper cone instead of tightening the fibonacci and get radial depth correctly, this is the correct way to do this, remove DepthSharpness since we dont need it anymore, adjust contrast back to 1.0f since 2.0f is very opinionated

* Can specify if Indirect Light Probe is indoor or outdoor

* Get rid of these softening stuff for DDGI, the depth algorithm is correct, pass variance directly ( verify if will shit BC6H )

* Store Distance as uncompressed for now, we really need high precision for accurate variance

* Option for high quality bounces, do two passes to make sure that bottom-up rays are accurate, start doing calculation from ray from scene camera like Garry initially wanted if so

* shaders

* Readd DDGIVolume alias to not break prefab

* Accidentally sent wrong variance, corrected

* format
2026-01-28 14:47:34 +00:00
Conna Wiles
3f0c69a2ea CodeGen Lambda Cache + More Network Optimizations (#3893) 2026-01-27 16:41: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
Lorenz Junglas
ac6e176a0d Reduce smoothdamp usage in audio components (#3881)
* Add MathX.ExponentialDecay, similar to our C++ version of it
* Replace SmoothDamp usage in audio components with expdecay
2026-01-23 10:30:00 +01:00
Conna Wiles
68884635b2 More Networking Optimizations 2026-01-22 23:21:45 -08:00
ryleigh
074263fddb Add Snap To Frame option for particle sheet sequences (#3821) 2026-01-21 10:06:51 -08:00
wheatleymf
7774ffc765 Add custom texture filtering to BeamEffect too
- Supports only texture filtering
- Clamp/wrap address mode is set using existing logic (set to `Clamp` only if "Travel" feature is enabled, in all other cases it's set to `Wrap`)
2026-01-21 10:53:14 +01:00
wheatleymf
96b2f0c9cc Custom filtering/address mode for line renderers
- Allows artists to control texture filtering (point/bilinear/trilinear/anisotropic) on line and trail renderers
- Obsoletes "Clamp" in SceneTrailObject's `TrailTextureConfig` struct, use `FilterMode` and `TextureAddressMode` properties instead. Default config will set anisotropic filtering with "wrap" UV address mode.
- No changes in line.shader, it still uses bindless sampler state. It is assigned from SceneLineObject.cs in `SamplerState` property's setter
2026-01-21 10:53:14 +01:00
Garry Newman
34990d7b56 IPressable Tooltips (#3858)
* IPressable can provide tooltips
* BaseChair supports tooltips
* Api++
2026-01-21 00:24:27 -08:00
Lorenz Junglas
9d072e6d89 Audio Optimizations (#3847)
- Auto-cleanup idle voice handles: Voice sound handles are now killed when player hasn't been talking for a while
- Audio Occlusion refactor: Moved occlusion calculation to a dedicated SoundOcclusionSystem GameObjectSystem for better organization
  - This now performs really well, so we could look into improving our occlusion calculation: proper damping when sound is transferred via wall, path tracing for occlusion etc. (will open a separate issue)
- Fix mixer early return bug: Fixed issue where mixer could return early, potentially skipping sounds
- Voice Component lipsync toggle: Added option to enable/disable lipsync processing on VoiceComponent
- Cheaper HRTF for voice audio: Disabled expensive bilinear interpolation for voice and certain other sounds in Steam Audio
- Editor MixerDetail perf: Skip frame updates on MixerDetail widget when not visible
- Reduced allocations in audio systems: Optimized away List and LINQ allocations in SoundOcclusionSystem, Listener, and SoundHandle.Source
- MP3 decoder buffer optimization: Improved buffer handling in native CAudioMixerWaveMP3 to reduce overhead

Depending on scenario can reduces audio frame time by up to 30%.
This should also drastically improve performance for games that use VOIP.
2026-01-20 18:48:09 +01:00
Conna Wiles
22b7c9e494 Add wrapper method overload for single array type (#3834) 2026-01-20 13:53:19 +00:00
Layla
ba68a30357 Mapping tools apply hotspot (#3828) 2026-01-20 12:38:53 +00:00
Carson Kompon
54429f0a13 Fix Press events on child GameObjects being sent to the parent if it has a rigidbody (#3811) 2026-01-19 07:55:21 -05:00
sboxbot
66962235d0 Localized Particle Velocity Fixes (#3808)
* localize particle velocity properly

same method as localizing position

* localize initial velocity using the 0th delta of `LocalSpace`

This is consistent with what you see in the editor, there's no indication that `LocalSpace` only applies the later movements of the particle and not everything in the movement feature.

* localize `ConstantMovement` as well

---------

Co-authored-by: Fortune <7847372+Fortune117@users.noreply.github.com>
2026-01-19 11:23:05 +00:00
sboxbot
ea65f915d2 Fix UseInputControls disabling lookat controls on PlayerController (#3822)
Co-authored-by: Balandjin Alexandre
2026-01-19 10:03:26 +00:00
Sam Pavlovic
9066f38917 Added baking to EnvmapProbe
* Added ability to bake envmap textures
* Added Scene.Editor.GetSceneFolder() - allows saving baked resources for scene
* Envmaps are represented with a shiny sphere now instead of a handle
* Fixed Enum Dropdown being the wrong color
* Added [EnumButtonGroup]
* Added GroupButtonControlWidget
* Added Editor.EditorSystem (accessible via Application.Editor)
* Can place [Menu] attributes in game code (was previously in tools only)
* Added "Scene/Bake Envmaps" option
2026-01-19 08:09:13 +00:00
Tony Ferguson
1de8ea2761 Expose MinImpactDamageSpeed, ImpactDamage in ModelPropData (#3803) 2026-01-16 09:54:28 +00:00
Lorenz Junglas
12affe5ccb Reduce material creations/allocations (#3766)
* Make SpriteBatchSceneObject shaders static, so we don't create them per instance

* Avoid per frame shader/material creation in PostProcessing

* Avoid per frame shader/material creation in HudPainter

* Move a few more compute shaders into static members

* Reduce allocations in NormalizeFilename

* Reduce string allocations in Material.FromShader
2026-01-14 08:40:37 +01:00
Antoine Pilote
5de9b0b06b always who alpha cutoff setting (#3769) 2026-01-13 15:56:24 -08:00
Lorenz Junglas
236b95e0ed Disposable diagnostic (#3693)
* Enable CA2000 in editorconfig

* Remove unused CaptureStdOut class

* Add missing dispose calls in Sandbox.Tools

* Add missing dispose calls in tests

* Add missing dispose calls in launchers

* Add missing dispose calls in Topten.RichtTextKit

* Add missing dispose calls in Engine

* Add missing dispose calls in SboxBuild

* Add nullchecks to a few dispose calls

* Fix more missing disposal calls and leaks

* Disable CA2000 for Textures

* Fix disposing too early in ImageFileTextureGenerator

* Fix disposing codec, ownership is transferred to animation

* Add missing using in ByteStream benchmark
2026-01-12 21:59:15 +01:00
Conna Wiles
06222ffdc4 INetworkSnapshot Support for GameObjectSystem (#3743) 2026-01-12 16:01:53 +00:00
Garry Newman
9de264593d Add advanced AnchorBody property to Joint (#3746)
Adds a AnchorBody joint, which can be revealed and filled in to supply the anchor body for the joint - rather than using the joint's GameObject
2026-01-12 13:32:00 +00:00
Layla
4efa081882 compute vertex tangents the same way hammer does (#3741) 2026-01-11 20:01:31 +00:00
Layla
5adf2e1823 Modelphysics issues (#3719) 2026-01-10 04:44:12 +00:00
Layla
f449ba39c2 double click faces selects contiguous faces, not all of them (#3718) 2026-01-09 10:51:45 +00:00
Layla
d365ffb506 suspension gizmo goes along Y (#3731) 2026-01-09 10:51:37 +00:00
Matt Stevens
3daba9716f Terrain add back texture streaming (again?) 2026-01-08 14:43:34 +00:00
Lorenz Junglas
1c5105bf72 SkinnedRenderer add null check when accessing go parent (#3721)
(Prefabs roots don't have parents)
2026-01-08 08:41:44 +01:00
Garry Newman
d0237a2124 Fix "generating envmaps" spam on loading screen (#3710) 2026-01-07 14:02:06 +00:00
Lorenz Junglas
acfbbb0ef6 Move AnimDecodeCache lock from managed to native (#3662)
* Move AnimDecodeCache lock managed to native

Should prevent crash if cache is accessed concurrently by native and managed at the same time.

* Also pass lock thrugh CalcLocalHierarchyAnimation

* Make sure nested bone merge hierarchies update correctly
2026-01-06 13:34:46 +01:00
Layla
b9893bb773 Fix WorldInput state being stomped, refactor how they're done and remove old shit way
* UISystem ticks over WorldPanel and WorldInput components
* Obsolete WorldInput class (it does nothing now)
* Add basic VR support by default to WorldInput component
* Remove VRWorldInput from menu
* Remove dead VROverlayInput

---------

Co-authored-by: Matt Stevens <matt@mattstevens.co.uk>
2026-01-06 10:32:44 +00:00
Antoine Pilote
924bbb3fa9 Added sprite alpha cutout (#3667)
* Added AlphaCutout setting to opaque sprite

* Just store as uint and cast back to float when necessary, simpler that way

https://files.facepunch.com/antopilo/1b2311b1/sbox-dev_wEBQHQosGe.mp4

* Rename fogStrength var to packedFogAndAlpha

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

* Fix typo by copilot preventing from compiling

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-05 07:50:31 -08:00
Carson Kompon
012dd40b89 CameraComponent now treats CustomSize as an override instead of being used as a fallback (#3692) 2026-01-05 09:39:33 -05:00
Layla
5e41d18750 Mapping tool thicken faces (#3681) 2026-01-05 12:44:32 +00:00
Layla
7ab2f3d351 Obsolete vertex attribute array (#3683) 2026-01-01 07:55:17 +00:00
Layla
3a60e7c143 prop inherits rigidbody properties that were set in modeldoc (#3682) 2026-01-01 07:32:30 +00:00
Layla
41f70325e2 Fix mapping move mode gizmos initial state (#3679) 2025-12-29 07:30:04 +00:00
Garry Newman
1dfd1de087 Thumb Textures (#3677)
Adds a universal way to get thumbnail images.

- `thumb:entities/sents/npc/scientist.sent` - resources/assets
- `thumb:mount://ns2/ns2/models/effects/exosuit_part1.model.vmdl` -mount files
- `thumb:facepunch.snowman` - packages

This greatly simplifies UI like the spawnmenu that needs to show thumbnails for these things.

We also add `AssetTypeFlags.IncludeThumbnails`. If this is set then when the package is published, any asset types with this flag will include a "[path].c.png" thumbnail image of it.

Also does Api++ protocol increase.
2025-12-27 17:55:57 +00:00
Layla
252d5fbd5a Clipping tool (#3668) 2025-12-27 11:05:06 +00:00
Layla
6c8a5613c1 Scene mesh per triangle physics materials (#3673) 2025-12-27 11:00:03 +00:00
Layla
677282f1cd fix typo causing unduck headroom check to fail 2025-12-23 14:30:40 +00:00
Layla
592575afe5 fix small mistake in EnhancedCcd 2025-12-22 22:15:21 +00:00
Layla
7a3cccfcb4 Rigidbody isbullet (#3649) 2025-12-22 21:35:49 +00:00
Layla
35aedbbd79 Advanced properties (#3652) 2025-12-22 08:31:55 +00:00
Lorenz Junglas
08c4ae6d73 Animgraph pose node optimizations (#3646)
* AddPoseOperation skip work when added transform is equal to identity

* SubtractPoseOperation skip work when added transform is equal to identity

* Fast path for BlendUpdateNode when weights are 1

Don't emit expensive pose op just forward the pose with weight 1

* Fast path for Blend2DUpdateNode when weights are 1

Don't emit expensive pose op just forward the pose with weight 1

* Avoid allocation of Actions in MergeDescendants
2025-12-22 07:09:45 +00:00
Garry Newman
d84f64c2c3 Fix wheel joint steering axis 2025-12-19 16:37:54 +00:00
Lorenz Junglas
bf8a22f40b Avoid allocations in MergeDescendants by using recursion instead of yield return (#3644)
yield return creates a lot of garbage and is easily avoidable here, by using recusing instead.
2025-12-19 12:12:51 +01:00