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:
@@ -1,6 +1,7 @@
|
||||
#ifndef TEXTURE_H
|
||||
#define TEXTURE_H
|
||||
|
||||
#include "Common.h"
|
||||
#include "cglm/struct/vec4.h"
|
||||
|
||||
#include <stdint.h>
|
||||
@@ -61,6 +62,7 @@ void texture_collection_resize(texture_collection_t* textures, uint16_t size);
|
||||
void texture_collection_free(texture_collection_t* textures);
|
||||
|
||||
texture_entity_t texture_load(const char* filename, bool srgb, stride_t stride, texture_collection_t* textures);
|
||||
vec4s texture_get_pixel(const texture_t* texture, uint32_t x, uint32_t y);
|
||||
vec4s texture_sample(const texture_t* texture, float u, float v);
|
||||
void texture_free(texture_t* texture);
|
||||
|
||||
@@ -84,4 +86,14 @@ inline texture_t* get_texture(const texture_collection_t* textures, texture_enti
|
||||
return &textures->buffer[entity.id].texture;
|
||||
}
|
||||
|
||||
inline size_t texture_get_pixel_index(texture_t* texture, uint32_t x, uint32_t y)
|
||||
{
|
||||
return (size_t)(y * texture->width + x) * texture->channel_count * texture->stride;
|
||||
}
|
||||
|
||||
inline void texture_uv_to_index(texture_t* texture, vec2s uv, uint32_t* x, uint32_t* y)
|
||||
{
|
||||
uv_to_index(uv, texture->width, texture->height, x, y);
|
||||
}
|
||||
|
||||
#endif // TEXTURE_H
|
||||
|
||||
Reference in New Issue
Block a user