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

Forward-declared to avoid circular includes. More...

#include <Renderer.hpp>

Inheritance diagram for Renderer:
[legend]
Collaboration diagram for Renderer:
[legend]

Public Member Functions

bool supports (RendererFeature) const override
 Report which RendererFeature entries this renderer implements.
 
bool init (SDL_Window *window) override
 Initialise the GPU device, pipelines, and default scene assets.
 
void drawFrame (glm::vec3 eye, float yaw, float pitch, float roll) override
 Render one frame from the given camera pose.
 
void requestScreenshot (const std::string &path) override
 Queue a screenshot to be saved after the next frame.
 
bool setVSync (bool enabled) override
 Enable or disable vertical sync.
 
void quit () override
 Release all GPU resources and shut down the renderer.
 
void setParticleSystem (ParticleSystem *ps) override
 Register a particle system to be rendered each frame (after scene, before ImGui).
 
SDL_GPUDevice * getDevice () const override
 Returns the SDL GPU device. Valid between init() and quit().
 
const CameragetCamera () const override
 Returns the current camera (updated every drawFrame call).
 
SDL_GPUShaderFormat getShaderFormat () const override
 Shader format selected during init() (SPIR-V or MSL).
 
void setEntityRenderList (std::vector< EntityRenderCmd > cmds) override
 Set the list of entity render commands for this frame.
 
void setPointLights (std::vector< PointLight > lights) override
 Set dynamic point lights for this frame.
 
void setModelEmissive (int modelIndex, glm::vec4 emissiveFactor) override
 Update the emissive factor on every mesh of a loaded model.
 
void setWeaponViewmodel (const WeaponViewmodel &vm) override
 Set the first-person weapon viewmodel for this frame.
 
int loadSceneModel (const char *filename, glm::vec3 pos, float scale, bool flipUVs=false) override
 Load a model and return its index in the models[] vector, or -1 on failure.
 
int uploadSceneModel (const LoadedModel &model) override
 Upload a pre-built LoadedModel (e.g. from CharacterRig::templateLoadedModel()) and return its index.
 
void updateModelMeshVertices (int modelIndex, int meshIndex, const ModelVertex *vertices, Uint32 vertexCount) override
 Queue a skinned vertex re-upload for one mesh of an animated model.
 
int modelCount () const override
 Returns the number of loaded models.
 
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.
 
glm::vec3 getSunDirection () const
 Compute the sun direction (unit vector TO sun) from azimuth/elevation.
 
- Public Member Functions inherited from IRenderer
virtual ~IRenderer ()=default
 

Static Public Member Functions

static constexpr SDL_GPUTextureFormat getHdrFormat ()
 HDR render target format (RGBA16F). Particle pipelines must match this.
 

Public Attributes

std::vector< std::string > availableHDRFiles
 Available HDR file paths (populated by scanHDRFiles).
 
std::string currentHDRName = "(procedural)"
 Currently loaded HDR file (display name).
 
bool useHDRSkybox = false
 True when an HDR cubemap is loaded and should be used for skybox + IBL.
 
int ssrMode = 2
 0=Sharp, 1=Stochastic, 2=Masked (default).
 
RenderToggles toggles
 Live-tunable feature toggles (checked every frame).
 
AAMode aaMode = AAMode::SMAA_T2x
 Current AA mode (default: recommended T2x).
 
bool casEnabled = true
 CAS sharpening on/off.
 
float casStrength = 1.0f
 CAS sharpness (0.0 = minimal, 1.0 = max).
 
float sunAzimuth = 210.0f
 Degrees, 0=North, 90=East, 180=South (default ~SSW).
 
float sunElevation = 60.0f
 Degrees above horizon (default 60° ≈ 11am).
 
float sunIntensity = 3.0f
 Primary directional light intensity.
 
float fillIntensity = 0.8f
 Fill/bounce light intensity.
 
float ambientR = 0.08f
 
float ambientG = 0.09f
 
float ambientB = 0.12f
 PBR ambient color.
 
float iblDiffuseIntensity = 1.0f
 Multiplier on IBL diffuse term.
 
float iblSpecularIntensity = 0.5f
 Multiplier on IBL specular term – default below 1.0 to tame the over-glossy / pseudo-metallic look dielectric surfaces get from real-world HDR environment maps.
 
float bloomStr = 0.3f
 Bloom compositing strength.
 
float ssaoStr = 0.8f
 SSAO compositing strength.
 
float ssaoRadius = 0.8f
 GTAO world-space radius.
 
float ssaoFalloff = 2.0f
 GTAO distance falloff exponent.
 
float ssaoPower = 1.5f
 AO power curve (1=linear, higher=softer).
 
float ssrStr = 0.4f
 SSR compositing strength.
 
float volStr = 0.15f
 Volumetric compositing strength.
 
float sharpenStr = 0.6f
 Post-TAA sharpening strength.
 
float shadowBiasVal = 0.0005f
 
