summaryrefslogtreecommitdiff
path: root/src/new_render/skybox.h
diff options
context:
space:
mode:
authoromnisci3nce <omniscient.oce@gmail.com>2024-07-17 23:12:42 +1000
committeromnisci3nce <omniscient.oce@gmail.com>2024-07-17 23:12:42 +1000
commitc3737fff1be704e14a2bada69bbf8a6709c5f670 (patch)
treeaa2225901f26598b07855a65a944354fbedc40b1 /src/new_render/skybox.h
parentf8641a5cc4c8baf1f0a7be3685afc219d90143d9 (diff)
wip shader layouts for common stuff
Diffstat (limited to 'src/new_render/skybox.h')
-rw-r--r--src/new_render/skybox.h46
1 files changed, 32 insertions, 14 deletions
diff --git a/src/new_render/skybox.h b/src/new_render/skybox.h
index 9bdc2ec..ec06658 100644
--- a/src/new_render/skybox.h
+++ b/src/new_render/skybox.h
@@ -7,20 +7,6 @@
#include "defines.h"
#include "ral_types.h"
-typedef struct CubeMapData {
- void* top_image_data;
- void* bottom_image_data;
- void* left_image_data;
- void* right_image_data;
- void* front_image_data;
- void* back_image_data;
- u32 width, height, num_channels;
-} CubeMapData;
-
-PUB void CubeMapData_Load(const char** face_paths, int n); // should always pass n = 6 for now
-PUB void CubeMapData_Free(CubeMapData* cubemap); // Frees all the image data for a cubemap
-PUB TextureHandle CubeMapData_Upload(CubeMapData* cubemap);
-
typedef struct Skybox {
BufferHandle vertex_buffer;
TextureHandle texture;
@@ -30,3 +16,35 @@ typedef struct Skybox {
PUB Skybox Skybox_Create(const char** face_paths, int n); // should always pass n = 6 for now
PUB void Skybox_Draw(Skybox* skybox);
+
+typedef struct SkyboxUniforms {
+ Vec3 in_pos;
+ TextureHandle cubemap;
+} SkyboxUniforms;
+
+static ShaderDataLayout Skybox_GetLayout(void* data) {
+ SkyboxUniforms* d = (SkyboxUniforms*)data; // cold cast
+ bool has_data = data != NULL;
+
+ ShaderBinding b1 = {
+ .label = "In",
+ .vis = VISIBILITY_VERTEX,
+ .kind = BINDING_BYTES,
+ .data = {.bytes = {.size = sizeof(Vec3)}}
+ };
+
+ ShaderBinding b2 = {
+ .label = "cubemap",
+ .vis = VISIBILITY_FRAGMENT,
+ .kind = BINDING_SAMPLER,
+ };
+
+ if (has_data) {
+ b1.data.bytes.data = &d->in_pos;
+ b2.data.texture.handle = d->cubemap;
+ }
+ return (ShaderDataLayout) {
+ .bindings = { b1, b2},
+ .binding_count = 2
+ };
+} \ No newline at end of file