group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
NewRenderer Class Reference

Graphics-team's work-in-progress SDL3 GPU renderer. More...

#include <NewRenderer.hpp>

Collaboration diagram for NewRenderer:
[legend]

Public Member Functions

bool init (SDL_Window *window)
 Initialise the GPU device, pipelines, and default scene assets.
void drawFrame (glm::vec3 eye, float yaw, float pitch, float roll)
 Render one frame from the given camera pose.
void quit ()
 Release all GPU resources and shut down the renderer.
SDL_GPUDevice * getDevice () const
 Returns the SDL GPU device.
SDL_GPUShaderFormat getShaderFormat () const
 Shader format selected during init() (SPIR-V on Vulkan, MSL on Metal, DXIL on D3D12).
SDL_GPUTextureFormat getSwapchainColorFormat () const
 Color format of the active swapchain render pass.
const NewCameragetCamera () const
 Current camera (updated every drawFrame call).
int modelCount () const
 Number of models currently registered in the asset map.
float getLastAcquireMs () const
 Most-recent SDL_AcquireGPUCommandBuffer cost in milliseconds.
float getLastRecordMs () const
 Most-recent command-recording cost (between acquire and submit) in ms.
float getLastSubmitMs () const
 Most-recent SDL_SubmitGPUCommandBuffer cost in milliseconds.
void setEntityRenderList (std::vector< EntityRenderCmd > &&entityList)
 Set the list of entity render commands for this frame.
void setPointLights (std::vector< PointLight > pointLights)
 Set dynamic point lights for this frame.
void setStaticPointLights (std::vector< PointLight > &&pointLights)
void setWeaponViewmodel (const WeaponViewmodel &vm)
 Set the first-person weapon viewmodel for this frame.
void setModelEmissive (int32_t modelIdUnsanitized, glm::vec4 emissiveColor)
 Override the emissive colour of every mesh in a registered model.
void setModelScenePass (int32_t modelIndex, bool drawInScene)
 Toggle whether a model is drawn during the scene pass.
SkinnedRendererskinned ()
 Accessor for the skinned-character subsystem.
const SkinnedRendererskinned () const
int loadSceneModel (const char *filename, glm::vec3 pos, float scale, bool flipUVs, const std::string &excludeNodesContaining="")
 Load a model from disk and register it in Asset::models_ + create a default scene instance.
void setHudTexture (SDL_GPUTexture *hudTexture)
 Set the HUD overlay texture to blit after the geometry pass.
void setParticleSystem (ParticleSystem *ps)
 Register the particle system so the renderer can call its render hooks.
bool setVSync (bool enabled)
 Enable or disable vertical sync.
void requestScreenshot (const std::string &path)
 Request a screenshot to be saved to disk after the next frame.
void updateModelMeshVertices (int modelIndex, int meshIndex, const Vertex *vertices, Uint32 vertexCount)
 Queue a vertex-buffer re-upload for one mesh of a loaded model.
bool loadHDRSkybox (const std::string &path)
 Load an equirectangular HDR image as the environment skybox + IBL source.
void scanHDRFiles ()
 Scan the assets HDR directory and populate availableHDRFiles_.
bool setRig (const std::vector< RigMeshSource > &meshes, int numJoints)
void setSkinnedFrame (const std::vector< glm::mat4 > &palette, const std::vector< SkinnedInstance > &instances)

Static Public Member Functions

static constexpr SDL_GPUTextureFormat getHdrFormat ()
 Legacy HDR colour render target format.

Public Attributes

float renderScale = 1.0f
 Internal-resolution multiplier (0.5 = half-res, 2.0 = SSAA).
float mainHorizontalFovDegrees = 110.0f
 Main camera horizontal field of view in degrees.
float scopeZoom = 1.0f
 Per-frame scope zoom multiplier (FOV divisor).
bool imguiEnabled = true
 Master toggle for the ImGui debug overlay.
RenderToggles toggles {}
 Per-pass on/off toggles (see RenderToggles in RendererTypes.hpp).
float roughnessTextureStrength = 1.0f
 Scales sampled roughness texture values before lighting.
float metallicTextureStrength = 0.5f
 Scales sampled metallic texture values before lighting.
float ambientColorMultiplier = 1.0f
 Scales the geometry shader ambient colour contribution.
float lightIntensityMultiplier = 8.0f
 Scales direct geometry light intensity.
float hdrExposure = 1.0f
 Debug exposure multiplier used by the tonemap pass.
float hdrWhitePoint = 4.0f
 Debug white point for Extended Reinhard tonemapping.
float ssaoRadius = 24.0f
 World-space AO sampling radius.
float ssaoBias = 1.5f
 World-space self-occlusion bias.
float ssaoPixelRadiusScale = 0.35f
 Converts AO radius to screen-space sample spacing.
float ssaoDepthThreshold = 0.01f
 Max depth-buffer delta accepted for contact AO samples.
float ssaoNormalDiffMin = 0.12f
 Normal-difference start for crease/contact weighting.
float ssaoNormalDiffMax = 0.55f
 Normal-difference full weight for crease/contact weighting.
float ssaoHemisphereMin = 0.05f
 Minimum normal-facing direction for AO samples.
float ssaoContactWeight = 1.0f
 Tight contact AO band weight.
float ssaoMediumRadius = 48.0f
 Medium-radius crease/corner AO band.
float ssaoMediumWeight = 0.25f
 Medium AO band weight.
float ssaoIntensity = 1.0f
 Raw AO occlusion multiplier.
float ssaoMinAo = 0.45f
 Darkest raw AO value.
float ssaoMaxAo = 1.0f
 Brightest raw AO value.
bool ssaoBlurEnabled = true
 Use the depth/normal-aware AO blur.
float ssaoBlurRadius = 1.0f
 Multiplier for the fixed 5x5 AO blur offsets.
float ssaoBlurDepthThreshold = 0.3f
 Blur world-distance rejection as a fraction of AO radius.
