71 lines
1.7 KiB
C
71 lines
1.7 KiB
C
#ifndef AOV_H
|
|
#define AOV_H
|
|
|
|
#include "cglm/struct/vec4.h"
|
|
#include <math.h>
|
|
|
|
#define MAX_AOV_TARGET 7
|
|
|
|
|
|
typedef enum
|
|
{
|
|
AOV_BEAUTY = 1 << 0,
|
|
AOV_AlBEDO = 1 << 1,
|
|
AOV_NORMAL = 1 << 2,
|
|
AOV_DEPTH = 1 << 3,
|
|
AOV_POSITION = 1 << 4,
|
|
// Lighting AOVs (require integration / multiple samples)
|
|
AOV_DIRECT = 1 << 5,
|
|
AOV_INDIRECT = 1 << 6,
|
|
} 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_DIRECT_INDEX = 5,
|
|
AOV_INDIRECT_INDEX = 6,
|
|
} aov_index_t;
|
|
|
|
typedef struct
|
|
{
|
|
vec4s beauty;
|
|
vec4s albedo;
|
|
vec4s normal;
|
|
vec4s position;
|
|
|
|
vec4s direct;
|
|
vec4s indirect;
|
|
|
|
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->direct = glms_vec4_add(aov->direct, glms_vec4_scale(new_aov->direct, inv_sample_count));
|
|
aov->indirect = glms_vec4_add(aov->indirect, glms_vec4_scale(new_aov->indirect, inv_sample_count));
|
|
|
|
// Depth: keep nearest valid depth across samples; treat 0 as "unset".
|
|
if (new_aov->depth > 0.0f)
|
|
{
|
|
if (aov->depth <= 0.0f)
|
|
{
|
|
aov->depth = new_aov->depth;
|
|
}
|
|
else
|
|
{
|
|
aov->depth = fminf(aov->depth, new_aov->depth);
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif // AOV_H
|