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:
2025-04-21 15:56:19 +09:00
parent 1162575545
commit 6800810369
36 changed files with 1590 additions and 579 deletions

View File

@@ -1,5 +1,10 @@
#include "Algorithm/Sobol.h"
static inline int sobol_get_bit(uint32_t index, uint32_t bit)
{
return (index >> bit) & 1;
}
//NOTE: Maybe precompute the vector table?
void sobol_init()
{
@@ -9,17 +14,15 @@ void sobol_init()
sobol_direction_vectors[0][i] = 1U << (31 - i);
}
// Dimensions 2 to 6
for (int d = 1; d < SOBOL_DIMENSIONS; d++)
{
int s = s_vals[d - 1];
int a = a_vals[d - 1];
const int* m = m_vals[d - 1];
// Set initial direction numbers
for (int i = 0; i < s; i++)
{
sobol_direction_vectors[d][i] = (uint32_t)m[i] << (31 - i);
sobol_direction_vectors[d][i] = m_vals[d - 1][i] << (31 - i);
}
// Compute remaining direction numbers
@@ -39,9 +42,9 @@ void sobol_init()
}
}
static inline uint32_t sobol_get_bit(uint32_t index, uint32_t bit)
uint16_t sobol_get_dimension(uint16_t bounce, sampling_dimension_t operation_type)
{
return (index >> bit) & 1;
return PRNG_BASE_NUM + bounce * PRNG_BOUNCE_NUM + operation_type;
}
static inline float sobol_uint_to_float(uint32_t x)
@@ -51,6 +54,7 @@ static inline float sobol_uint_to_float(uint32_t x)
float sobol_sample(uint32_t index, uint32_t dimension)
{
// return random_float();
if (dimension >= SOBOL_DIMENSIONS)
{
return 0.0f; // Invalid dimension
@@ -67,23 +71,3 @@ float sobol_sample(uint32_t index, uint32_t dimension)
return sobol_uint_to_float(result);
}
float sobol_next(sobol_state_t* state)
{
uint32_t index = state->index;
uint32_t dimension = state->dimension;
uint32_t result = 0;
for (int i = 0; i < SOBOL_BITS; i++)
{
if (sobol_get_bit(index, i))
{
result ^= sobol_direction_vectors[dimension][i];
}
}
// Increment the index for the next call
state->dimension = (state->dimension + 1) % SOBOL_DIMENSIONS;
return sobol_uint_to_float(result);
}