float ssaoBlurNormalThreshold = 0.6f
 Minimum normal dot for AO blur samples.
float ssaoBlurStrength = 1.0f
 Blend amount from raw AO to blurred AO.
float ssaoCompositeStrength = 1.0f
 AO application strength before tonemapping.
float ssaoCompositePower = 2.0f
 AO exponent before composition.
int ssaoDebugView = 0
 0 final scene, 1 raw AO.
std::vector< std::string > availableHDRFiles
 Filled by scanHDRFiles(); consumed by debug UI.
std::string currentHDRName = "(procedural)"
 Display name of the currently-loaded HDR.
bool useHDRSkybox = false
 True after a successful loadHDRSkybox().

Private Member Functions

bool createGeometryPipeline ()
bool createGeometryLightMapPipeline ()
bool createEntityChamsPipeline ()
 Create the flat static-entity chams pipeline used for occluded powerup silhouettes.
SDL_GPUGraphicsPipeline * createDepthPipeline (const SDL_GPURasterizerState &rasterizer_state) const
bool createDepthRes0Pipeline (bool reverseZ)
bool createDepthRes1Pipeline (bool reverseZ)
bool createDepthRes2Pipeline (bool reverseZ)
bool createHudPipeline ()
bool createFxaaPipeline ()
bool createTonemapPipeline ()
bool createSsaoPipeline ()
bool createSsaoBlurPipeline ()
bool createSsaoCompositePipeline ()
bool ensureDepthTextureSize (Uint32 width, Uint32 height)
bool ensureSceneTextureSize (Uint32 width, Uint32 height)
void createMeshBuffers (MeshIdInt meshId) const
void setMainCamera (glm::vec3 eye, float yaw, float pitch, float roll, Uint32 width, Uint32 height, float fov)
void drawGeometryDepthPass (SDL_GPUTexture *depthTexture, Uint8 res, Uint8 layer, SDL_GPUCommandBuffer *cmd, const glm::mat4 &shadowViewProjection, bool staticGeometry, bool entityGeometry, bool skinnedGeometry)
void drawToShadowMap (SDL_GPUCommandBuffer *cmd, SDL_GPUTexture *shadowMapTexture, Uint8 res, bool staticGeometry, bool entityGeometry, bool skinnedGeometry, PointLightType lightType, bool cullByCamera=true)
void onFirstFrame (SDL_GPUCommandBuffer *cmd)
void bindLightShadowInfo (SDL_GPURenderPass *renderPass, SDL_GPUCommandBuffer *cmd, bool lightmap)
void drawStaticLightmapGeometryPass (SDL_GPUTexture *sceneColor, SDL_GPUCommandBuffer *cmd)
void drawGeometryPass (SDL_GPUTexture *sceneColor, SDL_GPUCommandBuffer *cmd)
void drawGeometryOverlayPass (SDL_GPUTexture *sceneColor, SDL_GPUCommandBuffer *cmd)
void drawSsaoPass (SDL_GPUTexture *depth, SDL_GPUTexture *normal, SDL_GPUTexture *ao, SDL_GPUCommandBuffer *cmd)
void drawSsaoBlurPass (SDL_GPUTexture *ao, SDL_GPUTexture *depth, SDL_GPUTexture *normal, SDL_GPUTexture *output, SDL_GPUCommandBuffer *cmd)
void drawSsaoCompositePass (SDL_GPUTexture *sceneColor, SDL_GPUTexture *rawAo, SDL_GPUTexture *blurredAo, SDL_GPUTexture *output, SDL_GPUCommandBuffer *cmd)
void drawUIPass (SDL_GPUTexture *swapchain, SDL_GPUCommandBuffer *cmd)
void drawHudPass (SDL_GPUTexture *target, SDL_GPUCommandBuffer *cmd)
void drawFxaaPass (SDL_GPUTexture *sceneColor, SDL_GPUTexture *swapchain, SDL_GPUCommandBuffer *cmd)
void drawTonemapPass (SDL_GPUTexture *hdrSceneColor, SDL_GPUTexture *ldrColor, SDL_GPUCommandBuffer *cmd)
void drawParticles (SDL_GPURenderPass *renderPass, SDL_GPUCommandBuffer *cmd) const
void drawWeaponPass (SDL_GPUTexture *sceneColor, SDL_GPUCommandBuffer *cmd)
void drawWorldModelInstances (SDL_GPURenderPass *renderPass, SDL_GPUCommandBuffer *cmd, bool depth, const FrustumPlanes &frustumPlanes)
void drawWeapon (SDL_GPURenderPass *geometryPass, SDL_GPUCommandBuffer *cmd, const FrustumPlanes &frustumPlanes)
void drawSkinnedModels (SDL_GPURenderPass *renderPass, SDL_GPUCommandBuffer *cmd)
void drawEntityChams (SDL_GPURenderPass *renderPass, SDL_GPUCommandBuffer *cmd, const FrustumPlanes &frustumPlanes)
void drawModel (ModelIdInt modelId, const glm::mat4 &modelTransform, SDL_GPURenderPass *renderPass, SDL_GPUCommandBuffer *cmd, const FrustumPlanes &frustumPlanes, glm::vec4 tint=glm::vec4{1.0f})
void drawModelDepth (ModelIdInt modelId, const glm::mat4 &modelTransform, SDL_GPURenderPass *renderPass, SDL_GPUCommandBuffer *cmd, const FrustumPlanes &frustumPlanes)
void drawEntityModels (SDL_GPURenderPass *renderPass, SDL_GPUCommandBuffer *cmd, bool depth, const FrustumPlanes &frustumPlanes)
void drawMesh (SDL_GPURenderPass *renderPass, const Asset::Mesh &mesh) const
void drawHud (SDL_GPURenderPass *pass)
bool loadLightMap ()

Static Private Member Functions

static bool inFrustum (const Asset::AABB &modelElementAABB, const FrustumPlanes &frustumPlanes, const glm::mat4 &modelMat)

Private Attributes

