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:
@@ -54,7 +54,7 @@ vec4s path_trace(const scene_t* scene, ray_t ray, uint32_t sample_index, uint16_
|
||||
|
||||
float cos_theta = fmaxf(0.0f, glms_vec3_dot(material_output.wi, closest_hit.normal));
|
||||
throughput = glms_vec3_mul(throughput, material_output.bsdf);
|
||||
|
||||
|
||||
// We do Russian roulette to decide whether to continue tracing or terminate the path
|
||||
if (depth > 1)
|
||||
{
|
||||
@@ -70,7 +70,7 @@ vec4s path_trace(const scene_t* scene, ray_t ray, uint32_t sample_index, uint16_
|
||||
|
||||
switch (material_output.state)
|
||||
{
|
||||
case TERMINATE:
|
||||
case PS_TERMINATE:
|
||||
goto end_path_trace;
|
||||
//case PATH_THROUGH:
|
||||
// active_ray = ray_create(BIAS_RAY_ORIGION(closest_hit.point, glms_vec3_negate(closest_hit.normal)), active_ray.direction);
|
||||
@@ -85,3 +85,37 @@ vec4s path_trace(const scene_t* scene, ray_t ray, uint32_t sample_index, uint16_
|
||||
end_path_trace:
|
||||
return accumulated_color;
|
||||
}
|
||||
|
||||
// How to handle multi-bounced aov like indirect lighting?
|
||||
// Maybe we should move aov to path_trace and split accumulated_color into direct/indirect diffuse/specular before returning.
|
||||
void render_aov(const scene_t* scene, ray_t ray, uint32_t sample_index, uint16_t max_depth, aov_output_t* aov_output)
|
||||
{
|
||||
hit_result_t closest_hit = ray_intersect_scene(&ray, scene);
|
||||
if (!closest_hit.hit)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const material_t* hit_material = &scene->materials.buffer[scene->triangles.buffer[closest_hit.triangle_id].material_id];
|
||||
shading_context_t shading_context =
|
||||
{
|
||||
.position = closest_hit.point,
|
||||
.normal = closest_hit.normal,
|
||||
.tangent = closest_hit.tangent,
|
||||
.uv = closest_hit.uv,
|
||||
.wo = ray.direction,
|
||||
.throughput = 1.0f,
|
||||
|
||||
.sample_index = sample_index,
|
||||
.bounce_depth = 0,
|
||||
|
||||
.bvh_tree = &scene->bvh_tree,
|
||||
.triangles = &scene->triangles,
|
||||
.lights = &scene->lights,
|
||||
.textures = &scene->textures,
|
||||
};
|
||||
|
||||
render_material_aov(hit_material, &shading_context, aov_output);
|
||||
aov_output->position = glms_vec4(closest_hit.point, 1.0f);
|
||||
aov_output->depth = closest_hit.distance;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user