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.
34 lines
920 B
C
34 lines
920 B
C
#ifndef POST_PROCESSING_H
|
|
#define POST_PROCESSING_H
|
|
|
|
#include "cglm/struct/vec4.h"
|
|
#include "cglm/struct/mat4.h"
|
|
|
|
inline vec4s gamma_correct(vec4s color, float gamma)
|
|
{
|
|
vec4s corrected_color = color;
|
|
corrected_color.x = powf(color.x, 1.0f / gamma);
|
|
corrected_color.y = powf(color.y, 1.0f / gamma);
|
|
corrected_color.z = powf(color.z, 1.0f / gamma);
|
|
return corrected_color;
|
|
}
|
|
|
|
// Maybe full aces later
|
|
inline vec4s aces_tone_map(vec4s color)
|
|
{
|
|
vec4s mapped_color = color;
|
|
float a = 2.51f;
|
|
float b = 0.03f;
|
|
float c = 2.43f;
|
|
float d = 0.59f;
|
|
float e = 0.14f;
|
|
|
|
mapped_color.x = (color.x * (a * color.x + b)) / (color.x * (c * color.x + d) + e);
|
|
mapped_color.y = (color.y * (a * color.y + b)) / (color.y * (c * color.y + d) + e);
|
|
mapped_color.z = (color.z * (a * color.z + b)) / (color.z * (c * color.z + d) + e);
|
|
|
|
return mapped_color;
|
|
}
|
|
|
|
#endif // POST_PROCESSING_H
|