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

@@ -23,9 +23,9 @@
typedef enum
{
NORMAL,
PATH_THROUGH,
TERMINATE,
PS_NORMAL,
PS_PATH_THROUGH,
PS_TERMINATE,
} path_state;
typedef struct
@@ -112,7 +112,13 @@ inline void uv_to_index(vec2s uv, uint32_t width, uint32_t height, uint32_t* x,
*y = i;
}
static inline vec2s direction_to_equirectangular(vec3s v)
inline float fast_cos_pi(float v)
{
float v2 = v * v;
return 1.0f - 2.0f * v2 + v2 * v2 * 0.5f;
}
inline vec2s direction_to_equirectangular(vec3s v)
{
float theta = -asinf(v.y);
float phi = atan2f(v.z, v.x);
@@ -123,20 +129,22 @@ static inline vec2s direction_to_equirectangular(vec3s v)
return uv;
}
static inline vec3s equirectangular_to_direction(float u, float v)
inline vec3s equirectangular_to_direction(float u, float v)
{
float phi = TWO_PI * (1.0f - u);
float cos_theta = 2.0f * v - 1.0f;
float theta = v * PI;
float phi = u * TWO_PI;
float sin_theta = sinf(theta);
float cos_theta = cosf(theta);
float sin_phi = sinf(phi);
float cos_phi = cosf(phi);
float sin_theta = sin_from_cos(cos_theta);
return (vec3s){
return glms_vec3_normalize((vec3s)
{
sin_theta * cos_phi,
cos_theta,
sin_theta * sin_phi,
};
});
}
#endif // COMMON_H