float shadowNormalBiasVal = 1.5f
 
float shadowDistance = 3000.0f
 Max shadow range (world units).
 
float cascadeLambda = 0.92f
 Log vs linear cascade split blend (0=linear, 1=log).
 

Detailed Description

Forward-declared to avoid circular includes.

SDL3 GPU renderer – forward PBR pipeline with HDR + tone mapping.

Render-pass architecture: Pass 0 – Shadow map (depth-only from directional light, cascaded) Pass 1 – Main colour pass (forward PBR into HDR render target)

  • Skybox (procedural gradient / cubemap)
  • Scene geometry (hard-coded cube + floor)
  • Loaded model (Assimp GLB meshes) Pass 2 – Tone mapping (HDR -> LDR swapchain) + ImGui overlay

Also owns the imgui_impl_sdlgpu3 render backend. The ImGui context and SDL3 input backend are owned by DebugUI – initialise DebugUI first.

SDL3 GPU renderer with forward PBR pipeline.

Member Function Documentation

◆ drawFrame()

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

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).

< Per-cascade light VP.

< For view-space Z.

< Cascade far distances.

< Per-cascade resolution.

Implements IRenderer.

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

◆ getCamera()

const Camera & Renderer::getCamera ( ) const
inlineoverridevirtual

Returns the current camera (updated every drawFrame call).

Implements IRenderer.

Here is the caller graph for this function:

◆ getDevice()

SDL_GPUDevice * Renderer::getDevice ( ) const
inlineoverridevirtual

Returns the SDL GPU device. Valid between init() and quit().

Implements IRenderer.

Here is the caller graph for this function:

◆ getHdrFormat()

static constexpr SDL_GPUTextureFormat Renderer::getHdrFormat ( )
inlinestaticconstexpr

HDR render target format (RGBA16F). Particle pipelines must match this.

Here is the caller graph for this function:

◆ getShaderFormat()

SDL_GPUShaderFormat Renderer::getShaderFormat ( ) const
inlineoverridevirtual

Shader format selected during init() (SPIR-V or MSL).

Implements IRenderer.

Here is the caller graph for this function:

◆ getSunDirection()

glm::vec3 Renderer::getSunDirection ( ) const

Compute the sun direction (unit vector TO sun) from azimuth/elevation.

Returns
Normalised direction vector pointing toward the sun.
Here is the caller graph for this function:

◆ init()

bool Renderer::init ( SDL_Window *  window)
overridevirtual

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

Parameters
windowSDL window to render into.
Returns
True on success.

Implements IRenderer.

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

◆ loadHDRSkybox()

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

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

Here is the caller graph for this function:

◆ loadSceneModel()

int Renderer::loadSceneModel ( const char *  filename,
glm::vec3  pos,
float  scale,
bool  flipUVs = false 
)
overridevirtual

Load a model and return its index in the models[] vector, or -1 on failure.

Implements IRenderer.

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

◆ modelCount()

int Renderer::modelCount ( ) const
inlineoverridevirtual

Returns the number of loaded models.

Implements IRenderer.

Here is the caller graph for this function:

◆ quit()

void Renderer::quit ( )
overridevirtual

Release all GPU resources and shut down the renderer.

Implements IRenderer.

Here is the caller graph for this function:

◆ requestScreenshot()

void Renderer::requestScreenshot ( const std::string &  path)
overridevirtual

Queue a screenshot to be saved after the next frame.

Parameters
pathOutput file path (PNG).

Implements IRenderer.

Here is the caller graph for this function:

◆ scanHDRFiles()

void Renderer::scanHDRFiles ( )

Scan the assets HDR directory and populate availableHDRFiles.

Here is the caller graph for this function:

◆ setEntityRenderList()

void Renderer::setEntityRenderList ( std::vector< EntityRenderCmd cmds)
inlineoverridevirtual

Set the list of entity render commands for this frame.

Implements IRenderer.

Here is the caller graph for this function:

◆ setModelEmissive()

void Renderer::setModelEmissive ( int  modelIndex,
glm::vec4  emissiveFactor 
)
inlineoverridevirtual

Update the emissive factor on every mesh of a loaded model.

Takes effect on the next drawFrame — the material UBO is pushed from CPU each frame, so no GPU re-upload is needed.

Implements IRenderer.

Here is the caller graph for this function:

◆ setParticleSystem()

void Renderer::setParticleSystem ( ParticleSystem ps)
inlineoverridevirtual

Register a particle system to be rendered each frame (after scene, before ImGui).

Implements IRenderer.

Here is the caller graph for this function:

◆ setPointLights()

void Renderer::setPointLights ( std::vector< PointLight lights)
inlineoverridevirtual

Set dynamic point lights for this frame.

Up to 6 point lights are supported (the UBO has 8 slots; 2 are reserved for the directional sun + fill). Excess lights are silently dropped.

Implements IRenderer.

Here is the caller graph for this function:

