Set C standard to C11 and add new assets
Changed CMakeLists.txt to set the C standard to C11. Added multiple binary image files for new visual assets. Added several new image files to enhance rendering capabilities. Changed stb_image.h to improve support for various image formats. Changed ray tracing engine to enhance ray creation and intersection. Changed triangle structure to use a vertex array for better attribute handling. Changed scene initialization to accommodate new texture management.
This commit is contained in:
@@ -17,14 +17,11 @@ vec3s evaluate_bsdf_directional(directional_light_t light, const light_shading_c
|
||||
return glms_vec3_zero();
|
||||
}
|
||||
|
||||
ray_t shadow_ray = {
|
||||
.origin = BIAS_RAY_ORIGION(context->hit_point, context->normal),
|
||||
.direction = wi,
|
||||
};
|
||||
ray_t shadow_ray = ray_create(BIAS_RAY_ORIGION(context->hit_point, context->normal), wi);
|
||||
|
||||
float closest = FLT_MAX;
|
||||
hit_result_t shadow_hit = {1};
|
||||
ray_intersect_bvh(shadow_ray, context->bvh_tree->nodes, context->bvh_tree->primitive_indices, context->bvh_tree->triangles, 0,
|
||||
ray_intersect_bvh(&shadow_ray, context->bvh_tree->nodes, context->bvh_tree->primitive_indices, context->bvh_tree->triangles, 0,
|
||||
&closest, &shadow_hit);
|
||||
if (shadow_hit.hit)
|
||||
{
|
||||
@@ -34,11 +31,12 @@ vec3s evaluate_bsdf_directional(directional_light_t light, const light_shading_c
|
||||
shading_context_t shading_context = {
|
||||
.normal = context->normal,
|
||||
.wi = wi,
|
||||
.wo = glms_vec3_negate(context->wo)
|
||||
.wo = glms_vec3_negate(context->wo),
|
||||
.uv = context->uv,
|
||||
};
|
||||
vec3s bsdf = evaluate_material_bsdf(context->material, &shading_context);
|
||||
|
||||
vec3s light_radiance = glms_vec3_scale(light.color, light.intensity);
|
||||
vec3s light_contribute = glms_vec3_scale(glms_vec3_mul(throughput, bsdf), fmaxf(0.0f, n_dot_l));
|
||||
vec3s light_contribute = glms_vec3_scale(glms_vec3_mul(throughput, bsdf), fmaxf(0.0f, n_dot_l)); // we always assume pdf = 1.0f for directional light
|
||||
return glms_vec3_mul(light_radiance, light_contribute);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ vec3s evaluate_bsdf_const_sky(const void* data, const light_shading_context_t* c
|
||||
if (context == NULL)
|
||||
{
|
||||
return glms_vec3_mul(sky_color, throughput);
|
||||
// return sky_data.color;
|
||||
}
|
||||
|
||||
uint16_t d1 = sobol_get_dimension(context->bounce_depth, PRNG_LIGHT_U);
|
||||
@@ -20,14 +19,11 @@ vec3s evaluate_bsdf_const_sky(const void* data, const light_shading_context_t* c
|
||||
vec3s wi = random_uniform_cdf_direction(context->normal, sample_index, d1, d2);
|
||||
float pdf = 1.0f / (4.0f * (float)M_PI);
|
||||
|
||||
ray_t shadow_ray = {
|
||||
.origin = BIAS_RAY_ORIGION(context->hit_point, context->normal),
|
||||
.direction = wi,
|
||||
};
|
||||
ray_t shadow_ray = ray_create(BIAS_RAY_ORIGION(context->hit_point, context->normal), wi);
|
||||
|
||||
float closest = FLT_MAX;
|
||||
hit_result_t shadow_hit = {1};
|
||||
ray_intersect_bvh(shadow_ray, context->bvh_tree->nodes, context->bvh_tree->primitive_indices, context->bvh_tree->triangles, 0, &closest, &shadow_hit);
|
||||
ray_intersect_bvh(&shadow_ray, context->bvh_tree->nodes, context->bvh_tree->primitive_indices, context->bvh_tree->triangles, 0, &closest, &shadow_hit);
|
||||
if (shadow_hit.hit)
|
||||
{
|
||||
return glms_vec3_zero();
|
||||
@@ -36,14 +32,15 @@ vec3s evaluate_bsdf_const_sky(const void* data, const light_shading_context_t* c
|
||||
shading_context_t shading_context = {
|
||||
.normal = context->normal,
|
||||
.wi = wi,
|
||||
.wo = glms_vec3_negate(context->wo)
|
||||
.wo = glms_vec3_negate(context->wo),
|
||||
.uv = context->uv,
|
||||
};
|
||||
|
||||
vec3s bsdf = evaluate_material_bsdf(context->material, &shading_context);
|
||||
bsdf = glms_vec3_mul(bsdf, sky_color);
|
||||
float cos_theta = fmaxf(glms_vec3_dot(wi, context->normal), 0.0f);
|
||||
|
||||
float pdf_bsdf = sample_material_bsdf_pdf(context->material, shading_context.normal, shading_context.wo, shading_context.wi);
|
||||
float pdf_bsdf = sample_material_bsdf_pdf(context->material, shading_context.normal, shading_context.wo, shading_context.wi, context->uv);
|
||||
float weight = power_heuristic(pdf, pdf_bsdf);
|
||||
|
||||
vec3s env_contrib = glms_vec3_scale(glms_vec3_mul(throughput, bsdf), cos_theta / pdf);
|
||||
|
||||
Reference in New Issue
Block a user