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:
@@ -145,7 +145,7 @@ static inline void warp_uv(wrap_mode_t mode, float* u, float* v)
|
||||
}
|
||||
}
|
||||
|
||||
static vec4s get_pixel_color(const texture_t* texture, uint32_t x, uint32_t y)
|
||||
vec4s texture_get_pixel(const texture_t* texture, uint32_t x, uint32_t y)
|
||||
{
|
||||
if (x >= texture->width || y >= texture->height)
|
||||
{
|
||||
@@ -194,7 +194,7 @@ static vec4s nearest_filter(const texture_t* texture, float u, float v)
|
||||
x = x < texture->width ? x : texture->width - 1;
|
||||
y = y < texture->height ? y : texture->height - 1;
|
||||
|
||||
return get_pixel_color(texture, x, y);
|
||||
return texture_get_pixel(texture, x, y);
|
||||
}
|
||||
|
||||
static vec4s linear_filter(const texture_t* texture, float u, float v)
|
||||
@@ -217,10 +217,10 @@ static vec4s linear_filter(const texture_t* texture, float u, float v)
|
||||
y1 = y1 < texture->height ? y1 : texture->height - 1;
|
||||
|
||||
// Sample 4 texels
|
||||
vec4s c00 = get_pixel_color(texture, x0, y0);
|
||||
vec4s c10 = get_pixel_color(texture, x1, y0);
|
||||
vec4s c01 = get_pixel_color(texture, x0, y1);
|
||||
vec4s c11 = get_pixel_color(texture, x1, y1);
|
||||
vec4s c00 = texture_get_pixel(texture, x0, y0);
|
||||
vec4s c10 = texture_get_pixel(texture, x1, y0);
|
||||
vec4s c01 = texture_get_pixel(texture, x0, y1);
|
||||
vec4s c11 = texture_get_pixel(texture, x1, y1);
|
||||
|
||||
// Interpolate along x
|
||||
vec4s c0 = glms_vec4_lerp(c00, c10, sx);
|
||||
|
||||
Reference in New Issue
Block a user