SDL_Window * window_ = nullptr
SDL_GPUDevice * device_ = nullptr
SDL_GPUShaderFormat shaderFormat_ = SDL_GPU_SHADERFORMAT_INVALID
SDL_GPUGraphicsPipeline * geometryPipeline_ = nullptr
SDL_GPUGraphicsPipeline * geometryLightMapPipeline_ = nullptr
SDL_GPUGraphicsPipeline * entityChamsPipeline_ = nullptr
SDL_GPUGraphicsPipeline * hudPipeline_ = nullptr
SDL_GPUGraphicsPipeline * fxaaPipeline_ = nullptr
SDL_GPUGraphicsPipeline * tonemapPipeline_ = nullptr
SDL_GPUGraphicsPipeline * ssaoPipeline_ = nullptr
SDL_GPUGraphicsPipeline * ssaoBlurPipeline_ = nullptr
SDL_GPUGraphicsPipeline * ssaoCompositePipeline_ = nullptr
SDL_GPUGraphicsPipeline * skinnedPipeline_ = nullptr
SDL_GPUGraphicsPipeline * depthRes0Pipeline_ = nullptr
SDL_GPUGraphicsPipeline * depthRes1Pipeline_ = nullptr
SDL_GPUGraphicsPipeline * depthRes2Pipeline_ = nullptr
SDL_GPUTextureFormat colorTarget_ = SDL_GPU_TEXTUREFORMAT_INVALID
SDL_GPUTexture * sceneColor_ = nullptr
SDL_GPUTexture * sceneNormal_ = nullptr
SDL_GPUTexture * ssaoColor_ = nullptr
SDL_GPUTexture * ssaoBlurred_ = nullptr
SDL_GPUTexture * sceneWithAo_ = nullptr
SDL_GPUTexture * tonemappedColor_ = nullptr
SDL_GPUTexture * lightMap_ = nullptr
SDL_GPUDepthStencilTargetInfo depthTarget_ {}
Uint32 sceneWidth_ = 0
Uint32 sceneHeight_ = 0
Uint32 ssaoWidth_ = 0
Uint32 ssaoHeight_ = 0
Uint32 depthWidth_ = 0
Uint32 depthHeight_ = 0
SDL_GPUTexture * texture_ = nullptr
SDL_GPUSampler * sampler_ = nullptr
SDL_GPUSampler * nearestSampler_ = nullptr
SDL_GPUTexture * hudTexture_ = nullptr
SDL_GPUSampler * hudSampler_ = nullptr
SDL_GPUSampler * fxaaSampler_ = nullptr
SDL_GPUTexture * dynamicShadowMaps_ = nullptr
SDL_GPUTexture * staticShadowMaps_ = nullptr
SDL_GPUSampler * staticDepthSampler_ = nullptr
SDL_GPUSampler * dynamicDepthSampler_ = nullptr
SDL_GPUTexture * movingLightShadowMaps_ = nullptr
glm::vec3 cubeFaceTargets_ [NUM_CUBE_FACES]
glm::vec3 cubeFaceUps_ [NUM_CUBE_FACES]
bool firstFrame_ = true
LightUBO sceneLightInfo_
NewCamera camera_
std::vector< EntityRenderCmdentities_
WeaponViewmodel weapon_ {}
ParticleSystemparticleSystem_ = nullptr
bool vsyncEnabled_ = true
std::string pendingScreenshotPath_
SkinnedRenderer skinnedRenderer_
float lastAcquireMs_ = 0.0f
float lastRecordMs_ = 0.0f
float lastSubmitMs_ = 0.0f

Static Private Attributes

static const uint32_t shadowSize = 1024
static const uint32_t macShadowSize = 512
static const uint32_t staticShadowSize = 2048

Detailed Description

Graphics-team's work-in-progress SDL3 GPU renderer.

Pass architecture (target — current implementation only covers a subset): Pass 0 — Shadow map (depth-only directional, cascaded) [TODO] Pass 1 — Skybox (procedural / cubemap) [TODO] Pass 2 — Geometry (static models + entity models + weapon) [partial] Pass 3 — Skinned chars (instanced GPU LBS for players) [TODO] Pass 4 — Particles (delegated to ParticleSystem::render) [TODO] Pass 5 — Post (SSAO/bloom/SSR/volumetrics/tonemap) [TODO] Pass 6 — HUD + ImGui [partial]

Shaders: shaders-new/geometry.{vert,frag} + shaders-new/hud.{vert,frag}. Graphics team adds new shaders alongside these as features come online.

Member Function Documentation

◆ bindLightShadowInfo()

void NewRenderer::bindLightShadowInfo ( SDL_GPURenderPass * renderPass,
SDL_GPUCommandBuffer * cmd,
bool lightmap )
private
Here is the caller graph for this function:

◆ createDepthPipeline()

SDL_GPUGraphicsPipeline * NewRenderer::createDepthPipeline ( const SDL_GPURasterizerState & rasterizer_state) const
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ createDepthRes0Pipeline()

bool NewRenderer::createDepthRes0Pipeline ( bool reverseZ)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ createDepthRes1Pipeline()

bool NewRenderer::createDepthRes1Pipeline ( bool reverseZ)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ createDepthRes2Pipeline()

bool NewRenderer::createDepthRes2Pipeline ( bool reverseZ)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ createEntityChamsPipeline()

bool NewRenderer::createEntityChamsPipeline ( )
private

Create the flat static-entity chams pipeline used for occluded powerup silhouettes.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ createFxaaPipeline()

bool NewRenderer::createFxaaPipeline ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ createGeometryLightMapPipeline()

bool NewRenderer::createGeometryLightMapPipeline ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ createGeometryPipeline()

bool NewRenderer::createGeometryPipeline ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ createHudPipeline()

bool NewRenderer::createHudPipeline ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ createMeshBuffers()

void NewRenderer::createMeshBuffers ( MeshIdInt meshId) const
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ createSsaoBlurPipeline()

bool NewRenderer::createSsaoBlurPipeline ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ createSsaoCompositePipeline()

