Add mipmap support and refactor texture handling

Note: Currently version still have lots of fireflies after applying normal map. And those fireflies are mostly coming from the nee sky. Need to double check the sky cdf and ray intersection.

Changed the `hit_result_t` structure to rename a parameter in `RayIntersection.h`.
Removed the `normal` field from the `path_output` structure in `Common.h`.
Added new fields `screen_size`, `camera_position`, and `camera_direction` in `Material.h`.
Changed the `mipmap_t` structure in `Texture.h` to include a `max_mip` field and modify the `data` field.
Changed the `texture_load` function in `Texture.c` to include a `mipmap` parameter and improve texture data handling.
Changed the `path_trace` function in `PathTracing.c` to update the `shading_context_t` structure and ray creation.
Changed the `evaluate_bsdf_directional` function in `LightEvaluation.c` to modify angular radius calculation.
Changed the `sky_create_hdr_sky` and `evaluate_bsdf_hdr_sky` functions in `SkyLight.c` to enhance texture sampling.
Changed the `get_surface_data` function in `SimpleLit.c` to incorporate camera distance and view direction in calculations.
Changed the `texture_get_pixel` function in `Texture.c` to improve pixel data retrieval.
Changed the `warp_uv` function to use a `vec2s` structure for UV coordinates.
Changed the `texture_sample` function to include additional parameters for improved sampling accuracy.
Changed the `scene_setup` function in `main.c` to adjust sun light intensity and HDRI texture loading.
This commit is contained in:
2025-05-06 17:46:35 +09:00
parent 3be0bbc7f3
commit e1693764f7
12 changed files with 366 additions and 104 deletions

View File

@@ -32,7 +32,7 @@ static bool scene_setup(scene_t* scene)
directional_light_t* sun_light = &scene->lights.directional_lights[sun.id];
sun_light->direction = glms_vec3_normalize((vec3s){0.6f, 1.0f, 0.25f});
sun_light->color = (vec3s){1.0f, 0.93f, 0.87f};
sun_light->intensity = 1.0f;
sun_light->intensity = 2.0f;
sun_light->angular_diameter = 0.53f;
//scene->lights.sky_light = sky_create_constant_sky(&(constant_sky_data_t)
@@ -40,7 +40,8 @@ static bool scene_setup(scene_t* scene)
// .color = (vec3s){0.73f, 0.82f, 1.0f},
// .intensity = 1.0f,
//});
texture_entity_t hdri = texture_load(HDRI_PATH, false, FLOAT_32, &scene->textures);
texture_entity_t hdri = texture_load(HDRI_PATH, false, false, FLOAT_32, &scene->textures);
scene->textures.buffer[hdri.id].texture.wrap_mode = CLAMP;
scene->lights.sky_light = sky_create_hdr_sky(&scene->textures, hdri, 1.0f);
return scene->lights.sky_light.data != NULL;