◆ setVSync()

bool Renderer::setVSync ( bool  enabled)
overridevirtual

Enable or disable vertical sync.

Parameters
enabledTrue for VSync, false for uncapped.
Returns
True on success.

Implements IRenderer.

Here is the caller graph for this function:

◆ setWeaponViewmodel()

void Renderer::setWeaponViewmodel ( const WeaponViewmodel vm)
inlineoverridevirtual

Set the first-person weapon viewmodel for this frame.

Implements IRenderer.

Here is the caller graph for this function:

◆ supports()

bool Renderer::supports ( RendererFeature  ) const
inlineoverridevirtual

Report which RendererFeature entries this renderer implements.

The legacy renderer implements all of them.

Implements IRenderer.

◆ updateModelMeshVertices()

void Renderer::updateModelMeshVertices ( int  modelIndex,
int  meshIndex,
const ModelVertex vertices,
Uint32  vertexCount 
)
overridevirtual

Queue a skinned vertex re-upload for one mesh of an animated model.

The actual GPU copy is deferred to the next drawFrame() command buffer – no separate command submission, no pipeline stall.

Parameters
modelIndexIndex into the models[] vector.
meshIndexIndex into the model's meshes[] vector.
verticesNew vertex data.
vertexCountNumber of vertices.

Implements IRenderer.

Here is the caller graph for this function:

◆ uploadSceneModel()

int Renderer::uploadSceneModel ( const LoadedModel model)
overridevirtual

Upload a pre-built LoadedModel (e.g. from CharacterRig::templateLoadedModel()) and return its index.

Implements IRenderer.

Here is the caller graph for this function:

Member Data Documentation

◆ aaMode

AAMode Renderer::aaMode = AAMode::SMAA_T2x

Current AA mode (default: recommended T2x).

◆ ambientB

float Renderer::ambientB = 0.12f

PBR ambient color.

◆ ambientG

float Renderer::ambientG = 0.09f

◆ ambientR

float Renderer::ambientR = 0.08f

◆ availableHDRFiles

std::vector<std::string> Renderer::availableHDRFiles

Available HDR file paths (populated by scanHDRFiles).

◆ bloomStr

float Renderer::bloomStr = 0.3f

Bloom compositing strength.

◆ cascadeLambda

float Renderer::cascadeLambda = 0.92f

Log vs linear cascade split blend (0=linear, 1=log).

◆ casEnabled

bool Renderer::casEnabled = true

CAS sharpening on/off.

◆ casStrength

float Renderer::casStrength = 1.0f

CAS sharpness (0.0 = minimal, 1.0 = max).

◆ currentHDRName

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

Currently loaded HDR file (display name).

◆ fillIntensity

float Renderer::fillIntensity = 0.8f

Fill/bounce light intensity.

◆ iblDiffuseIntensity

float Renderer::iblDiffuseIntensity = 1.0f

Multiplier on IBL diffuse term.

◆ iblSpecularIntensity

float Renderer::iblSpecularIntensity = 0.5f

Multiplier on IBL specular term – default below 1.0 to tame the over-glossy / pseudo-metallic look dielectric surfaces get from real-world HDR environment maps.

◆ shadowBiasVal

float Renderer::shadowBiasVal = 0.0005f

◆ shadowDistance

float Renderer::shadowDistance = 3000.0f

Max shadow range (world units).

◆ shadowNormalBiasVal

float Renderer::shadowNormalBiasVal = 1.5f

◆ sharpenStr

float Renderer::sharpenStr = 0.6f

Post-TAA sharpening strength.

◆ ssaoFalloff

float Renderer::ssaoFalloff = 2.0f

GTAO distance falloff exponent.

◆ ssaoPower

float Renderer::ssaoPower = 1.5f

AO power curve (1=linear, higher=softer).

◆ ssaoRadius

float Renderer::ssaoRadius = 0.8f

GTAO world-space radius.

◆ ssaoStr

float Renderer::ssaoStr = 0.8f

SSAO compositing strength.

◆ ssrMode

int Renderer::ssrMode = 2

0=Sharp, 1=Stochastic, 2=Masked (default).

◆ ssrStr

float Renderer::ssrStr = 0.4f

SSR compositing strength.

◆ sunAzimuth

float Renderer::sunAzimuth = 210.0f

Degrees, 0=North, 90=East, 180=South (default ~SSW).

◆ sunElevation

float Renderer::sunElevation = 60.0f

Degrees above horizon (default 60° ≈ 11am).

◆ sunIntensity

float Renderer::sunIntensity = 3.0f

Primary directional light intensity.

◆ toggles

RenderToggles Renderer::toggles

Live-tunable feature toggles (checked every frame).

◆ useHDRSkybox

bool Renderer::useHDRSkybox = false

True when an HDR cubemap is loaded and should be used for skybox + IBL.

◆ volStr

float Renderer::volStr = 0.15f

Volumetric compositing strength.


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