bool NewRenderer::createSsaoCompositePipeline ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ createSsaoPipeline()

bool NewRenderer::createSsaoPipeline ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ createTonemapPipeline()

bool NewRenderer::createTonemapPipeline ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawEntityChams()

void NewRenderer::drawEntityChams ( SDL_GPURenderPass * renderPass,
SDL_GPUCommandBuffer * cmd,
const FrustumPlanes & frustumPlanes )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawEntityModels()

void NewRenderer::drawEntityModels ( SDL_GPURenderPass * renderPass,
SDL_GPUCommandBuffer * cmd,
bool depth,
const FrustumPlanes & frustumPlanes )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawFrame()

void NewRenderer::drawFrame ( glm::vec3 eye,
float yaw,
float pitch,
float roll )

Render one frame from the given camera pose.

Parameters
eyeCamera world position.
yawHorizontal rotation in radians.
pitchVertical rotation in radians.
rollCamera roll in radians (default 0).

Reads all per-frame state previously captured by set*() calls. Game code is expected to call every relevant setter BEFORE calling drawFrame.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawFxaaPass()

void NewRenderer::drawFxaaPass ( SDL_GPUTexture * sceneColor,
SDL_GPUTexture * swapchain,
SDL_GPUCommandBuffer * cmd )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawGeometryDepthPass()

void NewRenderer::drawGeometryDepthPass ( SDL_GPUTexture * depthTexture,
Uint8 res,
Uint8 layer,
SDL_GPUCommandBuffer * cmd,
const glm::mat4 & shadowViewProjection,
bool staticGeometry,
bool entityGeometry,
bool skinnedGeometry )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawGeometryOverlayPass()

void NewRenderer::drawGeometryOverlayPass ( SDL_GPUTexture * sceneColor,
SDL_GPUCommandBuffer * cmd )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawGeometryPass()

void NewRenderer::drawGeometryPass ( SDL_GPUTexture * sceneColor,
SDL_GPUCommandBuffer * cmd )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawHud()

void NewRenderer::drawHud ( SDL_GPURenderPass * pass)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawHudPass()

void NewRenderer::drawHudPass ( SDL_GPUTexture * target,
SDL_GPUCommandBuffer * cmd )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawMesh()

void NewRenderer::drawMesh ( SDL_GPURenderPass * renderPass,
const Asset::Mesh & mesh ) const
private
Here is the caller graph for this function:

◆ drawModel()

void NewRenderer::drawModel ( ModelIdInt modelId,
const glm::mat4 & modelTransform,
SDL_GPURenderPass * renderPass,
SDL_GPUCommandBuffer * cmd,
const FrustumPlanes & frustumPlanes,
glm::vec4 tint = glm::vec4{1.0f} )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawModelDepth()

void NewRenderer::drawModelDepth ( ModelIdInt modelId,
const glm::mat4 & modelTransform,
SDL_GPURenderPass * renderPass,
SDL_GPUCommandBuffer * cmd,
const FrustumPlanes & frustumPlanes )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawParticles()

void NewRenderer::drawParticles ( SDL_GPURenderPass * renderPass,
SDL_GPUCommandBuffer * cmd ) const
private
Here is the caller graph for this function:

◆ drawSkinnedModels()

void NewRenderer::drawSkinnedModels ( SDL_GPURenderPass * renderPass,
SDL_GPUCommandBuffer * cmd )
private
Here is the caller graph for this function:

◆ drawSsaoBlurPass()

void NewRenderer::drawSsaoBlurPass ( SDL_GPUTexture * ao,
SDL_GPUTexture * depth,
SDL_GPUTexture * normal,
SDL_GPUTexture * output,
SDL_GPUCommandBuffer * cmd )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawSsaoCompositePass()

void NewRenderer::drawSsaoCompositePass ( SDL_GPUTexture * sceneColor,
SDL_GPUTexture * rawAo,
SDL_GPUTexture * blurredAo,
SDL_GPUTexture * output,
SDL_GPUCommandBuffer * cmd )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawSsaoPass()

void NewRenderer::drawSsaoPass ( SDL_GPUTexture * depth,
SDL_GPUTexture * normal,
SDL_GPUTexture * ao,
SDL_GPUCommandBuffer * cmd )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawStaticLightmapGeometryPass()

void NewRenderer::drawStaticLightmapGeometryPass ( SDL_GPUTexture * sceneColor,
SDL_GPUCommandBuffer * cmd )
private

◆ drawTonemapPass()

void NewRenderer::drawTonemapPass ( SDL_GPUTexture * hdrSceneColor,
SDL_GPUTexture * ldrColor,
SDL_GPUCommandBuffer * cmd )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawToShadowMap()

void NewRenderer::drawToShadowMap ( SDL_GPUCommandBuffer * cmd,
SDL_GPUTexture * shadowMapTexture,
Uint8 res,
bool staticGeometry,
bool entityGeometry,
bool skinnedGeometry,
PointLightType lightType,
bool cullByCamera = true )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawUIPass()

void NewRenderer::drawUIPass ( SDL_GPUTexture * swapchain,
SDL_GPUCommandBuffer * cmd )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawWeapon()

void NewRenderer::drawWeapon ( SDL_GPURenderPass * geometryPass,
SDL_GPUCommandBuffer * cmd,
const FrustumPlanes & frustumPlanes )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawWeaponPass()

void NewRenderer::drawWeaponPass ( SDL_GPUTexture * sceneColor,
SDL_GPUCommandBuffer * cmd )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawWorldModelInstances()

void NewRenderer::drawWorldModelInstances ( SDL_GPURenderPass * renderPass,
SDL_GPUCommandBuffer * cmd,
bool depth,
const FrustumPlanes & frustumPlanes )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ensureDepthTextureSize()

bool NewRenderer::ensureDepthTextureSize ( Uint32 width,
Uint32 height )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ensureSceneTextureSize()

bool NewRenderer::ensureSceneTextureSize ( Uint32 width,
Uint32 height )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCamera()

