group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
NewRenderer.hpp
Go to the documentation of this file.
1
14
15#pragma once
16
17#include "Asset.hpp"
18#include "Boilerplate.hpp"
19#include "Camera.hpp"
20#include "RendererTypes.hpp"
21#include "SkinnedRenderer.hpp"
22
23#include <SDL3/SDL.h>
24#include <SDL3/SDL_gpu.h>
25
26#include <glm/glm.hpp>
27#include <queue>
28#include <string>
29#include <vector>
30
31#define NUM_CUBE_FACES 6
32class ParticleSystem;
33
39struct Vertex
40{
41 glm::vec3 position;
42 glm::vec3 normal;
43 glm::vec2 texUV;
44 glm::vec4 tangent;
45 glm::vec2 lightMapUV;
46};
47
48enum class PointLightType : std::uint8_t
49{
54};
55
69
83{
84public:
85 // ─── Lifecycle ───────────────────────────────────────────────────────────
86
90 bool init(SDL_Window* window);
91
100 void drawFrame(glm::vec3 eye, float yaw, float pitch, float roll);
101
103 void quit();
104
105 // ─── Readback (must return real values — gameplay depends on them) ───────
106
111 [[nodiscard]] SDL_GPUDevice* getDevice() const { return device_; }
112
116 [[nodiscard]] SDL_GPUShaderFormat getShaderFormat() const { return shaderFormat_; }
117
123 [[nodiscard]] SDL_GPUTextureFormat getSwapchainColorFormat() const { return colorTarget_; }
124
129 [[nodiscard]] const NewCamera& getCamera() const { return camera_; }
130
135 [[nodiscard]] int modelCount() const;
136
142 [[nodiscard]] static constexpr SDL_GPUTextureFormat getHdrFormat()
143 {
144 return SDL_GPU_TEXTUREFORMAT_R16G16B16A16_FLOAT;
145 }
146
150 [[nodiscard]] float getLastAcquireMs() const { return lastAcquireMs_; }
151
153 [[nodiscard]] float getLastRecordMs() const { return lastRecordMs_; }
154
156 [[nodiscard]] float getLastSubmitMs() const { return lastSubmitMs_; }
157
158 // ─── Per-frame submit setters (data-capture stubs) ───────────────────────
159 //
160 // Called by Game.cpp every frame BEFORE drawFrame. Each stores the
161 // payload into a member field; drawFrame reads it. Currently most of
162 // these have no consumer — the data is captured but nothing renders.
163
174 void setEntityRenderList(std::vector<EntityRenderCmd>&& entityList);
175
185 void setPointLights(std::vector<PointLight> pointLights);
186 void setStaticPointLights(std::vector<PointLight>&& pointLights);
187
198 void setWeaponViewmodel(const WeaponViewmodel& vm);
199
210 void setModelEmissive(int32_t modelIdUnsanitized, glm::vec4 emissiveColor);
211
222 void setModelScenePass(int32_t modelIndex, bool drawInScene);
223
224 // ─── Skinned characters (animated players) ───────────────────────────────
225 //
226 // The skinning pipeline (rig install, per-frame palette upload, instanced
227 // draw, shaders) is its own subsystem — see `SkinnedRenderer.hpp`.
228 // Game code talks to it through the accessor below:
229 //
230 // renderer.skinned().setRig(meshes, numJoints); // once
231 // renderer.skinned().setFrame(palette, instances); // every frame
232 //
233 // `NewRenderer::drawFrame` automatically drives the matching
234 // `uploadFrame()` (before render pass) and `draw()` (inside geometry pass)
235 // — game code never calls those directly.
236
242 [[nodiscard]] SkinnedRenderer& skinned() { return skinnedRenderer_; }
243 [[nodiscard]] const SkinnedRenderer& skinned() const { return skinnedRenderer_; }
244
245 // ─── Static models ───────────────────────────────────────────────────────
246
260 int loadSceneModel(
261 const char* filename, glm::vec3 pos, float scale, bool flipUVs, const std::string& excludeNodesContaining = "");
262
270 void setHudTexture(SDL_GPUTexture* hudTexture);
271
272 // ─── Subsystem registration ─────────────────────────────────────────────
273
286
287 // ─── Settings / toggles ─────────────────────────────────────────────────
288
300 bool setVSync(bool enabled);
301
311 void requestScreenshot(const std::string& path);
324 void updateModelMeshVertices(int modelIndex, int meshIndex, const Vertex* vertices, Uint32 vertexCount);
325
335 bool loadHDRSkybox(const std::string& path);
336
344 void scanHDRFiles();
345
346 bool setRig(const std::vector<RigMeshSource>& meshes, int numJoints);
347
348 void setSkinnedFrame(const std::vector<glm::mat4>& palette, const std::vector<SkinnedInstance>& instances);
349
350 // ─── Public settings members (mutable directly from Game / debug UI) ─────
351 //
352 // The legacy renderer exposed these as direct member access. Keep the
353 // pattern so Game.cpp and the debug UI can read/write without a getter
354 // ceremony.
355
356 float renderScale = 1.0f;
358 float scopeZoom = 1.0f;
361 bool imguiEnabled = true;
367 float hdrExposure = 1.0f;
368 float hdrWhitePoint = 4.0f;
369 float ssaoRadius = 24.0f;
370 float ssaoBias = 1.5f;
371 float ssaoPixelRadiusScale = 0.35f;
372 float ssaoDepthThreshold = 0.01f;
373 float ssaoNormalDiffMin = 0.12f;
374 float ssaoNormalDiffMax = 0.55f;
375 float ssaoHemisphereMin = 0.05f;
376 float ssaoContactWeight = 1.0f;
377 float ssaoMediumRadius = 48.0f;
378 float ssaoMediumWeight = 0.25f;
379 float ssaoIntensity = 1.0f;
380 float ssaoMinAo = 0.45f;
381 float ssaoMaxAo = 1.0f;
382 bool ssaoBlurEnabled = true;
383 float ssaoBlurRadius = 1.0f;
386 float ssaoBlurStrength = 1.0f;
388 float ssaoCompositePower = 2.0f;
390 std::vector<std::string> availableHDRFiles;
391 std::string currentHDRName = "(procedural)";
392 bool useHDRSkybox = false;
393
394private:
395 // ─── Existing internal helpers ───────────────────────────────────────────
396
401 SDL_GPUGraphicsPipeline* createDepthPipeline(const SDL_GPURasterizerState& rasterizer_state) const;
402 bool createDepthRes0Pipeline(bool reverseZ);
403 bool createDepthRes1Pipeline(bool reverseZ);
404 bool createDepthRes2Pipeline(bool reverseZ);
405 bool createHudPipeline();
406 bool createFxaaPipeline();
408 bool createSsaoPipeline();
411 bool ensureDepthTextureSize(Uint32 width, Uint32 height);
412 bool ensureSceneTextureSize(Uint32 width, Uint32 height);
413 void createMeshBuffers(MeshIdInt meshId) const;
414 void setMainCamera(glm::vec3 eye, float yaw, float pitch, float roll, Uint32 width, Uint32 height, float fov);
415
416 void drawGeometryDepthPass(SDL_GPUTexture* depthTexture,
417 Uint8 res,
418 Uint8 layer,
419 SDL_GPUCommandBuffer* cmd,
420 const glm::mat4& shadowViewProjection,
421 bool staticGeometry,
422 bool entityGeometry,
423 bool skinnedGeometry);
424 void drawToShadowMap(SDL_GPUCommandBuffer* cmd,
425 SDL_GPUTexture* shadowMapTexture,
426 Uint8 res,
427 bool staticGeometry,
428 bool entityGeometry,
429 bool skinnedGeometry,
430 PointLightType lightType,
431 bool cullByCamera = true);
432
433 void onFirstFrame(SDL_GPUCommandBuffer* cmd);
434
435 void bindLightShadowInfo(SDL_GPURenderPass* renderPass, SDL_GPUCommandBuffer* cmd, bool lightmap);
436 void drawStaticLightmapGeometryPass(SDL_GPUTexture* sceneColor, SDL_GPUCommandBuffer* cmd);
437 void drawGeometryPass(SDL_GPUTexture* sceneColor, SDL_GPUCommandBuffer* cmd);
438 void drawGeometryOverlayPass(SDL_GPUTexture* sceneColor, SDL_GPUCommandBuffer* cmd);
439 void drawSsaoPass(SDL_GPUTexture* depth, SDL_GPUTexture* normal, SDL_GPUTexture* ao, SDL_GPUCommandBuffer* cmd);
440 void drawSsaoBlurPass(
441 SDL_GPUTexture* ao, SDL_GPUTexture* depth, SDL_GPUTexture* normal, SDL_GPUTexture* output, SDL_GPUCommandBuffer* cmd);
443 SDL_GPUTexture* sceneColor, SDL_GPUTexture* rawAo, SDL_GPUTexture* blurredAo, SDL_GPUTexture* output, SDL_GPUCommandBuffer* cmd);
444 void drawUIPass(SDL_GPUTexture* swapchain, SDL_GPUCommandBuffer* cmd);
445 void drawHudPass(SDL_GPUTexture* target, SDL_GPUCommandBuffer* cmd);
446 void drawFxaaPass(SDL_GPUTexture* sceneColor, SDL_GPUTexture* swapchain, SDL_GPUCommandBuffer* cmd);
447 void drawTonemapPass(SDL_GPUTexture* hdrSceneColor, SDL_GPUTexture* ldrColor, SDL_GPUCommandBuffer* cmd);
448 void drawParticles(SDL_GPURenderPass* renderPass, SDL_GPUCommandBuffer* cmd) const;
449 void drawWeaponPass(SDL_GPUTexture* sceneColor, SDL_GPUCommandBuffer* cmd);
450 void drawWorldModelInstances(SDL_GPURenderPass* renderPass,
451 SDL_GPUCommandBuffer* cmd,
452 bool depth,
453 const FrustumPlanes& frustumPlanes);
454 void drawWeapon(SDL_GPURenderPass* geometryPass, SDL_GPUCommandBuffer* cmd, const FrustumPlanes& frustumPlanes);
455 void drawSkinnedModels(SDL_GPURenderPass* renderPass, SDL_GPUCommandBuffer* cmd);
456 void drawEntityChams(SDL_GPURenderPass* renderPass, SDL_GPUCommandBuffer* cmd, const FrustumPlanes& frustumPlanes);
457
458 void drawModel(ModelIdInt modelId,
459 const glm::mat4& modelTransform,
460 SDL_GPURenderPass* renderPass,
461 SDL_GPUCommandBuffer* cmd,
462 const FrustumPlanes& frustumPlanes,
463 glm::vec4 tint = glm::vec4{1.0f});
464
465 void drawModelDepth(ModelIdInt modelId,
466 const glm::mat4& modelTransform,
467 SDL_GPURenderPass* renderPass,
468 SDL_GPUCommandBuffer* cmd,
469 const FrustumPlanes& frustumPlanes);
470
471 void drawEntityModels(SDL_GPURenderPass* renderPass,
472 SDL_GPUCommandBuffer* cmd,
473 bool depth,
474 const FrustumPlanes& frustumPlanes);
475
476 void drawMesh(SDL_GPURenderPass* renderPass, const Asset::Mesh& mesh) const;
477 void drawHud(SDL_GPURenderPass* pass);
478
479 static bool
480 inFrustum(const Asset::AABB& modelElementAABB, const FrustumPlanes& frustumPlanes, const glm::mat4& modelMat);
481 bool loadLightMap();
482
483 // ─── Member state ────────────────────────────────────────────────────────
484
485 SDL_Window* window_ = nullptr;
486 SDL_GPUDevice* device_ = nullptr;
487 SDL_GPUShaderFormat shaderFormat_ = SDL_GPU_SHADERFORMAT_INVALID;
488
489 SDL_GPUGraphicsPipeline* geometryPipeline_ = nullptr;
490 SDL_GPUGraphicsPipeline* geometryLightMapPipeline_ = nullptr;
491 SDL_GPUGraphicsPipeline* entityChamsPipeline_ = nullptr;
492 SDL_GPUGraphicsPipeline* hudPipeline_ = nullptr;
493 SDL_GPUGraphicsPipeline* fxaaPipeline_ = nullptr;
494 SDL_GPUGraphicsPipeline* tonemapPipeline_ = nullptr;
495 SDL_GPUGraphicsPipeline* ssaoPipeline_ = nullptr;
496 SDL_GPUGraphicsPipeline* ssaoBlurPipeline_ = nullptr;
497 SDL_GPUGraphicsPipeline* ssaoCompositePipeline_ = nullptr;
498 SDL_GPUGraphicsPipeline* skinnedPipeline_ = nullptr;
499 SDL_GPUGraphicsPipeline* depthRes0Pipeline_ = nullptr;
500 SDL_GPUGraphicsPipeline* depthRes1Pipeline_ = nullptr;
501 SDL_GPUGraphicsPipeline* depthRes2Pipeline_ = nullptr;
502
503 SDL_GPUTextureFormat colorTarget_ = SDL_GPU_TEXTUREFORMAT_INVALID;
504 SDL_GPUTexture* sceneColor_ = nullptr;
505 SDL_GPUTexture* sceneNormal_ = nullptr;
506 SDL_GPUTexture* ssaoColor_ = nullptr;
507 SDL_GPUTexture* ssaoBlurred_ = nullptr;
508 SDL_GPUTexture* sceneWithAo_ = nullptr;
509 SDL_GPUTexture* tonemappedColor_ = nullptr;
510 SDL_GPUTexture* lightMap_ = nullptr;
511 SDL_GPUDepthStencilTargetInfo depthTarget_{};
512 Uint32 sceneWidth_ = 0;
513 Uint32 sceneHeight_ = 0;
514 Uint32 ssaoWidth_ = 0;
515 Uint32 ssaoHeight_ = 0;
516 Uint32 depthWidth_ = 0;
517 Uint32 depthHeight_ = 0;
518
519 // Default fallback texture used when a mesh has no material/texture.
520 SDL_GPUTexture* texture_ = nullptr;
521 SDL_GPUSampler* sampler_ = nullptr;
522 SDL_GPUSampler* nearestSampler_ = nullptr;
523
524 SDL_GPUTexture* hudTexture_ = nullptr;
525 SDL_GPUSampler* hudSampler_ = nullptr;
526 SDL_GPUSampler* fxaaSampler_ = nullptr;
527
528 // constexpr uint32_t shadowSize = 2048;
529 // constexpr uint32_t shadowSize = 512;
530 static const uint32_t shadowSize = 1024;
531 static const uint32_t macShadowSize = 512;
532 static const uint32_t staticShadowSize = 2048;
533 SDL_GPUTexture* dynamicShadowMaps_ = nullptr;
534 SDL_GPUTexture* staticShadowMaps_ = nullptr;
535 SDL_GPUSampler* staticDepthSampler_ = nullptr;
536 SDL_GPUSampler* dynamicDepthSampler_ = nullptr;
537
538 SDL_GPUTexture* movingLightShadowMaps_ = nullptr;
539
542
543 bool firstFrame_ = true;
544
546
548
549 // Per-frame captured state ───────────────────────────────────────────────
550 std::vector<EntityRenderCmd> entities_;
551 // std::vector<Asset::AABB> entityAABBs_;
554
555 // Settings captured state ─────────────────────────────────────────────────
556 bool vsyncEnabled_ = true;
558 // Skinned-character subsystem (see SkinnedRenderer.hpp) ──────────────────
560
561 // Telemetry counters (filled by drawFrame) ────────────────────────────────
562 float lastAcquireMs_ = 0.0f;
563 float lastRecordMs_ = 0.0f;
564 float lastSubmitMs_ = 0.0f;
565};
GPU asset types and global registries for the new renderer.
uint32_t MeshIdInt
Definition Asset.hpp:21
uint32_t ModelIdInt
Definition Asset.hpp:22
SDL3 GPU helper utilities: shader loading, buffer/texture creation, pipeline setup.
#define MAX_MOVING_POINT_LIGHTS
Definition Boilerplate.hpp:21
#define MAX_POINT_LIGHTS
Definition Boilerplate.hpp:13
Camera class for the new renderer with combined view-projection matrix.
PointLightType
Definition NewRenderer.hpp:49
@ TEMPORARY
Definition NewRenderer.hpp:52
@ NON_SHADOW
Definition NewRenderer.hpp:53
@ MOVING
Definition NewRenderer.hpp:51
@ STATIC
Definition NewRenderer.hpp:50
#define NUM_CUBE_FACES
Definition NewRenderer.hpp:31
Shared data types exchanged between Game (producer) and NewRenderer (consumer).
Self-contained renderer subsystem for skinned (animated) characters.
Camera for the new renderer, combining view and projection into one matrix.
Definition Camera.hpp:22
Graphics-team's work-in-progress SDL3 GPU renderer.
Definition NewRenderer.hpp:83
void onFirstFrame(SDL_GPUCommandBuffer *cmd)
Definition NewRenderer.cpp:926
SDL_GPUGraphicsPipeline * ssaoPipeline_
Definition NewRenderer.hpp:495
bool createDepthRes1Pipeline(bool reverseZ)
Definition NewRenderer.cpp:627
float ssaoBlurStrength
Blend amount from raw AO to blurred AO.
Definition NewRenderer.hpp:386
SDL_GPUSampler * dynamicDepthSampler_
Definition NewRenderer.hpp:536
SDL_GPUTexture * texture_
Definition NewRenderer.hpp:520
SDL_GPUDevice * getDevice() const
Returns the SDL GPU device.
Definition NewRenderer.hpp:111
SDL_GPUTextureFormat getSwapchainColorFormat() const
Color format of the active swapchain render pass.
Definition NewRenderer.hpp:123
void drawSsaoBlurPass(SDL_GPUTexture *ao, SDL_GPUTexture *depth, SDL_GPUTexture *normal, SDL_GPUTexture *output, SDL_GPUCommandBuffer *cmd)
Definition NewRenderer.cpp:1085
SDL_GPUSampler * nearestSampler_
Definition NewRenderer.hpp:522
float ssaoHemisphereMin
Minimum normal-facing direction for AO samples.
Definition NewRenderer.hpp:375
void drawParticles(SDL_GPURenderPass *renderPass, SDL_GPUCommandBuffer *cmd) const
Definition NewRenderer.cpp:1247
void drawHud(SDL_GPURenderPass *pass)
Definition NewRenderer.cpp:1628
void quit()
Release all GPU resources and shut down the renderer.
Definition NewRenderer.cpp:1641
Uint32 ssaoWidth_
Definition NewRenderer.hpp:514
NewCamera camera_
Definition NewRenderer.hpp:547
bool setRig(const std::vector< RigMeshSource > &meshes, int numJoints)
Definition NewRenderer.cpp:1988
void setEntityRenderList(std::vector< EntityRenderCmd > &&entityList)
Set the list of entity render commands for this frame.
Definition NewRenderer.cpp:1867
glm::vec3 cubeFaceTargets_[NUM_CUBE_FACES]
Definition NewRenderer.hpp:540
float ssaoMediumRadius
Medium-radius crease/corner AO band.
Definition NewRenderer.hpp:377
float hdrExposure
Debug exposure multiplier used by the tonemap pass.
Definition NewRenderer.hpp:367
void drawFxaaPass(SDL_GPUTexture *sceneColor, SDL_GPUTexture *swapchain, SDL_GPUCommandBuffer *cmd)
Definition NewRenderer.cpp:1201
bool createDepthRes2Pipeline(bool reverseZ)
Definition NewRenderer.cpp:647
bool loadLightMap()
Definition NewRenderer.cpp:2028
SDL_GPUTexture * sceneNormal_
Definition NewRenderer.hpp:505
SDL_GPUTexture * ssaoBlurred_
Definition NewRenderer.hpp:507
void setPointLights(std::vector< PointLight > pointLights)
Set dynamic point lights for this frame.
Definition NewRenderer.cpp:1845
glm::vec3 cubeFaceUps_[NUM_CUBE_FACES]
Definition NewRenderer.hpp:541
float lastRecordMs_
Definition NewRenderer.hpp:563
SDL_GPUSampler * fxaaSampler_
Definition NewRenderer.hpp:526
float lightIntensityMultiplier
Scales direct geometry light intensity.
Definition NewRenderer.hpp:366
bool createGeometryLightMapPipeline()
Definition NewRenderer.cpp:459
float ssaoBlurNormalThreshold
Minimum normal dot for AO blur samples.
Definition NewRenderer.hpp:385
bool ensureSceneTextureSize(Uint32 width, Uint32 height)
Definition NewRenderer.cpp:1550
SDL_GPUTexture * sceneWithAo_
Definition NewRenderer.hpp:508
void drawWeapon(SDL_GPURenderPass *geometryPass, SDL_GPUCommandBuffer *cmd, const FrustumPlanes &frustumPlanes)
Definition NewRenderer.cpp:1274
SDL_GPUTexture * hudTexture_
Definition NewRenderer.hpp:524
void drawUIPass(SDL_GPUTexture *swapchain, SDL_GPUCommandBuffer *cmd)
Definition NewRenderer.cpp:1598
SDL_GPUGraphicsPipeline * tonemapPipeline_
Definition NewRenderer.hpp:494
void drawGeometryDepthPass(SDL_GPUTexture *depthTexture, Uint8 res, Uint8 layer, SDL_GPUCommandBuffer *cmd, const glm::mat4 &shadowViewProjection, bool staticGeometry, bool entityGeometry, bool skinnedGeometry)
Definition NewRenderer.cpp:800
float getLastSubmitMs() const
Most-recent SDL_SubmitGPUCommandBuffer cost in milliseconds.
Definition NewRenderer.hpp:156
WeaponViewmodel weapon_
Definition NewRenderer.hpp:552
float ssaoDepthThreshold
Max depth-buffer delta accepted for contact AO samples.
Definition NewRenderer.hpp:372
Uint32 depthHeight_
Definition NewRenderer.hpp:517
bool createSsaoBlurPipeline()
Definition NewRenderer.cpp:402
Uint32 sceneWidth_
Definition NewRenderer.hpp:512
SDL_GPUGraphicsPipeline * skinnedPipeline_
Definition NewRenderer.hpp:498
int ssaoDebugView
0 final scene, 1 raw AO.
Definition NewRenderer.hpp:389
SDL_Window * window_
Definition NewRenderer.hpp:485
bool createHudPipeline()
Definition NewRenderer.cpp:302
void drawEntityModels(SDL_GPURenderPass *renderPass, SDL_GPUCommandBuffer *cmd, bool depth, const FrustumPlanes &frustumPlanes)
Definition NewRenderer.cpp:1334
SDL_GPUGraphicsPipeline * depthRes0Pipeline_
Definition NewRenderer.hpp:499
void drawModel(ModelIdInt modelId, const glm::mat4 &modelTransform, SDL_GPURenderPass *renderPass, SDL_GPUCommandBuffer *cmd, const FrustumPlanes &frustumPlanes, glm::vec4 tint=glm::vec4{1.0f})
Definition NewRenderer.cpp:1394
void drawSsaoCompositePass(SDL_GPUTexture *sceneColor, SDL_GPUTexture *rawAo, SDL_GPUTexture *blurredAo, SDL_GPUTexture *output, SDL_GPUCommandBuffer *cmd)
Definition NewRenderer.cpp:1133
void drawMesh(SDL_GPURenderPass *renderPass, const Asset::Mesh &mesh) const
Definition NewRenderer.cpp:1510
bool vsyncEnabled_
Definition NewRenderer.hpp:556
bool createSsaoPipeline()
Definition NewRenderer.cpp:362
SkinnedRenderer & skinned()
Accessor for the skinned-character subsystem.
Definition NewRenderer.hpp:242
SDL_GPUGraphicsPipeline * fxaaPipeline_
Definition NewRenderer.hpp:493
LightUBO sceneLightInfo_
Definition NewRenderer.hpp:545
SDL_GPUTexture * sceneColor_
Definition NewRenderer.hpp:504
static const uint32_t staticShadowSize
Definition NewRenderer.hpp:532
std::string currentHDRName
Display name of the currently-loaded HDR.
Definition NewRenderer.hpp:391
float ssaoNormalDiffMax
Normal-difference full weight for crease/contact weighting.
Definition NewRenderer.hpp:374
SDL_GPUTexture * lightMap_
Definition NewRenderer.hpp:510
void drawWeaponPass(SDL_GPUTexture *sceneColor, SDL_GPUCommandBuffer *cmd)
Definition NewRenderer.cpp:1173
SDL_GPUSampler * sampler_
Definition NewRenderer.hpp:521
float metallicTextureStrength
Scales sampled metallic texture values before lighting.
Definition NewRenderer.hpp:364
void drawToShadowMap(SDL_GPUCommandBuffer *cmd, SDL_GPUTexture *shadowMapTexture, Uint8 res, bool staticGeometry, bool entityGeometry, bool skinnedGeometry, PointLightType lightType, bool cullByCamera=true)
Definition NewRenderer.cpp:845
float mainHorizontalFovDegrees
Main camera horizontal field of view in degrees.
Definition NewRenderer.hpp:357
void setWeaponViewmodel(const WeaponViewmodel &vm)
Set the first-person weapon viewmodel for this frame.
Definition NewRenderer.cpp:1840
RenderToggles toggles
Per-pass on/off toggles (see RenderToggles in RendererTypes.hpp).
Definition NewRenderer.hpp:362
void drawTonemapPass(SDL_GPUTexture *hdrSceneColor, SDL_GPUTexture *ldrColor, SDL_GPUCommandBuffer *cmd)
Definition NewRenderer.cpp:1224
void scanHDRFiles()
Scan the assets HDR directory and populate availableHDRFiles_.
Definition NewRenderer.cpp:1981
void drawGeometryOverlayPass(SDL_GPUTexture *sceneColor, SDL_GPUCommandBuffer *cmd)
Definition NewRenderer.cpp:998
SDL_GPUSampler * staticDepthSampler_
Definition NewRenderer.hpp:535
float ssaoRadius
World-space AO sampling radius.
Definition NewRenderer.hpp:369
SDL_GPUGraphicsPipeline * createDepthPipeline(const SDL_GPURasterizerState &rasterizer_state) const
Definition NewRenderer.cpp:565
static const uint32_t shadowSize
Definition NewRenderer.hpp:530
void updateModelMeshVertices(int modelIndex, int meshIndex, const Vertex *vertices, Uint32 vertexCount)
Queue a vertex-buffer re-upload for one mesh of a loaded model.
Definition NewRenderer.cpp:1964
bool createTonemapPipeline()
Definition NewRenderer.cpp:342
bool createDepthRes0Pipeline(bool reverseZ)
Definition NewRenderer.cpp:606
const SkinnedRenderer & skinned() const
Definition NewRenderer.hpp:243
bool setVSync(bool enabled)
Enable or disable vertical sync.
Definition NewRenderer.cpp:1910
float getLastAcquireMs() const
Most-recent SDL_AcquireGPUCommandBuffer cost in milliseconds.
Definition NewRenderer.hpp:150
void setMainCamera(glm::vec3 eye, float yaw, float pitch, float roll, Uint32 width, Uint32 height, float fov)
Definition NewRenderer.cpp:782
bool imguiEnabled
Master toggle for the ImGui debug overlay.
Definition NewRenderer.hpp:361
void setModelEmissive(int32_t modelIdUnsanitized, glm::vec4 emissiveColor)
Override the emissive colour of every mesh in a registered model.
Definition NewRenderer.cpp:1884
SDL_GPUTexture * dynamicShadowMaps_
Definition NewRenderer.hpp:533
SDL_GPUShaderFormat getShaderFormat() const
Shader format selected during init() (SPIR-V on Vulkan, MSL on Metal, DXIL on D3D12).
Definition NewRenderer.hpp:116
void createMeshBuffers(MeshIdInt meshId) const
Definition NewRenderer.cpp:668
float ambientColorMultiplier
Scales the geometry shader ambient colour contribution.
Definition NewRenderer.hpp:365
std::vector< EntityRenderCmd > entities_
Definition NewRenderer.hpp:550
void drawHudPass(SDL_GPUTexture *target, SDL_GPUCommandBuffer *cmd)
Definition NewRenderer.cpp:1615
float ssaoBias
World-space self-occlusion bias.
Definition NewRenderer.hpp:370
float hdrWhitePoint
Debug white point for Extended Reinhard tonemapping.
Definition NewRenderer.hpp:368
Uint32 ssaoHeight_
Definition NewRenderer.hpp:515
float lastAcquireMs_
Definition NewRenderer.hpp:562
float ssaoCompositeStrength
AO application strength before tonemapping.
Definition NewRenderer.hpp:387
void drawWorldModelInstances(SDL_GPURenderPass *renderPass, SDL_GPUCommandBuffer *cmd, bool depth, const FrustumPlanes &frustumPlanes)
Definition NewRenderer.cpp:1318
float ssaoPixelRadiusScale
Converts AO radius to screen-space sample spacing.
Definition NewRenderer.hpp:371
SDL_GPUGraphicsPipeline * ssaoCompositePipeline_
Definition NewRenderer.hpp:497
bool init(SDL_Window *window)
Initialise the GPU device, pipelines, and default scene assets.
Definition NewRenderer.cpp:57
const NewCamera & getCamera() const
Current camera (updated every drawFrame call).
Definition NewRenderer.hpp:129
void drawFrame(glm::vec3 eye, float yaw, float pitch, float roll)
Render one frame from the given camera pose.
Definition NewRenderer.cpp:686
bool createFxaaPipeline()
Definition NewRenderer.cpp:322
SDL_GPUTextureFormat colorTarget_
Definition NewRenderer.hpp:503
Uint32 sceneHeight_
Definition NewRenderer.hpp:513
void setModelScenePass(int32_t modelIndex, bool drawInScene)
Toggle whether a model is drawn during the scene pass.
Definition NewRenderer.cpp:1893
float renderScale
Internal-resolution multiplier (0.5 = half-res, 2.0 = SSAA).
Definition NewRenderer.hpp:356
SDL_GPUGraphicsPipeline * geometryLightMapPipeline_
Definition NewRenderer.hpp:490
SDL_GPUGraphicsPipeline * entityChamsPipeline_
Definition NewRenderer.hpp:491
float getLastRecordMs() const
Most-recent command-recording cost (between acquire and submit) in ms.
Definition NewRenderer.hpp:153
SDL_GPUTexture * tonemappedColor_
Definition NewRenderer.hpp:509
std::string pendingScreenshotPath_
Definition NewRenderer.hpp:557
bool ensureDepthTextureSize(Uint32 width, Uint32 height)
Definition NewRenderer.cpp:1526
bool createSsaoCompositePipeline()
Definition NewRenderer.cpp:382
bool useHDRSkybox
True after a successful loadHDRSkybox().
Definition NewRenderer.hpp:392
float ssaoMediumWeight
Medium AO band weight.
Definition NewRenderer.hpp:378
SDL_GPUGraphicsPipeline * geometryPipeline_
Definition NewRenderer.hpp:489
bool createEntityChamsPipeline()
Create the flat static-entity chams pipeline used for occluded powerup silhouettes.
Definition NewRenderer.cpp:496
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.
Definition NewRenderer.cpp:1745
SDL_GPUGraphicsPipeline * depthRes2Pipeline_
Definition NewRenderer.hpp:501
Uint32 depthWidth_
Definition NewRenderer.hpp:516
float scopeZoom
Per-frame scope zoom multiplier (FOV divisor).
Definition NewRenderer.hpp:358
void setParticleSystem(ParticleSystem *ps)
Register the particle system so the renderer can call its render hooks.
Definition NewRenderer.cpp:1900
void drawSkinnedModels(SDL_GPURenderPass *renderPass, SDL_GPUCommandBuffer *cmd)
Definition NewRenderer.cpp:1308
static const uint32_t macShadowSize
Definition NewRenderer.hpp:531
void bindLightShadowInfo(SDL_GPURenderPass *renderPass, SDL_GPUCommandBuffer *cmd, bool lightmap)
Definition NewRenderer.cpp:934
float ssaoCompositePower
AO exponent before composition.
Definition NewRenderer.hpp:388
bool createGeometryPipeline()
Definition NewRenderer.cpp:422
float ssaoMaxAo
Brightest raw AO value.
Definition NewRenderer.hpp:381
void drawSsaoPass(SDL_GPUTexture *depth, SDL_GPUTexture *normal, SDL_GPUTexture *ao, SDL_GPUCommandBuffer *cmd)
Definition NewRenderer.cpp:1021
ParticleSystem * particleSystem_
Definition NewRenderer.hpp:553
bool ssaoBlurEnabled
Use the depth/normal-aware AO blur.
Definition NewRenderer.hpp:382
float ssaoMinAo
Darkest raw AO value.
Definition NewRenderer.hpp:380
SDL_GPUTexture * movingLightShadowMaps_
Definition NewRenderer.hpp:538
float lastSubmitMs_
Definition NewRenderer.hpp:564
float ssaoIntensity
Raw AO occlusion multiplier.
Definition NewRenderer.hpp:379
void setStaticPointLights(std::vector< PointLight > &&pointLights)
Definition NewRenderer.cpp:1859
static constexpr SDL_GPUTextureFormat getHdrFormat()
Legacy HDR colour render target format.
Definition NewRenderer.hpp:142
void requestScreenshot(const std::string &path)
Request a screenshot to be saved to disk after the next frame.
Definition NewRenderer.cpp:1955
float ssaoContactWeight
Tight contact AO band weight.
Definition NewRenderer.hpp:376
float ssaoBlurRadius
Multiplier for the fixed 5x5 AO blur offsets.
Definition NewRenderer.hpp:383
SDL_GPUDepthStencilTargetInfo depthTarget_
Definition NewRenderer.hpp:511
void drawStaticLightmapGeometryPass(SDL_GPUTexture *sceneColor, SDL_GPUCommandBuffer *cmd)
bool firstFrame_
Definition NewRenderer.hpp:543
SkinnedRenderer skinnedRenderer_
Definition NewRenderer.hpp:559
static bool inFrustum(const Asset::AABB &modelElementAABB, const FrustumPlanes &frustumPlanes, const glm::mat4 &modelMat)
Definition NewRenderer.cpp:2002
int modelCount() const
Number of models currently registered in the asset map.
Definition NewRenderer.cpp:1833
SDL_GPUGraphicsPipeline * depthRes1Pipeline_
Definition NewRenderer.hpp:500
SDL_GPUTexture * staticShadowMaps_
Definition NewRenderer.hpp:534
void setHudTexture(SDL_GPUTexture *hudTexture)
Set the HUD overlay texture to blit after the geometry pass.
Definition NewRenderer.cpp:1636
void setSkinnedFrame(const std::vector< glm::mat4 > &palette, const std::vector< SkinnedInstance > &instances)
Definition NewRenderer.cpp:1993
void drawGeometryPass(SDL_GPUTexture *sceneColor, SDL_GPUCommandBuffer *cmd)
Definition NewRenderer.cpp:957
float ssaoBlurDepthThreshold
Blur world-distance rejection as a fraction of AO radius.
Definition NewRenderer.hpp:384
float roughnessTextureStrength
Scales sampled roughness texture values before lighting.
Definition NewRenderer.hpp:363
SDL_GPUGraphicsPipeline * ssaoBlurPipeline_
Definition NewRenderer.hpp:496
SDL_GPUTexture * ssaoColor_
Definition NewRenderer.hpp:506
bool loadHDRSkybox(const std::string &path)
Load an equirectangular HDR image as the environment skybox + IBL source.
Definition NewRenderer.cpp:1973
float ssaoNormalDiffMin
Normal-difference start for crease/contact weighting.
Definition NewRenderer.hpp:373
SDL_GPUDevice * device_
Definition NewRenderer.hpp:486
void drawModelDepth(ModelIdInt modelId, const glm::mat4 &modelTransform, SDL_GPURenderPass *renderPass, SDL_GPUCommandBuffer *cmd, const FrustumPlanes &frustumPlanes)
Definition NewRenderer.cpp:1486
void drawEntityChams(SDL_GPURenderPass *renderPass, SDL_GPUCommandBuffer *cmd, const FrustumPlanes &frustumPlanes)
Definition NewRenderer.cpp:1356
SDL_GPUSampler * hudSampler_
Definition NewRenderer.hpp:525
std::vector< std::string > availableHDRFiles
Filled by scanHDRFiles(); consumed by debug UI.
Definition NewRenderer.hpp:390
SDL_GPUGraphicsPipeline * hudPipeline_
Definition NewRenderer.hpp:492
SDL_GPUShaderFormat shaderFormat_
Definition NewRenderer.hpp:487
Top-level particle system orchestrator.
Definition ParticleSystem.hpp:39
Instanced GPU-skinning subsystem. One per renderer.
Definition SkinnedRenderer.hpp:40
Definition Asset.hpp:48
A single mesh: CPU-side vertex/index data plus GPU buffer info.
Definition Asset.hpp:54
Definition Camera.hpp:11
Definition NewRenderer.hpp:57
float cameraPosX
Definition NewRenderer.hpp:63
PointLight movingPointLights[MAX_MOVING_POINT_LIGHTS]
Definition NewRenderer.hpp:67
PointLight pointLights[MAX_POINT_LIGHTS]
Definition NewRenderer.hpp:66
float pointLightFarPlane
Definition NewRenderer.hpp:61
uint32_t numPointLights
Definition NewRenderer.hpp:58
uint32_t numSpotLights
Definition NewRenderer.hpp:60
float cameraPosY
Definition NewRenderer.hpp:64
uint32_t numMovingPointLights
Definition NewRenderer.hpp:59
float pointLightNearPlane
Definition NewRenderer.hpp:62
float cameraPosZ
Definition NewRenderer.hpp:65
Dynamic point light — built by Game, injected into the PBR light array.
Definition RendererTypes.hpp:73
Live toggles for every render system — exposed to ImGui.
Definition RendererTypes.hpp:27
Forward-declared — owned by Game, registered via setParticleSystem().
Definition NewRenderer.hpp:40
glm::vec3 position
Definition NewRenderer.hpp:41
glm::vec3 normal
Definition NewRenderer.hpp:42
glm::vec4 tangent
Definition NewRenderer.hpp:44
glm::vec2 texUV
Definition NewRenderer.hpp:43
glm::vec2 lightMapUV
Definition NewRenderer.hpp:45
First-person weapon viewmodel descriptor sent per frame.
Definition RendererTypes.hpp:100