Update project files and enhance rendering system

Added:
- Updated `.gitignore` to ignore the `[Bb]uild/` directory.
- Additional tasks added to the roadmap in `README.md` for light unit standardization and GPU backend support.

Changed:
- Removed line in `settings.json` that disabled error squiggles for C/C++ code.
- Modified `Triangle.h` to include `material_id` in `triangle_t` and reorganized properties.
- Reordered parameters in `triangle_collection_init` for clarity.
- Updated `shading_context_t` in `Material.h` and added size parameter to `material_create`.
- Streamlined initialization in `scene_init` and updated `scene_free` for proper resource management.
- Updated `window_create` in `Window.h` to accept a `render_job_t` parameter.
- Introduced `renderer_start` in `Renderer.c` to handle rendering jobs and optimized pixel rendering logic.
This commit is contained in:
2025-04-23 22:24:02 +09:00
parent 9cc420693c
commit 17872804c5
24 changed files with 523083 additions and 807 deletions

View File

@@ -1,10 +1,11 @@
#include "Material/Material.h"
#include <string.h>
bool material_collection_init(size_t size, material_collection_t* materials)
{
if (size > 254)
{
size = 254; // Limit the count to 254 to fit in a uint8_t
size = 254;
}
material_collection_t temp = {0};
@@ -40,12 +41,21 @@ void material_collection_free(material_collection_t* materials)
{
if (materials->buffer != NULL)
{
for (uint8_t i; i < materials->count; i++)
{
void* data = materials->buffer[i].data;
if (data != NULL)
{
free(data);
}
}
free(materials->buffer);
materials->buffer = NULL;
}
}
material_entity_t material_create(sample_bsdf_f sample, sample_bsdf_pdf_f sample_pdf, evaluate_bsdf_f evaluate, void* data, material_collection_t* collection)
material_entity_t material_create(sample_bsdf_f sample, sample_bsdf_pdf_f sample_pdf, evaluate_bsdf_f evaluate, void* data, size_t size_of_data, material_collection_t* collection)
{
material_t material = {0};
@@ -57,7 +67,13 @@ material_entity_t material_create(sample_bsdf_f sample, sample_bsdf_pdf_f sample
material.sample_bsdf = sample;
material.sample_bsdf_pdf = sample_pdf;
material.evaluate_bsdf = evaluate;
material.data = data;
material.data = malloc(size_of_data);
if (material.data == NULL)
{
return (material_entity_t){.id = 255};
}
memcpy(material.data, data, size_of_data);
material_entity_t entity = {.id = collection->count};

View File

@@ -9,7 +9,7 @@ static vec3s DIELECTRIC_REFLECTIVE = {0.04f, 0.04f, 0.04f}; // Standard dielectr
// Simple lit, but keep it unbiased as much as possible
vec3s sample_bsdf_simple_lit(const void* data, vec3s normal, vec3s wo, uint32_t sample_index, uint32_t bounce, float* pdf_out)
{
simple_lit_data_t shading_data = *(const simple_lit_data_t*)data;
simple_lit_data_t shading_data = *(const simple_lit_data_t*)data;
//TODO: having a bsdf data struct to avoid recomputing the same thing in both sample and evaluate
vec3s f0 = glms_vec3_lerp(DIELECTRIC_REFLECTIVE, shading_data.albedo, shading_data.metallic);
@@ -129,8 +129,8 @@ float sample_bsdf_pdf_simple_lit(const void* data, vec3s normal, vec3s wo, vec3s
vec3s evaluate_bsdf_simple_lit(const shading_context_t* context, const void* data)
{
simple_lit_data_t shading_data = *(const simple_lit_data_t*)data;
shading_context_t shading_context = *context;
simple_lit_data_t shading_data = *(const simple_lit_data_t*)data;
shading_context_t shading_context = *context;
vec3s h = glms_vec3_normalize(glms_vec3_add(shading_context.wi, shading_context.wo));
float n_dot_l = fmaxf(FLT_EPSILON, glms_vec3_dot(shading_context.normal, shading_context.wi));