const NewCamera & NewRenderer::getCamera ( ) const
inlinenodiscard

Current camera (updated every drawFrame call).

Game code reads this for projection-dependent operations: picking, reticle world-ray, frustum culling, etc. Caller must not mutate.

◆ getDevice()

SDL_GPUDevice * NewRenderer::getDevice ( ) const
inlinenodiscard

Returns the SDL GPU device.

Valid between init() and quit().

Used by sub-renderers (ParticleSystem, HudRenderer) and tests that need to allocate GPU resources on the same device.

Here is the caller graph for this function:

◆ getHdrFormat()

constexpr SDL_GPUTextureFormat NewRenderer::getHdrFormat ( )
inlinestaticnodiscardconstexpr

Legacy HDR colour render target format.

NewRenderer currently draws directly into the swapchain, so sub-renderers registered with it should use getSwapchainColorFormat(). Keep this for code paths that actually render into an HDR intermediate.

Here is the caller graph for this function:

◆ getLastAcquireMs()

float NewRenderer::getLastAcquireMs ( ) const
inlinenodiscard

Most-recent SDL_AcquireGPUCommandBuffer cost in milliseconds.

Captured by drawFrame(). Read by the debug HUD's frame-timing panel.

◆ getLastRecordMs()

float NewRenderer::getLastRecordMs ( ) const
inlinenodiscard

Most-recent command-recording cost (between acquire and submit) in ms.

◆ getLastSubmitMs()

float NewRenderer::getLastSubmitMs ( ) const
inlinenodiscard

Most-recent SDL_SubmitGPUCommandBuffer cost in milliseconds.

◆ getShaderFormat()

SDL_GPUShaderFormat NewRenderer::getShaderFormat ( ) const
inlinenodiscard

Shader format selected during init() (SPIR-V on Vulkan, MSL on Metal, DXIL on D3D12).

Sub-renderers consult this to pick the right precompiled shader binary.

◆ getSwapchainColorFormat()

SDL_GPUTextureFormat NewRenderer::getSwapchainColorFormat ( ) const
inlinenodiscard

Color format of the active swapchain render pass.

Sub-renderers that draw inside NewRenderer's main pass must create pipelines with this format so backends such as Metal can validate the pipeline against the render-pass texture.

◆ inFrustum()

bool NewRenderer::inFrustum ( const Asset::AABB & modelElementAABB,
const FrustumPlanes & frustumPlanes,
const glm::mat4 & modelMat )
staticprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init()

bool NewRenderer::init ( SDL_Window * window)

Initialise the GPU device, pipelines, and default scene assets.

Parameters
windowSDL window to render into.
Returns
True on success.
Here is the call graph for this function:

◆ loadHDRSkybox()

bool NewRenderer::loadHDRSkybox ( const std::string & path)

Load an equirectangular HDR image as the environment skybox + IBL source.

Parameters
pathAbsolute or assets-relative path to a .hdr file.
Returns
True on success.

IMPLEMENTATION: load via stb_image (float), upload as a 2D HDR texture, run an equirect→cubemap compute pass, derive the irradiance + prefilter cubemaps for IBL. Currently a no-op stub.

DATA SOURCE: debug UI's HDR picker — user selects from availableHDRFiles_.

◆ loadLightMap()

bool NewRenderer::loadLightMap ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadSceneModel()

int NewRenderer::loadSceneModel ( const char * filename,
glm::vec3 pos,
float scale,
bool flipUVs,
const std::string & excludeNodesContaining = "" )

Load a model from disk and register it in Asset::models_ + create a default scene instance.

Parameters
filenamePath under the assets dir.
posWorld position of the default scene instance.
scaleUniform scale of the default scene instance.
flipUVsTrue to flip V coordinate on import (glTF vs DCC convention).
excludeNodesContaining(Unused on main today.) Substring filter to drop collision-only nodes.
Returns
Index into Asset::modelInstances_ (-1 on failure). Game.cpp stashes this and uses it as a handle.

IMPLEMENTATION (real): delegates to AssetLoader::loadModel, then creates an Asset::ModelInstance at pos, then uploads mesh VB/IB. See cpp.

DATA SOURCE: Game.cpp's init phase, once per map asset.

Here is the call graph for this function:

◆ modelCount()

int NewRenderer::modelCount ( ) const
nodiscard

Number of models currently registered in the asset map.

Used by the debug UI to display loaded-model counts. Backed by Asset::models_, which is populated by loadSceneModel().

◆ onFirstFrame()

void NewRenderer::onFirstFrame ( SDL_GPUCommandBuffer * cmd)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ quit()

void NewRenderer::quit ( )

Release all GPU resources and shut down the renderer.

◆ requestScreenshot()

void NewRenderer::requestScreenshot ( const std::string & path)

Request a screenshot to be saved to disk after the next frame.

Parameters
pathOutput file path (PNG).

IMPLEMENTATION: after drawFrame's submit + present, read back the swapchain texture into a transfer buffer, map it CPU-side, write a PNG via stbi_write_png. Currently a no-op — pendingScreenshotPath_ is captured but not consumed.

DATA SOURCE: debug UI hotkey / console command.

◆ scanHDRFiles()

void NewRenderer::scanHDRFiles ( )

Scan the assets HDR directory and populate availableHDRFiles_.

