summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmniscient <omniscient.oce@gmail.com>2024-06-15 16:38:05 +1000
committerOmniscient <omniscient.oce@gmail.com>2024-06-15 16:38:05 +1000
commitc5808488875484aca814bfc8e526f37f3f447166 (patch)
treee560bc86302fad0c8520140511e1994c2b4800d7
parent59f67f04d7238453da766218a37b3c78607fb122 (diff)
shinchoku
-rw-r--r--assets/shaders/pbr_params.frag50
-rw-r--r--assets/shaders/pbr_params.vert26
-rw-r--r--examples/cube/ex_cube.c9
-rw-r--r--examples/pbr_params/ex_pbr_params.c117
-rw-r--r--examples/primitives/ex_primitives.c2
-rw-r--r--src/colours.h1
-rw-r--r--src/maths/maths.h2
-rw-r--r--src/maths/primitives.c34
-rw-r--r--src/renderer/backends/opengl/backend_opengl.c13
-rw-r--r--src/renderer/backends/opengl/backend_opengl.h1
-rw-r--r--src/renderer/builtin_materials.h81
-rw-r--r--src/renderer/ral.c9
-rw-r--r--src/renderer/render.h10
-rw-r--r--src/renderer/render_types.h7
-rw-r--r--src/renderer/static_pipeline.h4
-rw-r--r--src/scene.h1
-rw-r--r--xmake.lua7
17 files changed, 311 insertions, 63 deletions
diff --git a/assets/shaders/pbr_params.frag b/assets/shaders/pbr_params.frag
index 06e0f7e..d467aa8 100644
--- a/assets/shaders/pbr_params.frag
+++ b/assets/shaders/pbr_params.frag
@@ -12,15 +12,21 @@ struct PointLight {
};
// --- Uniforms
-uniform vec3 viewPos;
// Lights data
#define NUM_POINT_LIGHTS 4
-uniform PointLight pointLights[NUM_POINT_LIGHTS];
+uniform Scene_Lights {
+ vec3 viewPos;
+ PointLight pointLights[NUM_POINT_LIGHTS];
+} scene;
// Material properties
-uniform vec3 albedo;
-uniform float metallic;
-uniform float roughness;
-uniform float ao;
+uniform PBR_Params {
+ uniform vec3 albedo;
+ uniform float metallic;
+ uniform float roughness;
+ uniform float ao;
+} pbr;
+
+const float PI = 3.14;
// Forward declarations
vec3 fresnelSchlick(float cosTheta, vec3 F0);
@@ -30,20 +36,22 @@ float GeometrySmith(vec3 N, vec3 V, vec3 L, float roughness);
void main() {
vec3 norm = normalize(Normal);
- vec3 viewDir = normalize(viewPos - WorldPos);
-
- vec3 radiance = vec3(0.0); // denoted L in the radiance equation
- for (int i = 0; i < 4; i++) {
- vec3 lightVec = normalize(pointLights[i].position - WorldPos);
- vec3 halfway = normalize(Normal + lightVec);
- float distance = length(pointLights[i].position - WorldPos);
- float attenuation = 1.0 / (distance * distance);
- vec3 radiance = pointLights[i].color * attenuation;
-
- vec3 F0 = vec3(0.04);
- F0 = mix(F0, albedo, metallic);
- vec3 F = fresnelSchlick(max(dot(halfway, lightVec), 0.0), F0);
- }
+ vec3 viewDir = normalize(scene.viewPos - WorldPos);
+
+ // vec3 radiance = vec3(0.0); // denoted L in the radiance equation
+ // for (int i = 0; i < 4; i++) {
+ // vec3 lightVec = normalize(pointLights[i].position - WorldPos);
+ // vec3 halfway = normalize(Normal + lightVec);
+ // float distance = length(pointLights[i].position - WorldPos);
+ // float attenuation = 1.0 / (distance * distance);
+ // vec3 radiance = pointLights[i].color * attenuation;
+
+ // vec3 F0 = vec3(0.04);
+ // F0 = mix(F0, albedo, metallic);
+ // vec3 F = fresnelSchlick(max(dot(halfway, lightVec), 0.0), F0);
+ // }
+
+ FragColor = vec4(1.0);
}
/* The below are from https://learnopengl.com/PBR/Lighting */
@@ -82,4 +90,4 @@ float GeometrySmith(vec3 N, vec3 V, vec3 L, float roughness)
float ggx1 = GeometrySchlickGGX(NdotL, roughness);
return ggx1 * ggx2;
-} \ No newline at end of file
+}
diff --git a/assets/shaders/pbr_params.vert b/assets/shaders/pbr_params.vert
new file mode 100644
index 0000000..0908246
--- /dev/null
+++ b/assets/shaders/pbr_params.vert
@@ -0,0 +1,26 @@
+#version 410
+
+// Vertex attributes
+layout(location = 0) in vec3 inPosition;
+layout(location = 1) in vec3 inNormal;
+layout(location = 2) in vec2 inTexCoords;
+
+// Uniforms
+uniform MVP_Matrices {
+ mat4 model; // TODO: make model a push constant/raw uniform
+ mat4 view;
+ mat4 proj;
+} mvp;
+
+// Outputs
+layout(location = 0) out vec3 fragWorldPos;
+layout(location = 1) out vec3 fragNormal;
+layout(location = 2) out vec2 fragTexCoords;
+
+void main() {
+ fragWorldPos = vec3(mvp.model * vec4(inPosition, 1.0));
+ // TODO: fragNormal
+ fragTexCoords = inTexCoords;
+
+ gl_Position = mvp.proj * mvp.view * mvp.model * vec4(inPosition, 1.0);
+}
diff --git a/examples/cube/ex_cube.c b/examples/cube/ex_cube.c
index 5f45b7f..26e6b71 100644
--- a/examples/cube/ex_cube.c
+++ b/examples/cube/ex_cube.c
@@ -16,6 +16,15 @@
extern core g_core;
+// Scene / light setup
+const vec3 pointlight_positions[4] = {
+ { -10.0, 10.0, 10.0},
+ { 10.0, 10.0, 10.0},
+ { -10.0, -10.0, 10.0},
+ { 10.0, -10.0, 10.0},
+};
+point_light point_lights[4];
+
// Define the shader data
typedef struct mvp_uniforms {
mat4 model;
diff --git a/examples/pbr_params/ex_pbr_params.c b/examples/pbr_params/ex_pbr_params.c
new file mode 100644
index 0000000..583fd12
--- /dev/null
+++ b/examples/pbr_params/ex_pbr_params.c
@@ -0,0 +1,117 @@
+#include <glfw3.h>
+
+#include "builtin_materials.h"
+#include "camera.h"
+#include "colours.h"
+#include "core.h"
+#include "log.h"
+#include "maths.h"
+#include "maths_types.h"
+#include "primitives.h"
+#include "ral.h"
+#include "render.h"
+#include "render_types.h"
+#include "str.h"
+
+extern core g_core;
+
+// Lets define some constant PBR parameters here to test on one sphere with first
+const rgba ALBEDO = RED_700;
+const f32 metallic = 0.0;
+const f32 roughness = 0.8;
+const f32 ao = 0.2;
+
+const pbr_params_material_uniforms pbr_params = {.albedo = (vec3){0.5,0.5,0.5}, .metallic = metallic, .roughness = roughness, .ao = ao};
+
+int main() {
+ core_bringup();
+
+ arena scratch = arena_create(malloc(1024 * 1024), 1024 * 1024);
+
+ vec3 camera_pos = vec3(3.0, 3., 3.);
+ vec3 camera_front = vec3_normalise(vec3_negate(camera_pos));
+ camera cam = camera_create(camera_pos, camera_front, VEC3_Y, deg_to_rad(45.0));
+
+ // PBR Material data
+ shader_data pbr_uniforms = { .data = NULL, .shader_data_get_layout = &pbr_params_shader_layout };
+
+ // Make the pipeline
+ gpu_renderpass_desc pass_description = {};
+ gpu_renderpass* renderpass = gpu_renderpass_create(&pass_description);
+ // FIXME: Make this work on other API backends
+ str8 vert_path = str8lit("assets/shaders/pbr_params.vert");
+ str8 frag_path = str8lit("assets/shaders/pbr_params.frag");
+ str8_opt vertex_shader = str8_from_file(&scratch, vert_path);
+ str8_opt fragment_shader = str8_from_file(&scratch, frag_path);
+ if (!vertex_shader.has_value || !fragment_shader.has_value) {
+ ERROR_EXIT("Failed to load shaders from disk")
+ }
+
+ struct graphics_pipeline_desc pipeline_description = {
+ .debug_name = "Basic Pipeline",
+ .vertex_desc = static_3d_vertex_description(),
+ .data_layouts = { pbr_uniforms },
+ .data_layouts_count = 1,
+ .vs = { .debug_name = "PBR (params) Vertex Shader",
+ .filepath = vert_path,
+ .code = vertex_shader.contents,
+ .is_spirv = false },
+ .fs = { .debug_name = "PBR (params) Fragment Shader",
+ .filepath = frag_path,
+ .code = fragment_shader.contents,
+ .is_spirv = false },
+ .renderpass = renderpass,
+ .wireframe = false,
+ .depth_test = false
+ };
+ gpu_pipeline* pbr_pipeline = gpu_graphics_pipeline_create(pipeline_description);
+
+ // Geometry
+ geometry_data sphere_data = geo_create_uvsphere(1.0, 12, 12);
+ mesh sphere = mesh_create(&sphere_data, false);
+
+ pbr_params_bindgroup pbr_bind_data;
+
+ while (!should_exit()) {
+ input_update(&g_core.input);
+
+ if (!gpu_backend_begin_frame()) {
+ continue;
+ }
+ gpu_cmd_encoder* enc = gpu_get_default_cmd_encoder();
+ // Begin recording
+ gpu_cmd_encoder_begin(*enc);
+ gpu_cmd_encoder_begin_render(enc, renderpass);
+ encode_bind_pipeline(enc, PIPELINE_GRAPHICS, pbr_pipeline);
+ encode_set_default_settings(enc);
+
+ mat4 model_affine = mat4_ident();
+ mat4 view, proj;
+ camera_view_projection(&cam, 1000, 1000, &view, &proj);
+
+ // Feed shader data
+ pbr_bind_data.mvp_matrices = (mvp_matrix_uniforms){.model = model_affine, .view = view, .projection = proj};
+ pbr_bind_data.material = pbr_params;
+ pbr_bind_data.lights = (pbr_params_light_uniforms){.viewPos = cam.position /* TODO: point lights*/};
+ pbr_uniforms.data = &pbr_bind_data;
+ encode_bind_shader_data(enc, 0, &pbr_uniforms);
+
+ // Record draw call
+ /* draw_mesh(&sphere, &model_affine, &cam); */
+ encode_set_vertex_buffer(enc, sphere.vertex_buffer);
+ encode_set_index_buffer(enc, sphere.index_buffer);
+ encode_draw_indexed(enc, sphere.geometry->indices->len);
+
+ // End recording
+ gpu_cmd_encoder_end_render(enc);
+
+ gpu_cmd_buffer buf = gpu_cmd_encoder_finish(enc);
+ gpu_queue_submit(&buf);
+ // Submit
+ gpu_backend_end_frame();
+ }
+
+ renderer_shutdown(&g_core.renderer);
+
+ return 0;
+}
diff --git a/examples/primitives/ex_primitives.c b/examples/primitives/ex_primitives.c
index 8ce2bf2..2109215 100644
--- a/examples/primitives/ex_primitives.c
+++ b/examples/primitives/ex_primitives.c
@@ -50,7 +50,7 @@ int main() {
.scale = 1.0 };
mat4 sphere_model = transform_to_mat(&transform);
- mat4 cube_model = mat4_translation(vec3(-2.,0,0));
+ mat4 cube_model = mat4_translation(vec3(-2., 0, 0));
draw_mesh(&cube, &cube_model, &cam);
draw_mesh(&sphere, &sphere_model, &cam);
diff --git a/src/colours.h b/src/colours.h
index a981c6c..ac8996a 100644
--- a/src/colours.h
+++ b/src/colours.h
@@ -13,6 +13,7 @@ typedef struct rgba {
#define COLOUR_WHITE ((rgba){ 1.0, 1.0, 1.0, 1.0 })
#define rgba_to_vec4(color) (vec4(color.r, color.g, color.b, color.a))
+#define rgba_to_vec3(color) (vec3(color.r, color.g, color.b))
// Thanks ChatGPT
#define STONE_50 ((rgba){ 0.980, 0.980, 0.976, 1.0 })
diff --git a/src/maths/maths.h b/src/maths/maths.h
index 80ce04d..fa58088 100644
--- a/src/maths/maths.h
+++ b/src/maths/maths.h
@@ -314,7 +314,7 @@ static inline mat4 transform_to_mat(transform *tf) {
mat4 scale = mat4_scale(tf->scale);
mat4 rotation = mat4_rotation(tf->rotation);
mat4 translation = mat4_translation(tf->position);
- return mat4_mult( mat4_mult(scale, rotation), translation);
+ return mat4_mult(mat4_mult(scale, rotation), translation);
}
// --- Sizing asserts
diff --git a/src/maths/primitives.c b/src/maths/primitives.c
index b6b5784..86f9261 100644
--- a/src/maths/primitives.c
+++ b/src/maths/primitives.c
@@ -199,38 +199,38 @@ geometry_data geo_create_uvsphere(f32 radius, u32 north_south_lines, u32 east_we
u32 i1 = i + 1;
u32 i2 = (i + 1) % north_south_lines + 1;
push_triangle(indices, 0, i1, i2);
- TRACE("Push triangle (%.2f %.2f %.2f)->(%.2f %.2f %.2f)->(%.2f %.2f %.2f)\n",
- vertices->data[0].static_3d.position.x, vertices->data[0].static_3d.position.y,
- vertices->data[0].static_3d.position.z, vertices->data[i1].static_3d.position.x,
- vertices->data[i1].static_3d.position.y, vertices->data[i1].static_3d.position.z,
- vertices->data[i2].static_3d.position.x, vertices->data[i2].static_3d.position.y,
- vertices->data[i2].static_3d.position.z);
+ /* TRACE("Push triangle (%.2f %.2f %.2f)->(%.2f %.2f %.2f)->(%.2f %.2f %.2f)\n", */
+ /* vertices->data[0].static_3d.position.x, vertices->data[0].static_3d.position.y, */
+ /* vertices->data[0].static_3d.position.z, vertices->data[i1].static_3d.position.x, */
+ /* vertices->data[i1].static_3d.position.y, vertices->data[i1].static_3d.position.z, */
+ /* vertices->data[i2].static_3d.position.x, vertices->data[i2].static_3d.position.y, */
+ /* vertices->data[i2].static_3d.position.z); */
u32 bot = vertices->len - 1;
u32 i3 = i + north_south_lines * (east_west_lines - 2) + 1;
u32 i4 = (i + 1) % north_south_lines + north_south_lines * (east_west_lines - 2) + 1;
- push_triangle(indices, bot, i3, i4);
+ push_triangle(indices, i3, bot, i4);
}
// quads
for (u32 i = 0; i < east_west_lines - 2; i++) {
u32 ring_start = i * north_south_lines + 1;
u32 next_ring_start = (i + 1) * north_south_lines + 1;
- printf("ring start %d next ring start %d\n", ring_start, next_ring_start);
- print_vec3(vertices->data[ring_start].static_3d.position);
- print_vec3(vertices->data[next_ring_start].static_3d.position);
+ /* printf("ring start %d next ring start %d\n", ring_start, next_ring_start); */
+ /* print_vec3(vertices->data[ring_start].static_3d.position); */
+ /* print_vec3(vertices->data[next_ring_start].static_3d.position); */
for (u32 j = 0; j < north_south_lines; j++) {
u32 i0 = ring_start + j;
u32 i1 = next_ring_start + j;
u32 i2 = ring_start + (j + 1) % north_south_lines;
u32 i3 = next_ring_start + (j + 1) % north_south_lines;
push_triangle(indices, i0, i1, i2);
- TRACE("Push triangle (%.2f %.2f %.2f)->(%.2f %.2f %.2f)->(%.2f %.2f %.2f)\n",
- vertices->data[i0].static_3d.position.x, vertices->data[i0].static_3d.position.y,
- vertices->data[i0].static_3d.position.z, vertices->data[i1].static_3d.position.x,
- vertices->data[i1].static_3d.position.y, vertices->data[i1].static_3d.position.z,
- vertices->data[i2].static_3d.position.x, vertices->data[i2].static_3d.position.y,
- vertices->data[i2].static_3d.position.z);
- // push_triangle(indices, i2, i1, i3);
+ /* TRACE("Push triangle (%.2f %.2f %.2f)->(%.2f %.2f %.2f)->(%.2f %.2f %.2f)\n", */
+ /* vertices->data[i0].static_3d.position.x, vertices->data[i0].static_3d.position.y, */
+ /* vertices->data[i0].static_3d.position.z, vertices->data[i1].static_3d.position.x, */
+ /* vertices->data[i1].static_3d.position.y, vertices->data[i1].static_3d.position.z, */
+ /* vertices->data[i2].static_3d.position.x, vertices->data[i2].static_3d.position.y, */
+ /* vertices->data[i2].static_3d.position.z); */
+ push_triangle(indices, i2, i1, i3);
}
}
diff --git a/src/renderer/backends/opengl/backend_opengl.c b/src/renderer/backends/opengl/backend_opengl.c
index 5a11f39..478ba0c 100644
--- a/src/renderer/backends/opengl/backend_opengl.c
+++ b/src/renderer/backends/opengl/backend_opengl.c
@@ -55,7 +55,7 @@ bool gpu_backend_init(const char* window_name, struct GLFWwindow* window) {
}
glEnable(GL_DEPTH_TEST);
- // glFrontFace(GL_CW);
+ glEnable(GL_CULL_FACE);
return true;
}
@@ -93,8 +93,13 @@ gpu_pipeline* gpu_graphics_pipeline_create(struct graphics_pipeline_desc descrip
pipeline->uniform_bindings[binding_id] = ubo_handle;
gpu_buffer* ubo_buf = BUFFER_GET(ubo_handle);
- u32 blockIndex = glGetUniformBlockIndex(pipeline->shader_id, "Matrices");
- printf("Block index for Matrices: %d", blockIndex);
+ i32 blockIndex = glGetUniformBlockIndex(pipeline->shader_id, binding.label);
+ /* printf("Block index for Matrices: %d", blockIndex); */
+ if (blockIndex < 0) {
+ WARN("Couldn't retrieve block index for uniform block '%s'", binding.label);
+ } else {
+ DEBUG("Retrived block index %d for %s", blockIndex, binding.label);
+ }
u32 blocksize;
glGetActiveUniformBlockiv(pipeline->shader_id, blockIndex, GL_UNIFORM_BLOCK_DATA_SIZE,
&blocksize);
@@ -259,7 +264,7 @@ buffer_handle gpu_buffer_create(u64 size, gpu_buffer_type buf_type, gpu_buffer_f
TRACE("Upload data (%d bytes) as part of buffer creation", size);
glBufferData(gl_buf_type, buffer->size, data, gl_buf_usage);
} else {
- TRACE("Allocating the correct size anyway");
+ TRACE("Allocating but not uploading (%d bytes)", size);
glBufferData(gl_buf_type, buffer->size, NULL, gl_buf_usage);
}
diff --git a/src/renderer/backends/opengl/backend_opengl.h b/src/renderer/backends/opengl/backend_opengl.h
index ccdb446..cde52a3 100644
--- a/src/renderer/backends/opengl/backend_opengl.h
+++ b/src/renderer/backends/opengl/backend_opengl.h
@@ -47,7 +47,6 @@ typedef struct gpu_texture {
} gpu_texture;
typedef struct opengl_support {
-
} opengl_support;
u32 shader_create_separate(const char *vert_shader, const char *frag_shader);
diff --git a/src/renderer/builtin_materials.h b/src/renderer/builtin_materials.h
new file mode 100644
index 0000000..c284acc
--- /dev/null
+++ b/src/renderer/builtin_materials.h
@@ -0,0 +1,81 @@
+/**
+ * @file builtin_materials.h
+ * @author your name (you@domain.com)
+ * @brief
+ * @version 0.1
+ * @date 2024-06-15
+ *
+ * @copyright Copyright (c) 2024
+ *
+ */
+#pragma once
+
+#include "colours.h"
+#include "defines.h"
+#include "ral.h"
+#include "ral_types.h"
+
+// Currently supported materials
+// - Blinn Phong (textured)
+// - PBR (params)
+// - PBR (textured)
+
+// Thoughts
+// --------
+//
+// A material and a shader are inextricably linked. The input data for a shader needs the material.
+// However, a shader may require more than just a material?
+
+// --- Common uniform blocks
+
+/* In glsl code we call it 'MVP_Matrices' */
+typedef struct mvp_matrix_uniforms {
+ mat4 model;
+ mat4 view;
+ mat4 projection;
+} mvp_matrix_uniforms;
+
+// --- PBR (params)
+
+typedef struct pbr_params_material_uniforms {
+ vec3 albedo;
+ f32 metallic;
+ f32 roughness;
+ f32 ao;
+} pbr_params_material_uniforms;
+
+typedef struct pbr_params_light_uniforms {
+ vec3 viewPos;
+ // TODO: PointLights
+
+} pbr_params_light_uniforms;
+
+typedef struct pbr_params_bindgroup {
+ mvp_matrix_uniforms mvp_matrices;
+ pbr_params_material_uniforms material;
+ pbr_params_light_uniforms lights;
+} pbr_params_bindgroup;
+
+static shader_data_layout pbr_params_shader_layout(void* data) {
+ pbr_params_bindgroup* d = (pbr_params_bindgroup*)data;
+ bool has_data = data != NULL;
+
+ shader_binding b1 = { .label = "MVP_Matrices",
+ .type = SHADER_BINDING_BYTES,
+ .stores_data = has_data,
+ .data = { .bytes = { .size = sizeof(mvp_matrix_uniforms) } } };
+
+ shader_binding b2 = { .label = "PBR_Params",
+ .type = SHADER_BINDING_BYTES,
+ .stores_data = has_data,
+ .data = { .bytes = { .size = sizeof(pbr_params_material_uniforms) } } };
+
+ shader_binding b3 = { .label = "Scene_Lights",
+ .type = SHADER_BINDING_BYTES,
+ .stores_data = has_data,
+ .data = { .bytes = { .size = sizeof(pbr_params_light_uniforms) } } };
+
+ return (shader_data_layout){ .name = "pbr_params", .bindings = { b1, b2, b3 }, .bindings_count = 3
+
+ };
+}
diff --git a/src/renderer/ral.c b/src/renderer/ral.c
index 123c932..e73843b 100644
--- a/src/renderer/ral.c
+++ b/src/renderer/ral.c
@@ -42,10 +42,11 @@ void vertex_desc_add(vertex_description* builder, const char* name, vertex_attri
}
vertex_description static_3d_vertex_description() {
- vertex_description builder = { .debug_label = "vertex" };
- vertex_desc_add(&builder, "position", ATTR_F32x3);
- vertex_desc_add(&builder, "normal", ATTR_F32x3);
- vertex_desc_add(&builder, "texCoords", ATTR_F32x2);
+ vertex_description builder = { .debug_label = "Standard static 3d vertex format" };
+ vertex_desc_add(&builder, "inPosition", ATTR_F32x3);
+ vertex_desc_add(&builder, "inNormal", ATTR_F32x3);
+ vertex_desc_add(&builder, "inTexCoords", ATTR_F32x2);
+ builder.use_full_vertex_size = true;
return builder;
}
diff --git a/src/renderer/render.h b/src/renderer/render.h
index 35e2899..4e8035e 100644
--- a/src/renderer/render.h
+++ b/src/renderer/render.h
@@ -66,14 +66,8 @@ texture_data texture_data_load(const char* path, bool invert_y);
texture_handle texture_data_upload(texture_data data, bool free_on_upload);
/** @brief load all of the texture for a PBR material and returns an unnamed material */
-material pbr_material_load(
- char* albedo_path,
- char* normal_path,
- bool metal_roughness_combined,
- char* metallic_path,
- char* roughness_map,
- char* ao_map
-);
+material pbr_material_load(char* albedo_path, char* normal_path, bool metal_roughness_combined,
+ char* metallic_path, char* roughness_map, char* ao_map);
buffer_handle buffer_create(const char* debug_name, u64 size);
bool buffer_destroy(buffer_handle buffer);
diff --git a/src/renderer/render_types.h b/src/renderer/render_types.h
index 1485ae4..8588b87 100644
--- a/src/renderer/render_types.h
+++ b/src/renderer/render_types.h
@@ -10,10 +10,10 @@
*/
#pragma once
+#include "colours.h"
#include "defines.h"
#include "ral.h"
#include "ral_types.h"
-#include "colours.h"
#if defined(CEL_PLATFORM_WINDOWS)
// #include "backend_dx11.h"
#endif
@@ -66,10 +66,11 @@ typedef struct texture_data {
typedef enum material_kind {
MAT_BLINN_PHONG,
MAT_PBR,
- MAT_PBR_PARAMS, // uses float values to represent a surface uniformly
+ MAT_PBR_PARAMS, // uses float values to represent a surface uniformly
MAT_COUNT
} material_kind;
-static const char* material_kind_names[] = { "Blinn Phong", "PBR (Textures)", "PBR (Params)", "Count (This should be an error)"};
+static const char* material_kind_names[] = { "Blinn Phong", "PBR (Textures)", "PBR (Params)",
+ "Count (This should be an error)" };
typedef struct blinn_phong_material {
char name[256];
diff --git a/src/renderer/static_pipeline.h b/src/renderer/static_pipeline.h
index 78f09f2..15e8842 100644
--- a/src/renderer/static_pipeline.h
+++ b/src/renderer/static_pipeline.h
@@ -1,6 +1,6 @@
#pragma once
-#include "maths_types.h"
#include "defines.h"
+#include "maths_types.h"
#include "ral.h"
#include "ral_types.h"
#include "render_types.h"
@@ -26,5 +26,5 @@ static shader_data_layout mvp_uniforms_layout(void* data) {
if (has_data) {
b1.data.bytes.data = &d->mvp;
}
- return (shader_data_layout){ .name = "global_ubo", .bindings = { b1}, .bindings_count = 1 };
+ return (shader_data_layout){ .name = "global_ubo", .bindings = { b1 }, .bindings_count = 1 };
}
diff --git a/src/scene.h b/src/scene.h
index f60bfff..5ac7542 100644
--- a/src/scene.h
+++ b/src/scene.h
@@ -26,7 +26,6 @@ typedef struct scene {
// TODO: tree - transform_hierarchy
} scene;
-
void scene_init(scene* s);
void scene_free(scene* s);
diff --git a/xmake.lua b/xmake.lua
index 55af4f2..67a21a0 100644
--- a/xmake.lua
+++ b/xmake.lua
@@ -223,6 +223,13 @@ target("gltf")
add_files("examples/gltf_loading/ex_gltf_loading.c")
set_rundir("$(projectdir)")
+target("pbr_params")
+ set_kind("binary")
+ set_group("examples")
+ add_deps("core_static")
+ add_files("examples/pbr_params/ex_pbr_params.c")
+ set_rundir("$(projectdir)")
+
-- target("transforms")
-- set_kind("binary")
-- set_group("examples")