Added new files for BVH, AABB, and Debug functionalities. Added new utility functions in Common.h. Added gamma correction function in PostProcessing.h. Changed the return type of path_trace to vec4s for alpha blending. Changed BSDF function signatures to include sample index and bounce. Changed the BSDF.h to replace inline functions with declarations. Changed the Light and SkyLight evaluation functions to include throughput and sample index. Changed the sphere creation function in GeometryUtilities.h for better quality. Changed the scene structure to include a BVH tree for improved ray intersection. Changed the scene initialization parameters for better performance. Created new Debug functions for ray intersection counting. Created new functions for triangle collection management in Triangle.c. Improved pixel updating logic in Window.c. Improved ray intersection performance with new BVH implementation. Removed unused includes from Common.h. Removed old library linking methods in CMakeLists.txt.
53 lines
1.8 KiB
C
53 lines
1.8 KiB
C
#ifndef MATERIAL_H
|
|
#define MATERIAL_H
|
|
|
|
#include "Algorithm/Sobol.h"
|
|
#include "Common.h"
|
|
|
|
typedef struct
|
|
{
|
|
vec3s normal;
|
|
vec3s position;
|
|
vec3s wi;
|
|
vec3s wo;
|
|
}shading_context_t;
|
|
|
|
typedef vec3s (*sample_bsdf_f)(const void* data, vec3s normal, vec3s wo, uint32_t index, uint32_t bounce, float* pdf_out);
|
|
typedef float (*sample_bsdf_pdf_f)(const void* data, vec3s normal, vec3s wo, vec3s wi);
|
|
typedef vec3s (*evaluate_bsdf_f)(const shading_context_t* context, const void* data);
|
|
|
|
typedef struct
|
|
{
|
|
// TODO: alpha, displacement, etc.
|
|
vec3s emission; // We have to have emission outside of data because data is only for bsdf, and emission is not part of bsdf. Maybe another shading properties struct is needed if the number of properties increases.
|
|
sample_bsdf_f sample_bsdf;
|
|
sample_bsdf_pdf_f sample_bsdf_pdf;
|
|
evaluate_bsdf_f evaluate_bsdf;
|
|
void* data;
|
|
}material_t;
|
|
|
|
typedef struct
|
|
{
|
|
uint8_t id;
|
|
} material_entity_t;
|
|
|
|
//TODO: Handle material remove, we can use something like sparse set.
|
|
typedef struct
|
|
{
|
|
uint8_t count;
|
|
uint8_t size;
|
|
material_t* buffer;
|
|
} material_collection_t;
|
|
|
|
bool material_collection_init(size_t size, material_collection_t* materials);
|
|
void material_collection_resize(material_collection_t* materials, size_t size);
|
|
void material_collection_free(material_collection_t* materials);
|
|
|
|
material_entity_t material_create(sample_bsdf_f sample, sample_bsdf_pdf_f sample_pdf, evaluate_bsdf_f evaluate, void* data, material_collection_t* collection);
|
|
|
|
vec3s sample_material_bsdf(const material_t* material, vec3s normal, vec3s wo, uint32_t sample_index, uint32_t bounce, float* pdf_out);
|
|
float sample_material_bsdf_pdf(const material_t* material, vec3s normal, vec3s wo, vec3s wi);
|
|
vec3s evaluate_material_bsdf(const material_t* material, const shading_context_t* context);
|
|
|
|
#endif // MATERIAL_H
|