IMPLEMENTATION: iterate assets/hdr/*.hdr via std::filesystem, fill the vector with the paths. Currently a no-op.

DATA SOURCE: called once at init; debug UI reads availableHDRFiles_ to populate its dropdown.

◆ setEntityRenderList()

void NewRenderer::setEntityRenderList ( std::vector< EntityRenderCmd > && entityList)

Set the list of entity render commands for this frame.

Parameters
entityListOne entry per visible static/dynamic entity. Moved-in.

IMPLEMENTATION: Currently captures into entities_ and the existing drawEntityModels() loop draws them with the geometry pipeline. When adding lighting/tinting/material variation this is the call site whose data needs to surface in the shader.

DATA SOURCE: built in Game.cpp's draw-list builder from ECS view <Position, Velocity, Renderable, ...> per frame.

◆ setHudTexture()

void NewRenderer::setHudTexture ( SDL_GPUTexture * hudTexture)

Set the HUD overlay texture to blit after the geometry pass.

Parameters
hudTextureHUD's final colour texture (RGBA8 swap-chain-format). May be null = no HUD.

IMPLEMENTATION (real): captured into hudTexture_; drawHud() samples it in the UI pass. Sampling is linear repeat via hudSampler_.

DATA SOURCE: Hud::getOutputTexture() after Hud::draw() populates it.

◆ setMainCamera()

void NewRenderer::setMainCamera ( glm::vec3 eye,
float yaw,
float pitch,
float roll,
Uint32 width,
Uint32 height,
float fov )
private
Here is the caller graph for this function:

◆ setModelEmissive()

void NewRenderer::setModelEmissive ( int32_t modelIdUnsanitized,
glm::vec4 emissiveColor )

Override the emissive colour of every mesh in a registered model.

Parameters
modelIdUnsanitizedIndex returned by loadSceneModel/uploadSceneModel.
emissiveColorRGB = emissive linear colour, A = ignored.

IMPLEMENTATION: store overrides keyed by modelIndex in a map; consult the map when building per-mesh material UBOs inside drawModel(). Currently a no-op.

DATA SOURCE: Game.cpp uses this to pulse beam/cylinder/sphere glow (Game.cpp legacy: renderer.setModelEmissive(glowCylinderModelIdx_, ...)).

◆ setModelScenePass()

void NewRenderer::setModelScenePass ( int32_t modelIndex,
bool drawInScene )

Toggle whether a model is drawn during the scene pass.

Parameters
modelIndexRenderer-side handle.
drawInScenetrue = draw as static world geometry; false = only via EntityRenderCmd.

IMPLEMENTATION: sets Asset::ModelInstance::drawInScenePass on every instance backed by modelIndex. The scene-pass loop in drawWorldModelInstances already honours this flag.

DATA SOURCE: Game.cpp calls this once per static map asset right after loadSceneModel.

◆ setParticleSystem()

void NewRenderer::setParticleSystem ( ParticleSystem * ps)

Register the particle system so the renderer can call its render hooks.

Parameters
psPointer to ParticleSystem owned by Game. May be null = disable particles.

IMPLEMENTATION: store in particleSystem_. During drawFrame, the renderer should call (in this order, inside the main HDR pass): ps->uploadToGpu(cmd); // BEFORE the render pass begins ps->render(pass, cmd); // INSIDE the HDR render pass Currently a no-op pointer-only stub.

DATA SOURCE: Game.cpp owns the ParticleSystem instance and registers it once after particleSystem.init(...) succeeds.

◆ setPointLights()

void NewRenderer::setPointLights ( std::vector< PointLight > pointLights)

Set dynamic point lights for this frame.

Parameters
pointLightsUp to ~6 lights; renderer may cap silently.

IMPLEMENTATION: store in pointLights_, then push as a UBO array to the PBR fragment shader during the geometry pass. Currently a no-op stub — pointLights_ is captured but never read.

DATA SOURCE: built in Game.cpp from ECS each frame (glow-emitting projectiles, muzzle flashes, etc).

◆ setRig()

bool NewRenderer::setRig ( const std::vector< RigMeshSource > & meshes,
int numJoints )

◆ setSkinnedFrame()

void NewRenderer::setSkinnedFrame ( const std::vector< glm::mat4 > & palette,
const std::vector< SkinnedInstance > & instances )

◆ setStaticPointLights()

void NewRenderer::setStaticPointLights ( std::vector< PointLight > && pointLights)
Here is the caller graph for this function:

◆ setVSync()

bool NewRenderer::setVSync ( bool enabled)

Enable or disable vertical sync.

Parameters
enabledTrue = VSync on (capped at refresh rate); false = uncapped.
Returns
True on success.

IMPLEMENTATION: call SDL_SetGPUSwapchainParameters with SDL_GPU_PRESENTMODE_VSYNC vs SDL_GPU_PRESENTMODE_IMMEDIATE (or MAILBOX for adaptive). Currently a no-op — stores vsyncEnabled_ but doesn't apply.

DATA SOURCE: Game.cpp toggles this when entering/leaving menus or via debug UI.

◆ setWeaponViewmodel()

void NewRenderer::setWeaponViewmodel ( const WeaponViewmodel & vm)

Set the first-person weapon viewmodel for this frame.

Parameters
vmModel handle + viewmodel-space transform + visibility.

IMPLEMENTATION: Captured into weapon_. drawWeapon() reads it and issues a draw call with the existing geometry pipeline. Note: the viewmodel is drawn LAST so it sits on top of the world (no depth fighting with map geometry near the camera).

DATA SOURCE: Game.cpp's runWeaponViewmodel() step, which composes the transform from camera state + recoil/sway curves.

◆ skinned() [1/2]

SkinnedRenderer & NewRenderer::skinned ( )
inlinenodiscard

Accessor for the skinned-character subsystem.

Use to register the shared rig once at startup, and to push the per- frame palette + instance arrays each frame. See SkinnedRenderer.hpp for the full API + data-flow notes.

◆ skinned() [2/2]

const SkinnedRenderer & NewRenderer::skinned ( ) const
inlinenodiscard

◆ updateModelMeshVertices()

void NewRenderer::updateModelMeshVertices ( int modelIndex,
int meshIndex,
const Vertex * vertices,
Uint32 vertexCount )

Queue a vertex-buffer re-upload for one mesh of a loaded model.

Parameters
modelIndexRenderer-side model handle.
meshIndexMesh index within that model.
verticesNew vertex data (caller retains ownership — copy if needed).
vertexCountNumber of vertices in vertices.

IMPLEMENTATION: legacy used this for CPU-skinning entity meshes (now superseded by setSkinnedFrame). May not need to come back; leave as a no-op stub for API parity. If a use-case re-emerges, do the copy inside the next drawFrame's copy pass.

DATA SOURCE: legacy CPU LBS path (now defunct). No current call site.

Member Data Documentation

◆ ambientColorMultiplier

float NewRenderer::ambientColorMultiplier = 1.0f

Scales the geometry shader ambient colour contribution.

◆ availableHDRFiles

std::vector<std::string> NewRenderer::availableHDRFiles

Filled by scanHDRFiles(); consumed by debug UI.

◆ camera_

NewCamera NewRenderer::camera_
private

◆ colorTarget_

SDL_GPUTextureFormat NewRenderer::colorTarget_ = SDL_GPU_TEXTUREFORMAT_INVALID
private

◆ cubeFaceTargets_

glm::vec3 NewRenderer::cubeFaceTargets_[NUM_CUBE_FACES]
private

◆ cubeFaceUps_

glm::vec3 NewRenderer::cubeFaceUps_[NUM_CUBE_FACES]
private

◆ currentHDRName

std::string NewRenderer::currentHDRName = "(procedural)"

Display name of the currently-loaded HDR.

◆ depthHeight_

Uint32 NewRenderer::depthHeight_ = 0
private

◆ depthRes0Pipeline_

SDL_GPUGraphicsPipeline* NewRenderer::depthRes0Pipeline_ = nullptr
private

◆ depthRes1Pipeline_

SDL_GPUGraphicsPipeline* NewRenderer::depthRes1Pipeline_ = nullptr
private

◆ depthRes2Pipeline_

SDL_GPUGraphicsPipeline* NewRenderer::depthRes2Pipeline_ = nullptr
private

◆ depthTarget_

SDL_GPUDepthStencilTargetInfo NewRenderer::depthTarget_ {}
private

◆ depthWidth_

Uint32 NewRenderer::depthWidth_ = 0
private

◆ device_

SDL_GPUDevice* NewRenderer::device_ = nullptr
private

◆ dynamicDepthSampler_

SDL_GPUSampler* NewRenderer::dynamicDepthSampler_ = nullptr
private

◆ dynamicShadowMaps_

SDL_GPUTexture* NewRenderer::dynamicShadowMaps_ = nullptr
private

◆ entities_

std::vector<EntityRenderCmd> NewRenderer::entities_
private

◆ entityChamsPipeline_

SDL_GPUGraphicsPipeline* NewRenderer::entityChamsPipeline_ = nullptr
private

◆ firstFrame_

bool NewRenderer::firstFrame_ = true
private

◆ fxaaPipeline_

SDL_GPUGraphicsPipeline* NewRenderer::fxaaPipeline_ = nullptr
private

◆ fxaaSampler_

SDL_GPUSampler* NewRenderer::fxaaSampler_ = nullptr
private

◆ geometryLightMapPipeline_

SDL_GPUGraphicsPipeline* NewRenderer::geometryLightMapPipeline_ = nullptr
private

◆ geometryPipeline_

SDL_GPUGraphicsPipeline* NewRenderer::geometryPipeline_ = nullptr
private

◆ hdrExposure

float NewRenderer::hdrExposure = 1.0f

Debug exposure multiplier used by the tonemap pass.

◆ hdrWhitePoint

float NewRenderer::hdrWhitePoint = 4.0f

Debug white point for Extended Reinhard tonemapping.

◆ hudPipeline_

SDL_GPUGraphicsPipeline* NewRenderer::hudPipeline_ = nullptr
private

◆ hudSampler_

SDL_GPUSampler* NewRenderer::hudSampler_ = nullptr
private

◆ hudTexture_

SDL_GPUTexture* NewRenderer::hudTexture_ = nullptr
private

◆ imguiEnabled

bool NewRenderer::imguiEnabled = true

Master toggle for the ImGui debug overlay.

◆ lastAcquireMs_

float NewRenderer::lastAcquireMs_ = 0.0f
private

◆ lastRecordMs_

float NewRenderer::lastRecordMs_ = 0.0f
private

◆ lastSubmitMs_

float NewRenderer::lastSubmitMs_ = 0.0f
private

◆ lightIntensityMultiplier

float NewRenderer::lightIntensityMultiplier = 8.0f

Scales direct geometry light intensity.

◆ lightMap_

SDL_GPUTexture* NewRenderer::lightMap_ = nullptr
private

◆ macShadowSize

const uint32_t NewRenderer::macShadowSize = 512
staticprivate

◆ mainHorizontalFovDegrees

float NewRenderer::mainHorizontalFovDegrees = 110.0f

Main camera horizontal field of view in degrees.

◆ metallicTextureStrength

float NewRenderer::metallicTextureStrength = 0.5f

Scales sampled metallic texture values before lighting.

◆ movingLightShadowMaps_

SDL_GPUTexture* NewRenderer::movingLightShadowMaps_ = nullptr
private

◆ nearestSampler_

SDL_GPUSampler* NewRenderer::nearestSampler_ = nullptr
private

◆ particleSystem_

ParticleSystem* NewRenderer::particleSystem_ = nullptr
private

◆ pendingScreenshotPath_

std::string NewRenderer::pendingScreenshotPath_
private

◆ renderScale

float NewRenderer::renderScale = 1.0f

Internal-resolution multiplier (0.5 = half-res, 2.0 = SSAA).

◆ roughnessTextureStrength

float NewRenderer::roughnessTextureStrength = 1.0f

Scales sampled roughness texture values before lighting.

◆ sampler_

SDL_GPUSampler* NewRenderer::sampler_ = nullptr
private

◆ sceneColor_

SDL_GPUTexture* NewRenderer::sceneColor_ = nullptr
private

◆ sceneHeight_

Uint32 NewRenderer::sceneHeight_ = 0
private

◆ sceneLightInfo_

LightUBO NewRenderer::sceneLightInfo_
private

◆ sceneNormal_

SDL_GPUTexture* NewRenderer::sceneNormal_ = nullptr
private

◆ sceneWidth_

Uint32 NewRenderer::sceneWidth_ = 0
private

◆ sceneWithAo_

SDL_GPUTexture* NewRenderer::sceneWithAo_ = nullptr
private

◆ scopeZoom

float NewRenderer::scopeZoom = 1.0f

Per-frame scope zoom multiplier (FOV divisor).

1.0 = no zoom; 1.5 = ADS through the charge rifle scope (FOV/1.5). Game.cpp drives this each frame from the local player's ADS state.

◆ shaderFormat_

SDL_GPUShaderFormat NewRenderer::shaderFormat_ = SDL_GPU_SHADERFORMAT_INVALID
private

◆ shadowSize

const uint32_t NewRenderer::shadowSize = 1024
staticprivate

◆ skinnedPipeline_

SDL_GPUGraphicsPipeline* NewRenderer::skinnedPipeline_ = nullptr
private

◆ skinnedRenderer_

SkinnedRenderer NewRenderer::skinnedRenderer_
private

◆ ssaoBias

float NewRenderer::ssaoBias = 1.5f

World-space self-occlusion bias.

◆ ssaoBlurDepthThreshold

float NewRenderer::ssaoBlurDepthThreshold = 0.3f

Blur world-distance rejection as a fraction of AO radius.

◆ ssaoBlurEnabled

bool NewRenderer::ssaoBlurEnabled = true

Use the depth/normal-aware AO blur.

◆ ssaoBlurNormalThreshold

float NewRenderer::ssaoBlurNormalThreshold = 0.6f

Minimum normal dot for AO blur samples.

◆ ssaoBlurPipeline_

SDL_GPUGraphicsPipeline* NewRenderer::ssaoBlurPipeline_ = nullptr
private

◆ ssaoBlurRadius

float NewRenderer::ssaoBlurRadius = 1.0f

Multiplier for the fixed 5x5 AO blur offsets.

◆ ssaoBlurred_

SDL_GPUTexture* NewRenderer::ssaoBlurred_ = nullptr
private

◆ ssaoBlurStrength

float NewRenderer::ssaoBlurStrength = 1.0f

Blend amount from raw AO to blurred AO.

◆ ssaoColor_

SDL_GPUTexture* NewRenderer::ssaoColor_ = nullptr
private

◆ ssaoCompositePipeline_

SDL_GPUGraphicsPipeline* NewRenderer::ssaoCompositePipeline_ = nullptr
private

◆ ssaoCompositePower

float NewRenderer::ssaoCompositePower = 2.0f

AO exponent before composition.

◆ ssaoCompositeStrength

float NewRenderer::ssaoCompositeStrength = 1.0f

AO application strength before tonemapping.

◆ ssaoContactWeight

float NewRenderer::ssaoContactWeight = 1.0f

Tight contact AO band weight.

◆ ssaoDebugView

int NewRenderer::ssaoDebugView = 0

0 final scene, 1 raw AO.

◆ ssaoDepthThreshold

float NewRenderer::ssaoDepthThreshold = 0.01f

Max depth-buffer delta accepted for contact AO samples.

◆ ssaoHeight_

Uint32 NewRenderer::ssaoHeight_ = 0
private

◆ ssaoHemisphereMin

float NewRenderer::ssaoHemisphereMin = 0.05f

Minimum normal-facing direction for AO samples.

◆ ssaoIntensity

float NewRenderer::ssaoIntensity = 1.0f

Raw AO occlusion multiplier.

◆ ssaoMaxAo

float NewRenderer::ssaoMaxAo = 1.0f

Brightest raw AO value.

◆ ssaoMediumRadius

float NewRenderer::ssaoMediumRadius = 48.0f

Medium-radius crease/corner AO band.

◆ ssaoMediumWeight

float NewRenderer::ssaoMediumWeight = 0.25f

Medium AO band weight.

◆ ssaoMinAo

float NewRenderer::ssaoMinAo = 0.45f

Darkest raw AO value.

◆ ssaoNormalDiffMax

float NewRenderer::ssaoNormalDiffMax = 0.55f

Normal-difference full weight for crease/contact weighting.

◆ ssaoNormalDiffMin

float NewRenderer::ssaoNormalDiffMin = 0.12f

Normal-difference start for crease/contact weighting.

◆ ssaoPipeline_

SDL_GPUGraphicsPipeline* NewRenderer::ssaoPipeline_ = nullptr
private

◆ ssaoPixelRadiusScale

float NewRenderer::ssaoPixelRadiusScale = 0.35f

Converts AO radius to screen-space sample spacing.

◆ ssaoRadius

float NewRenderer::ssaoRadius = 24.0f

World-space AO sampling radius.

◆ ssaoWidth_

Uint32 NewRenderer::ssaoWidth_ = 0
private

◆ staticDepthSampler_

SDL_GPUSampler* NewRenderer::staticDepthSampler_ = nullptr
private

◆ staticShadowMaps_

SDL_GPUTexture* NewRenderer::staticShadowMaps_ = nullptr
private

◆ staticShadowSize

const uint32_t NewRenderer::staticShadowSize = 2048
staticprivate

◆ texture_

SDL_GPUTexture* NewRenderer::texture_ = nullptr
private

◆ toggles

RenderToggles NewRenderer::toggles {}

Per-pass on/off toggles (see RenderToggles in RendererTypes.hpp).

◆ tonemappedColor_

SDL_GPUTexture* NewRenderer::tonemappedColor_ = nullptr
private

◆ tonemapPipeline_

SDL_GPUGraphicsPipeline* NewRenderer::tonemapPipeline_ = nullptr
private

◆ useHDRSkybox

bool NewRenderer::useHDRSkybox = false

True after a successful loadHDRSkybox().

◆ vsyncEnabled_

bool NewRenderer::vsyncEnabled_ = true
private

◆ weapon_

WeaponViewmodel NewRenderer::weapon_ {}
private

◆ window_

SDL_Window* NewRenderer::window_ = nullptr
private

The documentation for this class was generated from the following files: