Update AOV support, ray intersection logic, and README
Added: - AOV support for normals, albedo, and depth marked as completed. - New function `normal_unpack` in `BSDF.h`. - New field `esp` in `ray_t` structure in `RayIntersection.h`. Changed: - Updated `normal_ts_to_ws` to accept an additional parameter. - Refactored `weight_nee_light` for clarity. - Modified `RAY_EPSILON` for improved precision. - Updated `path_output` structure to include a `normal` field. - Normalized unpacked normal vector in `normal_unpack` function. - Updated `path_trace` to use closest hit ray intersection. - Updated `render_aov` to utilize closest hit logic. - Modified `ray_create` to initialize `esp` based on ray origin. - Improved accuracy in `offset_ray_origin` calculations. - Updated ray intersection logic in `ray_intersect_triangle` and `ray_intersect_aabb` to include epsilon checks. - Updated `evaluate_bsdf_directional` and `evaluate_bsdf_const_sky` for shadow rays. - Adjusted `sample_bsdf_simple_lit` for incoming light direction calculations. - Enhanced `render_pixel` to manage AOV flags effectively. - Changed camera rotation and light intensity in `scene_setup`. - Simplified texture loading by removing unnecessary sRGB conversion. Modified: - Several binary image files have been updated.
This commit is contained in:
@@ -56,7 +56,7 @@ vec4s render_debug(scene_t* scene, ray_t ray, uint16_t sample_index, int flag)
|
||||
return (vec4s){sobol_sample_value, sobol_sample_value, sobol_sample_value, 1.0f};
|
||||
|
||||
case DEBUG_UV:
|
||||
hit_result_t hit_result = ray_intersect_scene(&ray, scene);
|
||||
hit_result_t hit_result = ray_intersect_scene_closest(&ray, scene);
|
||||
return (vec4s){fmodf(fabsf(hit_result.uv.x), 1.0f), fmodf(fabsf(hit_result.uv.y), 1.0f), 0.0f, 1.0f};
|
||||
|
||||
default:
|
||||
|
||||
@@ -70,7 +70,7 @@ static inline uint16_t get_sample_count(uint16_t sample_count, aov_index_t index
|
||||
}
|
||||
}
|
||||
|
||||
static void render_pixel(const rendering_config_t* config, scene_t* scene, vec3s coord, uint32_t x, uint32_t y, bool request_aov, aov_output_t* pixel_output)
|
||||
static void render_pixel(const rendering_config_t* config, scene_t* scene, vec3s coord, uint32_t x, uint32_t y, aov_flags_t aov_flags, aov_output_t* pixel_output)
|
||||
{
|
||||
aov_output_t accumulated_color = {0};
|
||||
|
||||
@@ -103,8 +103,12 @@ static void render_pixel(const rendering_config_t* config, scene_t* scene, vec3s
|
||||
ray_t ray = ray_create(scene->camera.position, glms_vec3_normalize(glms_vec3_sub(image_plane_point, scene->camera.position)));
|
||||
|
||||
aov_output_t aov_output = {0};
|
||||
aov_output.beauty = path_trace(scene, ray, sobol_idx, config->max_depth);
|
||||
if (request_aov)
|
||||
if (has_flag(aov_flags, AOV_BEAUTY))
|
||||
{
|
||||
aov_output.beauty = path_trace(scene, ray, sobol_idx, config->max_depth);
|
||||
}
|
||||
|
||||
if (aov_flags != AOV_BEAUTY)
|
||||
{
|
||||
render_aov(scene, ray, sobol_idx, config->max_depth, &aov_output);
|
||||
}
|
||||
@@ -167,7 +171,7 @@ void renderer_start(render_job_t* job)
|
||||
}
|
||||
|
||||
aov_output_t pixel_output = {0};
|
||||
render_pixel(job->config, job->scene, coord, (uint32_t)x, (uint32_t)y, job->aov_flags != AOV_BEAUTY, &pixel_output);
|
||||
render_pixel(job->config, job->scene, coord, (uint32_t)x, (uint32_t)y, job->aov_flags, &pixel_output);
|
||||
update_aov(job->aov_target, &pixel_output, (uint32_t)x, (uint32_t)y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,16 +82,7 @@ texture_entity_t texture_load(const char* filename, bool srgb, stride_t stride,
|
||||
switch (stride)
|
||||
{
|
||||
case UINT_8:
|
||||
uint8_t* img_data = stbi_load(filename, &width, &height, &channels, 0);
|
||||
if (srgb)
|
||||
{
|
||||
// Convert to linear space if the texture is in sRGB format
|
||||
for (int i = 0; i < width * height * channels; i++)
|
||||
{
|
||||
img_data[i] = (uint8_t)(powf(img_data[i] / 255.0f, 2.2f) * 255.0f);
|
||||
}
|
||||
}
|
||||
data = (char*)img_data;
|
||||
data = stbi_load(filename, &width, &height, &channels, 0);
|
||||
break;
|
||||
|
||||
case UINT_16:
|
||||
|
||||
Reference in New Issue
Block a user