Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Facepunch/sbox-public
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: Pi-Dev/Source2-sandbox
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 6 commits
  • 84 files changed
  • 4 contributors

Commits on Mar 27, 2026

  1. 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.
    handsomematt authored Mar 27, 2026
    Configuration menu
    Copy the full SHA
    a577067 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    8ec6f4b View commit details
    Browse the repository at this point in the history
  3. Call ReflectionQueryCache.ClearTypeCache in GlobalContext.OnHotload (#…

    …4409)
    
    * Instead of in a EditorEvent.Hotload, which only happens in the editor
    * Fixes exceptions on connected clients after hotload (#10246, #10210)
    Metapyziks authored Mar 27, 2026
    Configuration menu
    Copy the full SHA
    53a9e1c View commit details
    Browse the repository at this point in the history
  4. Movie Recording Playtest Fixes (#4401)

    * Add DisableClientRecording config property in MovieRecorderSystem
    * Fix handling missing prefabs when creating targets
    * Fix AutoBind finding prefab scenes(?)
    * Include current game's ident in __references for movie recordings
    * Make exceptions when serializing blocks survivable
    * Survive trying to compress NaN / infinite transforms / rotations
    * MemberProperty: use delegate instead of reflection when getting value
    * PropertyBlockWriter: avoid allocating _samples list for constants
    * Fix creating targets from prefab with multiple same-type components
    * Add TextRendererCapturer, fix recording strings
    Metapyziks authored Mar 27, 2026
    Configuration menu
    Copy the full SHA
    ed27afc View commit details
    Browse the repository at this point in the history
  5. Api++ (#4411)

    DevulTj authored Mar 27, 2026
    Configuration menu
    Copy the full SHA
    4e12fc8 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    e948428 View commit details
    Browse the repository at this point in the history
Loading