Fixed cdf and added Standard Lit

This commit is contained in:
2025-12-29 22:01:44 +09:00
parent e1693764f7
commit adee5acd10
24 changed files with 830 additions and 570 deletions

View File

@@ -11,6 +11,7 @@ typedef struct
{
vec3s position;
vec3s normal;
vec3s geometric_normal;
vec3s tangent;
vec2s uv;
vec3s wo;

View File

@@ -17,16 +17,21 @@ typedef struct
{
uint32_t width;
uint32_t height;
texture_entity_t texture;
texture_handle_t texture;
float intensity;
float total_weight;
vec3s* cdf_cache; // Precomputed cache for sampling, xy for texture coordinates, z for PDF
// Normalized discrete probability mass per texel (sum==1), indexed by [y * width + x]
float* pdf_uv_mass;
// CDF tables for correct runtime sampling (keeps wi/pdf consistent)
float* cdf_x; // size: width
float* cdf_y_transposed; // size: width * height, layout: [x * height + y]
} hdr_sky_data_t;
sky_light_t sky_create_constant_sky(const constant_sky_data_t* data);
path_output evaluate_bsdf_const_sky(const void* data, const light_shading_context_t* context, vec3s throughput, uint32_t sample_index);
sky_light_t sky_create_hdr_sky(const texture_collection_t* textures, texture_entity_t hdri_entity, float intensity);
sky_light_t sky_create_hdr_sky(const texture_collection_t* textures, texture_handle_t hdri_entity, float intensity);
path_output evaluate_bsdf_hdr_sky(const void* data, const light_shading_context_t* context, vec3s throughput, uint32_t sample_index);
void hdr_sky_free(hdr_sky_data_t* data);