Class Renderer
Namespace: ValveResourceFormat.Renderer
Assembly: Renderer.dll
Main renderer for Source 2 scenes with support for shadows, post-processing, and multiple render passes.
public class Renderer : ISpawnGroupHostInheritance
Implements
Constructors
Renderer(RendererContext)
Initializes a new renderer with the given context.
public Renderer(RendererContext rendererContext)Parameters
rendererContext RendererContext
Shared context providing loaders and caches.
Properties
BarnLightShadowBuffer
Depth-only framebuffer atlas used for barn light shadow mapping.
public Framebuffer? BarnLightShadowBuffer { get; }Property Value
BaseBackground
Default background used when no skybox is available.
public SceneBackground? BaseBackground { get; protected set; }Property Value
Camera
Active camera used for view and projection transforms.
public Camera Camera { get; set; }Property Value
DefaultSunAngles
Default sun angles for lighting used by viewers without lighting information
public static Vector2 DefaultSunAngles { get; }Property Value
DefaultSunColor
Default sun color for lighting used by viewers without lighting information
public static Vector4 DefaultSunColor { get; }Property Value
DeltaTime
Time elapsed since the last frame, in seconds.
public float DeltaTime { get; set; }Property Value
DisableAllCulling
When true, every form of culling (CPU frustum, GPU meshlet, occlusion, PVS, shadow frustum) is bypassed so the whole scene is submitted.
public bool DisableAllCulling { get; set; }Property Value
EnableBarnLights
Enable barn light types in shaders.
public bool EnableBarnLights { get; set; }Property Value
EntitySystem
The entity world the scenes are spawned into, ticked once a frame ahead of the scenes that draw it.
public EntitySystem EntitySystem { get; }Property Value
ForceResolveSceneDepth
When set, forces to be refreshed this frame even if no material or occlusion pass requests it. Used by overlays (e.g. world-space text) that need the scene depth to occlude themselves against geometry. Must be set before .
public bool ForceResolveSceneDepth { get; set; }Property Value
IsWireframe
When true, geometry is rendered as wireframe lines.
public bool IsWireframe { get; set; }Property Value
LightTilesOverlay
Gets the fullscreen tile mask overlay drawn in the tile debug render modes.
public LightTilesOverlay LightTilesOverlay { get; }Property Value
LockedCullFrustum
When not null, culling uses this frustum instead of the camera frustum, freezing the cull state. Setting it also freezes the 3D sky's cull frustum.
public Frustum? LockedCullFrustum { get; set; }Property Value
LockedCullPosition
When not null, PVS queries use this position instead of the camera position, freezing the PVS state.
public Vector3? LockedCullPosition { get; set; }Property Value
MainFramebuffer
Target framebuffer for the main scene render; must be set before calling .
public Framebuffer? MainFramebuffer { get; set; }Property Value
MainViewState
Gets the main scene state in the main view, or null until the first update.
public SceneViewState? MainViewState { get; }Property Value
OutlineMaskBuffer
Single channel coverage mask written by the outline geometry pass and read by the outline edge post pass. Lazily created to match 's dimensions and sample count.
public Framebuffer? OutlineMaskBuffer { get; }Property Value
ParallelSimulation
Whether scene nodes simulate across the thread pool. Off runs them in scene order.
public bool ParallelSimulation { get; set; }Property Value
PerfStats
Per-frame rendering statistics, including CPU/GPU profiling timings
public PerfStats PerfStats { get; }Property Value
Postprocess
Post-processing renderer handling tone mapping, bloom, and MSAA resolve.
public PostProcessRenderer Postprocess { get; set; }Property Value
Prewarming
Set while the shader specialization prewarm frame is being drawn.
public bool Prewarming { get; set; }Property Value
RendererContext
Shared renderer context containing loaders and caches.
public RendererContext RendererContext { get; }Property Value
ResolvedSceneColor
Resolved (non-MSAA) scene color in rgba16f format, used for refraction, bloom input, and luminance computation. Filled by .
public RenderTexture? ResolvedSceneColor { get; }Property Value
ResolvedSceneDepth
Resolved (non-MSAA) scene depth in R32F format, used for the depth pyramid and occlusion culling. Filled by .
public RenderTexture? ResolvedSceneDepth { get; }Property Value
Scene
The main scene to render.
public Scene Scene { get; }Property Value
Scenes
Gets the scenes drawn, the main scene first, then one per spawn group in load order.
public IReadOnlyList<Scene> Scenes { get; }Property Value
ShadowDepthBuffer
Depth-only framebuffer used for directional (sun) light shadow mapping.
public Framebuffer? ShadowDepthBuffer { get; }Property Value
ShadowTextureSize
Width and height in texels of the shadow depth buffers.
public int ShadowTextureSize { get; set; }Property Value
ShowSkybox
When true, the 3D sky is drawn. Does not affect the 2D skybox.
public bool ShowSkybox { get; set; }Property Value
ShowSoundDebug
Gets or sets whether the vsnd name of every active positioned sound is billboarded in the world.
public bool ShowSoundDebug { get; set; }Property Value
SkyCamera
Camera the 3D sky is drawn through.
public Camera SkyCamera { get; }Property Value
SkyGroup
Gets the spawn group the 3D sky is drawn from, or null; the last one placed wins.
public SpawnGroup? SkyGroup { get; }Property Value
Skybox2D
Gets or sets the 2D sky drawn when no scene in view has one.
public SceneSkybox2D? Skybox2D { get; set; }Property Value
SpawnGroups
Gets the spawn groups placed into the loaded map, such as its 3D sky.
public IReadOnlyList<SpawnGroup> SpawnGroups { get; }Property Value
Textures
Named textures bound to reserved slots for all render passes.
public List<(ReservedTextureSlots Slot, string Name, RenderTexture Texture)> Textures { get; }Property Value
List<(ReservedTextureSlots Slot, string Name, RenderTexture Texture)>
Uptime
Total time elapsed since the renderer was started, in seconds.
public float Uptime { get; set; }Property Value
ViewBuffer
GPU uniform buffer containing per-view constants such as view-projection matrices.
public UniformBuffer<ViewConstants>? ViewBuffer { get; set; }Property Value
ViewmodelCamera
Secondary camera used to render the first-person viewmodel layer with its own FOV. Synced to 's position/orientation each frame; see .
public Camera ViewmodelCamera { get; }Property Value
WaterEffectsBuffer
Screen space map of ripple, silt and foam decals that the fancy water shader reads.
public Framebuffer? WaterEffectsBuffer { get; }Property Value
WaterEffectsDownsample
Scene pixels per water effects texel, horizontally and vertically.
public static (int X, int Y) WaterEffectsDownsample { get; }Property Value
Methods
AddSpawnGroup(SpawnGroup)
Starts drawing a spawn group; its scene must be initialized before the next frame.
public void AddSpawnGroup(SpawnGroup group)Parameters
group SpawnGroup
Clear()
Empties the entity world and every scene, leaving the renderer ready to load something else.
public void Clear()Dispose()
Releases GPU resources owned by this renderer.
public void Dispose()DrawMainScene()
Renders the opaque and translucent layers of the main view to .
public void DrawMainScene()FindNode(Entity)
Finds the node an entity was loaded as, in whichever scene it went into.
public SceneNode? FindNode(EntityLump.Entity entity)Parameters
entity EntityLump.Entity
The entity to look for.
Returns
Its node, or null when it has none.
FindNodeByTargetName(string)
Finds a node by its entity's targetname, in whichever scene it went into.
public SceneNode? FindNodeByTargetName(string pattern)Parameters
pattern string
The target name to match.
Returns
The first matching node, or null when there is none.
GrabFramebufferCopy(Framebuffer, bool, bool)
Resolves MSAA and copies color and/or depth from the framebuffer into and .
public void GrabFramebufferCopy(Framebuffer framebuffer, bool copyColor, bool copyDepth)Parameters
framebuffer Framebuffer
copyColor bool
copyDepth bool
Initialize()
Allocates GPU resources required for rendering; must be called once before .
public void Initialize()LoadDefaultLighting(Scene, Resource)
Load default lighting, used by viewers without lighting information
public static void LoadDefaultLighting(Scene scene, Resource ibl)Parameters
scene Scene
ibl Resource
LoadRendererResources()
Loads the embedded BRDF LUT and cube fog textures, and the game's blue noise where it has one, into .
public void LoadRendererResources()PostprocessRender(Framebuffer, Framebuffer, bool)
Multisampling resolve, postprocess the image, and convert to gamma.
public void PostprocessRender(Framebuffer inputFramebuffer, Framebuffer outputFramebuffer, bool flipY = false)Parameters
inputFramebuffer Framebuffer
outputFramebuffer Framebuffer
flipY bool
RemoveSpawnGroup(SpawnGroup)
Stops drawing a spawn group and releases its scene and mounted package. Remove its entities first with
.public void RemoveSpawnGroup(SpawnGroup group)Parameters
group SpawnGroup
Render(Framebuffer)
Renders the scene to the specified framebuffer. The result will be in linear space.
public void Render(Framebuffer framebuffer)Parameters
framebuffer Framebuffer
Framebuffer with hdr color support.
Render(RenderContext)
Renders shadows and then the full scene using the provided render context.
public void Render(Scene.RenderContext renderContext)Parameters
renderContext Scene.RenderContext
RenderSceneShadows(RenderContext)
Renders opaque shadow casters for the directional (sun) light into .
public void RenderSceneShadows(Scene.RenderContext renderContext)Parameters
renderContext Scene.RenderContext
RenderScenesWithView(RenderContext)
Renders every view using the camera and framebuffer specified in the render context.
public void RenderScenesWithView(Scene.RenderContext renderContext)Parameters
renderContext Scene.RenderContext
Update(UpdateContext)
Advances the simulation, updates scene draw calls, and prepares shadow data for the next frame.
public void Update(Scene.UpdateContext updateContext)Parameters
updateContext Scene.UpdateContext

