Enhance graphics library functionality and structure

Added new function signatures in `assimp-vc143-mt.lib` for improved logging, parsing, and vector operations.
Added new metadata and configuration information in `assimp-vc143-mt.dll` for versioning and licensing compliance.
Added Sobol sequence generation in `Sobol.c` for quasi-random sampling.
Added window message handling in `Window.c` for rendering graphics.
Added ray-triangle intersection tests in `RayIntersection.c` for collision detection.
Added functions for loading mesh data in `Mesh.c` to support 3D model import.
Added functions for managing triangle collections in `Triangle.c` to enhance geometric data handling.
Added light evaluation functions in `LightEvaluation.c` and `SkyLight.c` for realistic rendering.
Added sampling and evaluation functions for simple lit materials in `SimpleLit.c`.
Changed various header files to include copyright and licensing information.
Changed existing functions in multiple files to improve performance and clarity.
Removed unused code in several files to streamline the library.
This commit is contained in:
2025-04-18 01:54:26 +09:00
parent b915d56f73
commit bfc94f0008
138 changed files with 28915 additions and 534 deletions

126
header/Lighting/Light.h Normal file
View File

@@ -0,0 +1,126 @@
#ifndef LIGHT_H
#define LIGHT_H
#include "Algorithm/Sobol.h"
#include "Geometry/Triangle.h"
#include "Material/Material.h"
#include "cglm/struct/vec3.h"
typedef struct
{
vec3s normal;
vec3s hit_point;
vec3s wo;
vec3s throughput;
const triangle_collection_t* triangles;
const material_t* material;
} light_shading_context_t;
typedef vec3s (*evaluate_bsdf_sky_f) (const void* data, const light_shading_context_t* context, sobol_state_t* sobol_state);
typedef struct
{
evaluate_bsdf_sky_f evaluate_bsdf_sky;
void* data;
} sky_light_t;
typedef enum
{
LIGHT_TYPE_POINT,
LIGHT_TYPE_SPOT,
LIGHT_TYPE_AREA,
} punctual_light_type_e;
typedef struct
{
vec3s position;
vec3s color;
float intensity;
punctual_light_type_e type;
} punctual_light_t;
typedef struct
{
vec3s direction;
vec3s color;
float intensity;
float angular_diameter;
} directional_light_t;
typedef struct
{
uint32_t punctual_light_count;
uint32_t directional_light_count;
uint32_t max_punctual_lights;
uint32_t max_directional_lights;
sky_light_t sky_light;
punctual_light_t* punctual_lights;
directional_light_t* directional_lights;
} light_collection_t;
typedef struct
{
uint32_t id;
bool is_punctual;
} light_entity_t;
inline light_collection_t light_collection_create(uint32_t max_punctual_lights, uint32_t max_directional_lights)
{
light_collection_t collection = {0};
collection.max_punctual_lights = max_punctual_lights;
collection.max_directional_lights = max_directional_lights;
collection.punctual_light_count = 0;
collection.directional_light_count = 0;
collection.punctual_lights = (punctual_light_t*)malloc(max_punctual_lights * sizeof(punctual_light_t));
collection.directional_lights = (directional_light_t*)malloc(max_directional_lights * sizeof(directional_light_t));
return collection;
}
inline light_entity_t light_create_punctual_light(light_collection_t* collection)
{
if (collection->punctual_light_count >= collection->max_punctual_lights)
{
return (light_entity_t){0};
}
punctual_light_t light = {0};
collection->punctual_lights[collection->punctual_light_count] = light;
light_entity_t entity = {.id = collection->punctual_light_count, .is_punctual = true};
collection->punctual_light_count++;
return entity;
}
inline light_entity_t light_create_directional_light(light_collection_t* collection)
{
if (collection->directional_light_count >= collection->max_directional_lights)
{
return (light_entity_t){0};
}
directional_light_t light = {0};
collection->directional_lights[collection->directional_light_count] = light;
light_entity_t entity = {.id = collection->directional_light_count, .is_punctual = false};
collection->directional_light_count++;
return entity;
}
inline void light_collection_free(light_collection_t* collection)
{
free(collection->punctual_lights);
free(collection->directional_lights);
collection->max_punctual_lights = 0;
collection->max_directional_lights = 0;
collection->punctual_light_count = 0;
collection->directional_light_count = 0;
collection->punctual_lights = NULL;
collection->directional_lights = NULL;
}
#endif // LIGHT_H

View File

@@ -0,0 +1,22 @@
#ifndef LIGHT_EVALUATION_H
#define LIGHT_EVALUATION_H
#include "Lighting/Light.h"
#include "Material/Material.h"
#include "Geometry/Triangle.h"
#include "Rendering/Scene.h"
vec3s evaluate_bsdf_directional(const directional_light_t light, const light_shading_context_t* context, sobol_state_t* sobol_state);
inline vec3s evaluate_bsdf_sky(const scene_t* scene, const light_shading_context_t* context, sobol_state_t* sobol_state)
{
vec3s ske_color = glms_vec3_zero();
if (scene->lights.sky_light.evaluate_bsdf_sky != NULL)
{
ske_color = scene->lights.sky_light.evaluate_bsdf_sky(scene->lights.sky_light.data, context, sobol_state);
}
return ske_color;
}
#endif // LIGHT_EVALUATION_H

View File

@@ -0,0 +1,21 @@
#ifndef SKY_LIGHT_H
#define SKY_LIGHT_H
#include "Light.h"
typedef struct
{
vec3s color;
} constant_sky_data_t;
vec3s evaluate_bsdf_const_sky(const void* data, const light_shading_context_t* context, sobol_state_t* sobol_state);
inline sky_light_t sky_create_constant_sky(constant_sky_data_t* data)
{
return (sky_light_t){
.evaluate_bsdf_sky = evaluate_bsdf_const_sky,
.data = data,
};
}
#endif // SKY_LIGHT_H