summaryrefslogtreecommitdiff
path: root/src/render/shadows.h
diff options
context:
space:
mode:
authoromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-08-10 14:06:15 +1000
committeromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-08-10 14:06:15 +1000
commit9cb4bfacc69b2a95ce8e9250afc33fb04d1ba548 (patch)
treefbe75da188ac83b34153ac79c367b9d57e0d5ff9 /src/render/shadows.h
parent071a635e63536e50abfad7d5aeca1208dba58025 (diff)
remove old code
Diffstat (limited to 'src/render/shadows.h')
-rw-r--r--src/render/shadows.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/render/shadows.h b/src/render/shadows.h
new file mode 100644
index 0000000..0482d10
--- /dev/null
+++ b/src/render/shadows.h
@@ -0,0 +1,48 @@
+/**
+ * @brief Functions for adding shadows to scene rendering.
+ */
+
+#pragma once
+#include "defines.h"
+#include "ral_impl.h"
+#include "ral_types.h"
+#include "render_types.h"
+
+typedef struct Shadow_Storage {
+ bool enabled;
+ GPU_Renderpass* shadowmap_pass;
+ GPU_Pipeline* shadowmap_pipeline;
+ TextureHandle depth_texture;
+ bool debug_quad_enabled;
+ Mesh quad;
+ GPU_Renderpass* debugquad_pass;
+ GPU_Pipeline* debugquad_pipeline;
+ // TODO: Some statistics tracking
+} Shadow_Storage;
+
+typedef struct ShadowUniforms {
+ Mat4 light_space;
+ Mat4 model;
+} ShadowUniforms;
+
+typedef struct Camera Camera;
+typedef struct Mat4 Mat4;
+
+// --- Public API
+PUB void Shadow_Init(Shadow_Storage* storage, u32 shadowmap_width, u32 shadowmap_height);
+
+/** @brief Run shadow map generation for given entities, and store in a texture.
+ * @note Uses active directional light for now */
+PUB void Shadow_Run(RenderEnt* entities, size_t entity_count);
+
+PUB void Shadow_DrawDebugQuad();
+
+/** @brief Get the shadow texture generated from shadowmap pass */
+PUB TextureHandle Shadow_GetShadowMapTexture(Shadow_Storage* storage);
+
+// --- Internal
+GPU_Renderpass* Shadow_RPassCreate(); // Creates the render pass
+GPU_Pipeline* Shadow_PipelineCreate(GPU_Renderpass* rpass); // Creates the pipeline
+void Shadow_ShadowmapExecute(Shadow_Storage* storage, Mat4 light_space_transform,
+ RenderEnt* entities, size_t entity_count);
+void Shadow_RenderDebugQuad();