Add AOV rendering support and related enhancements

Added support for rendering Arbitrary Output Variables (AOVs) for detailed outputs like beauty, albedo, normal, depth, and position.
Added new functions `render_aov` and `accumulate_aov` for AOV data management during rendering.
Added AOV rendering capabilities to the `SimpleLit` material with specific functions.
Changed the material system to include new function pointers for AOV rendering.
Changed the renderer to initialize and update AOV targets during the rendering process.
Changed the main rendering loop to handle AOVs and update render targets accordingly.
Fixed various minor issues, including function signature updates, variable name changes, and improved error handling for memory allocations.
This commit is contained in:
2025-05-04 17:32:48 +09:00
parent 4c62b3ecde
commit 4b29de15cd
16 changed files with 357 additions and 135 deletions

View File

@@ -5,6 +5,7 @@
#include "Algorithm/Sobol.h"
#include "Common.h"
#include "Lighting/Light.h"
#include "Rendering/AOV.h"
#include "Rendering/Texture.h"
#define PROPERTY_SIZE 64
@@ -30,15 +31,18 @@ typedef struct
} shading_context_t;
typedef path_output (*material_render_loop_f)(const void* properties, const shading_context_t* context);
typedef void (*material_render_aov_f)(const void* properties, const shading_context_t* context, aov_output_t* aov_output);
typedef struct
{
// Should we heap allocate this? It is a bit of a waste to have it on the stack.
char properties[PROPERTY_SIZE];
// 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.
size_t properties_size;
void* properties;
material_render_loop_f render_loop;
material_render_aov_f render_aov;
} material_t;
typedef struct
@@ -55,13 +59,15 @@ typedef struct
material_t* buffer;
} material_collection_t;
bool material_collection_init(uint8_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(const void* properties, size_t properties_size, material_render_loop_f render_loop, material_collection_t* collection);
material_entity_t material_create(const void* properties, size_t properties_size, material_render_loop_f render_loop, material_render_aov_f render_aov, material_collection_t* collection);
// void material_free(material_entity_t entity, material_collection_t* collection);
inline material_entity_t invalid_material_entity()
{
return (material_entity_t){.id = INVALID_MATERIAL_ID};
@@ -82,4 +88,14 @@ inline path_output render_material(const material_t* material, const shading_con
return material->render_loop(material->properties, context);
}
inline void render_material_aov(const material_t* material, const shading_context_t* context, aov_output_t* aov_output)
{
if (material == NULL || material->render_loop == NULL)
{
return;
}
material->render_aov(material->properties, context, aov_output);
}
#endif // MATERIAL_H

View File

@@ -25,11 +25,14 @@ typedef struct
texture_entity_t metallic_texture;
} simple_lit_properties_t;
path_output simple_lit_render_loop(const void* properties, const shading_context_t* context);
path_output simple_lit_render_loop(const shading_context_t* properties, const shading_context_t* context);
void simple_lit_render_aov(const shading_context_t* properties, const shading_context_t* context, aov_output_t* aov_output);
inline material_entity_t material_create_simple_lit_default(const simple_lit_properties_t* properties, material_collection_t* collection)
{
return material_create(properties, sizeof(simple_lit_properties_t), simple_lit_render_loop, collection);
return material_create(properties, sizeof(simple_lit_properties_t), (material_render_loop_f)simple_lit_render_loop, (material_render_aov_f)simple_lit_render_aov, collection);
}
#endif // SIMPLE_LIT_H