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:
@@ -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
|
||||
|
||||
@@ -6,6 +6,10 @@ hit_result_t ray_intersect_triangle(ray_t ray, triangle_t triangle)
|
||||
{
|
||||
hit_result_t result = {0};
|
||||
|
||||
vec3s edge1 = glms_vec3_sub(triangle.point_2, triangle.point_1);
|
||||
vec3s edge2 = glms_vec3_sub(triangle.point_3, triangle.point_2);
|
||||
vec3s edge3 = glms_vec3_sub(triangle.point_1, triangle.point_3);
|
||||
|
||||
vec3s normal_face = triangle.normal_face;
|
||||
float n_dot_r = glms_vec3_dot(normal_face, ray.direction);
|
||||
if (n_dot_r > 0.0f)
|
||||
@@ -30,9 +34,7 @@ hit_result_t ray_intersect_triangle(ray_t ray, triangle_t triangle)
|
||||
vec3s intersection_point = glms_vec3_add(ray.origin, glms_vec3_scale(ray.direction, distance));
|
||||
|
||||
// Check if the intersection point is inside the triangle using barycentric coordinates
|
||||
vec3s edge1 = glms_vec3_sub(triangle.point_2, triangle.point_1);
|
||||
vec3s edge2 = glms_vec3_sub(triangle.point_3, triangle.point_2);
|
||||
vec3s edge3 = glms_vec3_sub(triangle.point_1, triangle.point_3);
|
||||
|
||||
vec3s vp = glms_vec3_sub(intersection_point, triangle.point_1);
|
||||
vec3s vp2 = glms_vec3_sub(intersection_point, triangle.point_2);
|
||||
vec3s vp3 = glms_vec3_sub(intersection_point, triangle.point_3);
|
||||
@@ -60,11 +62,7 @@ hit_result_t ray_intersect_triangle(ray_t ray, triangle_t triangle)
|
||||
|
||||
bool ray_intersect_aabb(ray_t ray, aabb_t aabb, float* enter_out, float* exit_out)
|
||||
{
|
||||
// vec3s inv_dir = glms_vec3_div(glms_vec3_one(), ray.direction);
|
||||
vec3s inv_dir;
|
||||
inv_dir.x = ray.direction.x != 0.0f ? 1.0f / ray.direction.x : FLT_MAX;
|
||||
inv_dir.y = ray.direction.y != 0.0f ? 1.0f / ray.direction.y : FLT_MAX;
|
||||
inv_dir.z = ray.direction.z != 0.0f ? 1.0f / ray.direction.z : FLT_MAX;
|
||||
vec3s inv_dir = glms_vec3_div(glms_vec3_one(), ray.direction);
|
||||
float t_near = -FLT_MIN;
|
||||
float t_far = FLT_MAX;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user