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:
46
header/Rendering/AOV.h
Normal file
46
header/Rendering/AOV.h
Normal 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
|
||||
@@ -10,7 +10,7 @@ typedef enum
|
||||
DEBUG_BVH = 1,
|
||||
DEBUG_SOBOL = 2,
|
||||
DEBUG_UV = 3,
|
||||
} debug_flag_t;
|
||||
} debug_mode_t;
|
||||
|
||||
static const vec4s DEBUG_COLOR_BVH = {0.0f, 1.0f, 0.0f, 0.005f}; // Green
|
||||
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
#ifndef RENDERER_H
|
||||
#define RENDERER_H
|
||||
|
||||
#include "Rendering/AOV.h"
|
||||
#include "Rendering/Debug.h"
|
||||
#include "Rendering/Scene.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PROGRESSIVE = 0,
|
||||
TILE_BASED = 1,
|
||||
RENDER_PROGRESSIVE = 0,
|
||||
RENDER_TILE_BASED = 1,
|
||||
} rendering_mode_t;
|
||||
|
||||
typedef struct
|
||||
@@ -23,14 +24,16 @@ typedef struct
|
||||
typedef struct
|
||||
{
|
||||
scene_t* scene;
|
||||
render_target_t* render_target;
|
||||
render_target_t** aov_target;
|
||||
const rendering_config_t* config;
|
||||
|
||||
rendering_mode_t rendering_type;
|
||||
debug_flag_t debug_flag;
|
||||
rendering_mode_t rendering_mode;
|
||||
aov_flags_t aov_flags;
|
||||
bool is_done;
|
||||
} render_job_t;
|
||||
|
||||
bool renderer_aov_target_init(render_job_t* job, aov_flags_t aov_flags);
|
||||
void renderer_start(render_job_t* job);
|
||||
void render_job_free(render_job_t* job);
|
||||
|
||||
#endif // RENDERER_H
|
||||
|
||||
Reference in New Issue
Block a user