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

@@ -12,7 +12,7 @@ vec4s path_trace(const scene_t* scene, ray_t ray, uint32_t sample_index, uint16_
const material_collection_t* materials = &scene->materials;
const light_collection_t* lights = &scene->lights;
vec4s accumulated_color = glms_vec4_zero();
vec4s accumulated_color = (vec4s){0.0f, 0.0f, 0.0f, 1.0f};
vec3s throughput = glms_vec3_one();
ray_t active_ray = ray;
@@ -34,14 +34,14 @@ vec4s path_trace(const scene_t* scene, ray_t ray, uint32_t sample_index, uint16_
float weight = power_heuristic(pdf_bsdf, pdf_nee);
sky_light = glms_vec3_scale(sky_light, weight);
}
accumulated_color = glms_vec4_add(accumulated_color, glms_vec4(sky_light, 1.0f)); // TODO: Physical Skybox
accumulated_color = glms_vec4_add(accumulated_color, glms_vec4(sky_light, 0.0f)); // TODO: Physical Skybox
break;
}
// Add the emission of the hit material to the accumulated color
material_t* hit_material = &materials->buffer[triangles->buffer[closest_hit.triangle_id].material_id];
vec3s emission = hit_material->emission;
accumulated_color = glms_vec4_add(accumulated_color, glms_vec4(glms_vec3_mul(throughput, emission), 1.0f));
accumulated_color = glms_vec4_add(accumulated_color, glms_vec4(glms_vec3_mul(throughput, emission), 0.0f));
light_shading_context_t light_context = {
.normal = closest_hit.normal,
@@ -59,11 +59,11 @@ vec4s path_trace(const scene_t* scene, ray_t ray, uint32_t sample_index, uint16_
for (uint32_t i = 0; i < lights->directional_light_count; i++)
{
vec3s l = evaluate_bsdf_directional(lights->directional_lights[i], &light_context, throughput, sample_index);
accumulated_color = glms_vec4_add(accumulated_color, glms_vec4(l, 1.0f));
accumulated_color = glms_vec4_add(accumulated_color, glms_vec4(l, 0.0f));
}
vec3s sky_light = evaluate_bsdf_sky(scene, &light_context, throughput, sample_index);
accumulated_color = glms_vec4_add(accumulated_color, glms_vec4(sky_light, 1.0f));
accumulated_color = glms_vec4_add(accumulated_color, glms_vec4(sky_light, 0.0f));
// Bounce and prepare for the next iteration
vec3s wo = glms_vec3_negate(active_ray.direction); // We need to negate the direction of the incoming ray