Add HDR sky lighting support and improve rendering
Added support for HDR sky lighting, including sampling environment maps with a hierarchical CDF. Added new utility functions for handling HDR sky data, including memory management and sampling functions. Added functions to improve texture handling, including pixel data retrieval and texture coordinate management. Changed the path tracing algorithm to enhance light evaluation from HDR skies and adjust light contribution calculations. Changed BSDF sampling functions to utilize constants from Common.h for better readability. Changed the main application logic to load HDR textures and configure the scene with improved lighting settings. Refactored ray intersection logic to enhance accuracy and performance in triangle intersections. Adjusted the sample count in the rendering configuration to optimize performance. Updated the README.md to document new features and example renders.
This commit is contained in:
@@ -86,7 +86,7 @@ static vec3s sample_bsdf_simple_lit(const shading_context_t* context, const surf
|
||||
float specular_exponent = roughness_to_blinn_phong_specular_exponent(surface_data->roughness);
|
||||
|
||||
float theta = acosf(powf(sobol_sample(sample_index, d1), 1.0f / (specular_exponent + 1.0f)));
|
||||
float phi = 2.0f * (float)M_PI * sobol_sample(sample_index, d2);
|
||||
float phi = 2.0f * PI * sobol_sample(sample_index, d2);
|
||||
// float theta = acosf(powf(random_float(), 1.0f / (specular_exponent + 1.0f)));
|
||||
// float phi = 2.0f * (float)M_PI * random_float();
|
||||
vec3s h_ts = (vec3s)
|
||||
@@ -180,7 +180,7 @@ static vec3s evaluate_bsdf_simple_lit(const shading_context_t* context, const su
|
||||
|
||||
float specular_exponent = roughness_to_blinn_phong_specular_exponent(surface_data->roughness);
|
||||
// Normalization factor D (Blinn-Phong distribution)
|
||||
float D_norm = (specular_exponent + 2.0f) / (2.0f * (float)M_PI); // Common normalization
|
||||
float D_norm = (specular_exponent + 2.0f) / (2.0f * PI); // Common normalization
|
||||
float D = D_norm * powf(n_dot_h, specular_exponent);
|
||||
vec3s F = fresnel_schlick_vec3(f0, v_dot_h);
|
||||
|
||||
@@ -242,7 +242,7 @@ path_output simple_lit_render_loop(const void* properties, const shading_context
|
||||
{
|
||||
vec3s bsdf_sky_light = evaluate_bsdf_simple_lit(context, &surface_data, sky_output.wi);
|
||||
float pdf_bsdf = sample_bsdf_pdf_simple_lit(context, &surface_data, sky_output.wi);
|
||||
vec3s sky_light = weight_nee_light(bsdf_sky_light, sky_output.direct_lighting, sky_output.pdf, pdf_bsdf);
|
||||
vec3s sky_light = weight_nee_light(bsdf_sky_light, sky_output.direct_lighting, pdf_bsdf, sky_output.pdf);
|
||||
output.direct_lighting = glms_vec3_add(output.direct_lighting, sky_light);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user