summaryrefslogtreecommitdiff
path: root/cnn_v3/src/gbuffer_effect.h
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-05-21 08:10:47 +0200
committerskal <pascal.massimino@gmail.com>2026-05-21 08:10:47 +0200
commitd806027dcaeadcdd8d2febd88bc46b2fd2c465de (patch)
tree30bc1ef9f40ccab7c00e31ee20e62bb86755fa26 /cnn_v3/src/gbuffer_effect.h
parent680042a18c11ad5e58757e45b260745c2f52417f (diff)
style: apply clang-formatHEADmain
Diffstat (limited to 'cnn_v3/src/gbuffer_effect.h')
-rw-r--r--cnn_v3/src/gbuffer_effect.h42
1 files changed, 22 insertions, 20 deletions
diff --git a/cnn_v3/src/gbuffer_effect.h b/cnn_v3/src/gbuffer_effect.h
index 76d4347..260444a 100644
--- a/cnn_v3/src/gbuffer_effect.h
+++ b/cnn_v3/src/gbuffer_effect.h
@@ -1,5 +1,6 @@
// GBufferEffect: Multi-pass G-buffer rendering for CNN v3 input
-// Outputs: gbuf_feat0, gbuf_feat1 (packed rgba32uint feature textures, 32 bytes/pixel)
+// Outputs: gbuf_feat0, gbuf_feat1 (packed rgba32uint feature textures, 32
+// bytes/pixel)
#pragma once
@@ -21,16 +22,17 @@ struct GBufResUniforms {
static_assert(sizeof(GBufResUniforms) == 16,
"GBufResUniforms must be 16 bytes");
-// Single directional light: direction points *toward* the light source (world space).
+// Single directional light: direction points *toward* the light source (world
+// space).
struct GBufLight {
- vec4 direction; // xyz = normalized direction toward light, w = unused
- vec4 color; // rgb = color, a = intensity
+ vec4 direction; // xyz = normalized direction toward light, w = unused
+ vec4 color; // rgb = color, a = intensity
};
static_assert(sizeof(GBufLight) == 32, "GBufLight must be 32 bytes");
struct GBufLightsUniforms {
GBufLight lights[2];
- vec4 params; // x = num_lights
+ vec4 params; // x = num_lights
};
static_assert(sizeof(GBufLightsUniforms) == 80,
"GBufLightsUniforms must be 80 bytes");
@@ -60,12 +62,12 @@ class GBufferEffect : public Effect {
private:
// Per-cube animation state (axis-angle rotation)
struct CubeAnim {
- vec3 axis;
- float speed; // radians/second, may be negative
+ vec3 axis;
+ float speed; // radians/second, may be negative
};
// Per-sphere animation state (radius driven by audio_intensity)
struct SphereAnim {
- int obj_idx; // index into scene_.objects
+ int obj_idx; // index into scene_.objects
float base_radius;
};
@@ -75,41 +77,42 @@ class GBufferEffect : public Effect {
std::string node_depth_;
std::string node_shadow_;
std::string node_transp_;
- std::string node_prev_tex_; // persistent prev-frame CNN output (rgba8unorm)
+ std::string node_prev_tex_; // persistent prev-frame CNN output (rgba8unorm)
// Name of the CNN effect's output node; set by caller before first render.
// When non-empty, the CNN output is copied into node_prev_tex_ each frame.
std::string cnn_output_node_;
public:
- void set_cnn_output_node(const std::string& name) { cnn_output_node_ = name; }
+ void set_cnn_output_node(const std::string& name) {
+ cnn_output_node_ = name;
+ }
private:
-
// Owned scene and camera — populated by set_scene()
- Scene scene_;
+ Scene scene_;
Camera camera_;
- bool scene_ready_ = false;
+ bool scene_ready_ = false;
- std::vector<CubeAnim> cube_anims_;
+ std::vector<CubeAnim> cube_anims_;
std::vector<SphereAnim> sphere_anims_;
// Pass 1: MRT rasterization pipeline
RenderPipeline raster_pipeline_;
- BindGroup raster_bind_group_;
+ BindGroup raster_bind_group_;
// Pass 2: SDF shadow pipeline
RenderPipeline shadow_pipeline_;
// Pass 4: Pack compute pipeline
- ComputePipeline pack_pipeline_;
- UniformBuffer<GBufResUniforms> pack_res_uniform_;
+ ComputePipeline pack_pipeline_;
+ UniformBuffer<GBufResUniforms> pack_res_uniform_;
UniformBuffer<GBufLightsUniforms> lights_uniform_;
// GPU-side object data buffers (global uniforms + objects storage)
GpuBuffer global_uniforms_buf_;
GpuBuffer objects_buf_;
- int objects_buf_capacity_ = 0;
+ int objects_buf_capacity_ = 0;
void create_raster_pipeline();
void create_shadow_pipeline();
@@ -117,7 +120,6 @@ class GBufferEffect : public Effect {
void update_raster_bind_group(NodeRegistry& nodes);
- void upload_scene_data(const Scene& scene, const Camera& camera,
- float time);
+ void upload_scene_data(const Scene& scene, const Camera& camera, float time);
void ensure_objects_buffer(int num_objects);
};