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:
@@ -34,20 +34,26 @@ vec3s normal_unpack(vec3s normal)
|
||||
float dot_xy = glm_clamp_zo(unpacked_normal.x * unpacked_normal.x + unpacked_normal.y * unpacked_normal.y);
|
||||
unpacked_normal.z = fmaxf(FLT_MIN, sqrtf(1.0f - dot_xy));
|
||||
|
||||
return unpacked_normal;
|
||||
return glms_vec3_normalize(unpacked_normal);
|
||||
}
|
||||
|
||||
vec3s normal_ts_to_ws(vec3s normal, vec3s tangent)
|
||||
vec3s normal_ts_to_ws(vec3s normal, vec3s geo_normal, vec3s tangent)
|
||||
{
|
||||
vec3s t = glms_vec3_normalize(tangent);
|
||||
vec3s b = glms_vec3_cross(normal, t);
|
||||
tangent = glms_vec3_normalize(tangent);
|
||||
vec3s bitangent = glms_vec3_cross(geo_normal, tangent);
|
||||
|
||||
float w = (glms_vec3_dot(glms_vec3_cross(geo_normal, tangent), bitangent) < 0.0f) ? -1.0f : +1.0f;
|
||||
|
||||
float proj = glms_vec3_dot(geo_normal, tangent);
|
||||
vec3s t_prime = glms_vec3_normalize(glms_vec3_sub(tangent, glms_vec3_scale(geo_normal, proj)));
|
||||
vec3s b_prime = glms_vec3_scale(glms_vec3_cross(geo_normal, t_prime), w);
|
||||
|
||||
// Matrix in cglm is column-major, not row-major
|
||||
mat3s tbn =
|
||||
{
|
||||
t.x, b.x, normal.x,
|
||||
t.y, b.y, normal.y,
|
||||
t.z, b.z, normal.z
|
||||
t_prime.x, t_prime.y, t_prime.z,
|
||||
b_prime.x, b_prime.y, b_prime.z,
|
||||
geo_normal.x, geo_normal.y, geo_normal.z
|
||||
};
|
||||
|
||||
return glms_vec3_normalize(glms_mat3_mulv(tbn, normal));
|
||||
@@ -242,3 +248,12 @@ vec3s random_uniform_cdf_direction_angular(vec3s direction, uint32_t index, floa
|
||||
vec3s world_dir = glms_vec3_add(glms_vec3_add(term_u, term_v), term_w);
|
||||
return world_dir;
|
||||
}
|
||||
|
||||
|
||||
// Must use this function to weight any nee light contribution before accumulate.
|
||||
vec3s weight_nee_light(vec3s bsdf, vec3s light, float pdf_bsdf, float pdf_sky)
|
||||
{
|
||||
light = glms_vec3_mul(bsdf, light);
|
||||
float weight = power_heuristic(pdf_sky, pdf_bsdf);
|
||||
return glms_vec3_scale(light, weight);
|
||||
}
|
||||
Reference in New Issue
Block a user