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

46
header/Rendering/AOV.h Normal file
View File

@@ -0,0 +1,46 @@
#ifndef AOV_H
#define AOV_H
#include "cglm/struct/vec4.h"
#define MAX_AOV_TARGET 5
typedef enum
{
AOV_BEAUTY = 1 << 0,
AOV_AlBEDO = 1 << 1,
AOV_NORMAL = 1 << 2,
AOV_DEPTH = 1 << 3,
AOV_POSITION = 1 << 4,
} aov_flags_t;
typedef enum
{
AOV_BEAUTY_INDEX = 0,
AOV_AlBEDO_INDEX = 1,
AOV_NORMAL_INDEX = 2,
AOV_DEPTH_INDEX = 3,
AOV_POSITION_INDEX = 4,
} aov_index_t;
typedef struct
{
vec4s beauty;
vec4s albedo;
vec4s normal;
vec4s position;
float depth;
} aov_output_t;
inline void accumulate_aov(aov_output_t* aov, const aov_output_t* new_aov, float inv_sample_count)
{
aov->beauty = glms_vec4_add(aov->beauty, glms_vec4_scale(new_aov->beauty, inv_sample_count));
aov->albedo = glms_vec4_add(aov->albedo, glms_vec4_scale(new_aov->albedo, inv_sample_count));
aov->normal = glms_vec4_add(aov->normal, glms_vec4_scale(new_aov->normal, inv_sample_count));
aov->position = glms_vec4_add(aov->position, glms_vec4_scale(new_aov->position, inv_sample_count));
aov->depth = fminf(aov->depth, new_aov->depth);
}
#endif // AOV_H