Changed function signatures to remove const qualifiers
Changed several function signatures across multiple files to remove the `const` qualifier from parameters of type `vec3s` for improved flexibility. Changed `material_collection_create` to `material_collection_init` for better initialization handling. Changed `scene_create` to `scene_init` to return a boolean indicating success or failure. Changed `render_target_create` to `render_target_init` for consistent initialization practices. Changed `window_create` to remove `const` from its parameters for consistency. Changed `evaluate_bsdf_directional` and `evaluate_bsdf_const_sky` to remove `const` from their parameters. Changed `sample_bsdf_simple_lit` and `sample_bsdf_pdf_simple_lit` to remove `const` from the `normal` parameter. Changed `scene_render` to take a pointer to `render_target_t` instead of returning it directly. Updated `main.c` to reflect new initialization functions for better memory management.
This commit is contained in:
@@ -2,13 +2,13 @@
|
||||
#include "Algorithm/BSDF.h"
|
||||
#include <float.h>
|
||||
|
||||
static const float DIELECTRIC_REFLECTIVE_F0 = 0.04f; // Standard dielectric reflectivity coef at incident angle (= 4%)
|
||||
static const vec3s DIELECTRIC_REFLECTIVE = {0.04f, 0.04f, 0.04f}; // Standard dielectric reflectivity coef at incident angle (= 4%)
|
||||
static float DIELECTRIC_REFLECTIVE_F0 = 0.04f; // Standard dielectric reflectivity coef at incident angle (= 4%)
|
||||
static vec3s DIELECTRIC_REFLECTIVE = {0.04f, 0.04f, 0.04f}; // Standard dielectric reflectivity coef at incident angle (= 4%)
|
||||
|
||||
// Simple lit, but keep it unbiased as much as possible
|
||||
vec3s sample_bsdf_simple_lit(const void* data, const vec3s normal, const vec3s wo, sobol_state_t* sobol_state, float* pdf_out)
|
||||
vec3s sample_bsdf_simple_lit(const void* data, vec3s normal, vec3s wo, sobol_state_t* sobol_state, float* pdf_out)
|
||||
{
|
||||
const simple_lit_data_t shading_data = *(const simple_lit_data_t*)data;
|
||||
simple_lit_data_t shading_data = *(const simple_lit_data_t*)data;
|
||||
|
||||
//TODO: having a bsdf data struct to avoid recomputing the same thing in both sample and evaluate
|
||||
vec3s f0 = glms_vec3_lerp(DIELECTRIC_REFLECTIVE, shading_data.albedo, shading_data.metallic);
|
||||
@@ -83,7 +83,7 @@ vec3s sample_bsdf_simple_lit(const void* data, const vec3s normal, const vec3s w
|
||||
}
|
||||
|
||||
//TODO: Most of the calculation here is same as in sample_bsdf_simple_lit, we can optimize this by using a bsdf data struct to avoid recomputing the same thing in both sample and evaluate
|
||||
float sample_bsdf_pdf_simple_lit(const void* data, const vec3s normal, const vec3s wo, const vec3s wi)
|
||||
float sample_bsdf_pdf_simple_lit(const void* data, vec3s normal, vec3s wo, vec3s wi)
|
||||
{
|
||||
// If wi is below the horizon relative to the normal, PDF must be 0
|
||||
if (glms_vec3_dot(normal, wi) <= 0.0f) // Use <= to be safe
|
||||
@@ -91,7 +91,7 @@ float sample_bsdf_pdf_simple_lit(const void* data, const vec3s normal, const vec
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
const simple_lit_data_t shading_data = *(const simple_lit_data_t*)data;
|
||||
simple_lit_data_t shading_data = *(const simple_lit_data_t*)data;
|
||||
|
||||
// Again, we need bsdf data;
|
||||
vec3s f0 = glms_vec3_lerp(DIELECTRIC_REFLECTIVE, shading_data.albedo, shading_data.metallic);
|
||||
@@ -120,8 +120,8 @@ float sample_bsdf_pdf_simple_lit(const void* data, const vec3s normal, const vec
|
||||
|
||||
vec3s evaluate_bsdf_simple_lit(const shading_context_t* context, const void* data)
|
||||
{
|
||||
const simple_lit_data_t shading_data = *(const simple_lit_data_t*)data;
|
||||
const shading_context_t shading_context = *context;
|
||||
simple_lit_data_t shading_data = *(const simple_lit_data_t*)data;
|
||||
shading_context_t shading_context = *context;
|
||||
|
||||
vec3s h = glms_vec3_normalize(glms_vec3_add(shading_context.wi, shading_context.wo));
|
||||
float n_dot_l = fmaxf(FLT_EPSILON, glms_vec3_dot(shading_context.normal, shading_context.wi));
|
||||
|
||||
Reference in New Issue
Block a user