Update project structure and improve performance
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.
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// TODO: Use mat4s instead of vec3s for position, forward, up and right
|
||||
vec3s position;
|
||||
vec3s forward;
|
||||
vec3s up;
|
||||
|
||||
@@ -4,8 +4,17 @@
|
||||
#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)
|
||||
inline vec4s aces_tone_map(vec4s color)
|
||||
{
|
||||
vec4s mapped_color = color;
|
||||
float a = 2.51f;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef SCENE_H
|
||||
#define SCENE_H
|
||||
|
||||
#include "Algorithm/BVH.h"
|
||||
#include "Camera.h"
|
||||
#include "Lighting/Light.h"
|
||||
#include "Material/Material.h"
|
||||
@@ -37,59 +38,18 @@ typedef struct
|
||||
typedef struct
|
||||
{
|
||||
camera_t camera;
|
||||
bvh_tree_t bvh_tree;
|
||||
triangle_collection_t triangles;
|
||||
material_collection_t materials;
|
||||
light_collection_t lights;
|
||||
} scene_t;
|
||||
|
||||
bool scene_render_tile(scene_t* scene, rendering_context_t* ctx, render_target_t* render_target,
|
||||
rendering_config_t config, uint32_t tile_index, tile_t* tile_out);
|
||||
bool scene_render(scene_t* scene, rendering_config_t confi, render_target_t* render_targetg);
|
||||
|
||||
inline bool scene_init(uint64_t triangle_count, uint8_t material_count, uint32_t punctual_light_count, scene_t* scene)
|
||||
{
|
||||
scene_t temp = {0};
|
||||
bool scene_init(uint64_t triangle_count, uint8_t material_count, uint32_t punctual_light_count, scene_t* scene);
|
||||
void scene_free(scene_t* scene);
|
||||
|
||||
if (!triangle_collection_init(triangle_count, &temp.triangles))
|
||||
{
|
||||
goto triangle_failed;
|
||||
}
|
||||
|
||||
if (!material_collection_init(material_count, &temp.materials))
|
||||
{
|
||||
goto material_failed;
|
||||
}
|
||||
|
||||
if (!light_collection_create(punctual_light_count, 16, &temp.lights)) // NOTE: We just fixed the max directional light count to 16.
|
||||
{
|
||||
goto light_failed;
|
||||
}
|
||||
|
||||
temp.camera = camera_create(
|
||||
(vec3s){0.0f, 0.0f, 5.0f},
|
||||
(vec3s){0.0f, 0.0f, -1.0f},
|
||||
(vec3s){0.0f, 1.0f, 0.0f},
|
||||
0.025f,
|
||||
0.036f,
|
||||
16.0f / 9.0f
|
||||
);
|
||||
|
||||
*scene = temp;
|
||||
return true;
|
||||
|
||||
light_failed:
|
||||
material_collection_free(&temp.materials);
|
||||
material_failed:
|
||||
triangle_collection_free(&temp.triangles);
|
||||
triangle_failed:
|
||||
return false;
|
||||
}
|
||||
|
||||
inline void scene_free(scene_t* scene)
|
||||
{
|
||||
triangle_collection_free(&scene->triangles);
|
||||
material_collection_free(&scene->materials);
|
||||
light_collection_free(&scene->lights);
|
||||
}
|
||||
bool scene_build_bvh(scene_t* scene);
|
||||
bool scene_render_tile(scene_t* scene, rendering_context_t* ctx, rendering_config_t config, uint32_t tile_index, int rendering_flags, render_target_t* render_target, tile_t* tile_out);
|
||||
bool scene_render(scene_t* scene, rendering_config_t config, int rendering_flags, render_target_t* render_targetg);
|
||||
|
||||
#endif // SCENE_H
|
||||
|
||||
Reference in New Issue
Block a user