Refactor codebase. Add punctual light support
This commit is contained in:
@@ -48,7 +48,7 @@ static bool scene_rebuild_tlas(scene_t* scene)
|
||||
}
|
||||
|
||||
// Build list of active instances.
|
||||
uint64_t active_count = 0;
|
||||
uint32_t active_count = 0;
|
||||
for (uint32_t i = 0; i < scene->mesh_instances.capacity; ++i)
|
||||
{
|
||||
if (scene->mesh_instances.occupied[i])
|
||||
@@ -64,13 +64,13 @@ static bool scene_rebuild_tlas(scene_t* scene)
|
||||
return true;
|
||||
}
|
||||
|
||||
uint64_t* indices = (uint64_t*)malloc(sizeof(uint64_t) * active_count);
|
||||
uint32_t* indices = (uint32_t*)malloc(sizeof(uint32_t) * active_count);
|
||||
if (indices == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
uint64_t cursor = 0;
|
||||
uint32_t cursor = 0;
|
||||
for (uint32_t i = 0; i < scene->mesh_instances.capacity; ++i)
|
||||
{
|
||||
if (scene->mesh_instances.occupied[i])
|
||||
@@ -115,6 +115,8 @@ static bool scene_rebuild_tlas(scene_t* scene)
|
||||
return true;
|
||||
}
|
||||
|
||||
ARRAY_DEF(int, test)
|
||||
|
||||
bool scene_init(scene_t* scene, uint32_t triangle_count, uint32_t texture_count, uint32_t material_count, uint32_t punctual_light_count)
|
||||
{
|
||||
scene_t temp = {0};
|
||||
@@ -232,7 +234,7 @@ void scene_free(scene_t* scene)
|
||||
light_collection_free(&scene->lights);
|
||||
}
|
||||
|
||||
mesh_model_handle_t scene_add_mesh_model(scene_t* scene, uint64_t triangle_reserve)
|
||||
mesh_model_handle_t scene_add_mesh_model(scene_t* scene, uint32_t triangle_reserve)
|
||||
{
|
||||
if (scene == NULL)
|
||||
{
|
||||
|
||||
@@ -362,7 +362,7 @@ float texture_get_sample_lod(const texture_t* texture, const texture_sample_cont
|
||||
// 4. Convert to LOD
|
||||
// LOD 0 = 1 texel. LOD 1 = 2 texels. LOD 2 = 4 texels.
|
||||
// log2(texels_covered) gives the mip level.
|
||||
return log2f(texels_covered) * 0.5f;
|
||||
return log2f(texels_covered) * 0.5f; // TODO: Apply EWA for better quality
|
||||
}
|
||||
|
||||
static vec4s nearest_filter(const texture_t* texture, vec2s uv, uint8_t lod)
|
||||
|
||||
Reference in New Issue
Block a user