blob: ef94c89dbd47b87889017951182fd86bcdd84405 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#pragma once
#include "maths_types.h"
#include "ral_types.h"
/** @brief shader layout for camera matrices */
typedef struct Binding_Camera {
Mat4 view;
Mat4 projection;
Vec4 viewPos;
} Binding_Camera;
typedef struct Binding_Model {
Mat4 model;
} Binding_Model;
/** @brief data that is handy to have in any shader */
typedef struct Binding_Globals {
} Binding_Globals;
typedef struct pbr_point_light {
Vec3 pos;
f32 pad;
Vec3 color;
f32 pad2;
} pbr_point_light;
typedef struct Binding_Lights {
pbr_point_light pointLights[4];
} Binding_Lights;
static ShaderDataLayout Binding_Camera_GetLayout(void* data) {
Binding_Camera* d = data;
bool has_data = data != NULL;
ShaderBinding b1 = { .label = "Camera",
.kind = BINDING_BYTES,
.data.bytes = { .size = sizeof(Binding_Camera) } };
if (has_data) {
b1.data.bytes.data = d;
}
return (ShaderDataLayout){ .bindings = { b1 }, .binding_count = 1 };
}
static ShaderDataLayout Binding_Model_GetLayout(void* data) {
Binding_Model* d = data;
bool has_data = data != NULL;
ShaderBinding b1 = { .label = "Model",
.kind = BINDING_BYTES,
.vis = VISIBILITY_VERTEX,
.data.bytes = { .size = sizeof(Binding_Model) } };
if (has_data) {
b1.data.bytes.data = d;
}
return (ShaderDataLayout){ .bindings = { b1 }, .binding_count = 1 };
}
static ShaderDataLayout Binding_Lights_GetLayout(void* data) {
Binding_Lights* d = data;
bool has_data = data != NULL;
ShaderBinding b1 = { .label = "Lights",
.kind = BINDING_BYTES,
.vis = VISIBILITY_FRAGMENT,
.data.bytes = { .size = sizeof(Binding_Lights) } };
if (has_data) {
b1.data.bytes.data = d;
}
return (ShaderDataLayout){ .bindings = { b1 }, .binding_count = 1 };
}
|