Fixed cdf and added Standard Lit

This commit is contained in:
2025-12-29 22:01:44 +09:00
parent e1693764f7
commit adee5acd10
24 changed files with 830 additions and 570 deletions

View File

@@ -53,7 +53,7 @@ typedef struct
typedef struct
{
uint8_t id;
} material_entity_t;
} material_handle_t;
// TODO: Handle material remove, we can use a lookup array.
// NOTE: 255 is invalid
@@ -69,16 +69,16 @@ bool material_collection_init(uint8_t size, material_collection_t* materials);
void material_collection_resize(material_collection_t* materials, size_t size);
void material_collection_free(material_collection_t* materials);
material_entity_t material_create(const void* properties, size_t properties_size, material_render_loop_f render_loop, material_render_aov_f render_aov, material_collection_t* collection);
material_handle_t material_create(const void* properties, size_t properties_size, material_render_loop_f render_loop, material_render_aov_f render_aov, material_collection_t* collection);
// void material_free(material_entity_t entity, material_collection_t* collection);
inline material_entity_t invalid_material_entity()
inline material_handle_t invalid_material_entity()
{
return (material_entity_t){.id = INVALID_MATERIAL_ID};
return (material_handle_t){.id = INVALID_MATERIAL_ID};
}
inline bool is_material_entity_valid(material_entity_t entity)
inline bool is_material_entity_valid(material_handle_t entity)
{
return entity.id != INVALID_MATERIAL_ID;
}

View File

@@ -1,38 +0,0 @@
#ifndef SIMPLE_LIT_H
#define SIMPLE_LIT_H
#include "Material.h"
#include "Rendering/Texture.h"
#include "cglm/struct/vec3.h"
typedef struct
{
vec3s albedo;
vec3s normal;
float roughness;
float metallic;
} surface_data_t;
typedef struct
{
vec3s albedo;
float roughness;
float metallic;
texture_entity_t albedo_texture;
texture_entity_t normal_texture;
texture_entity_t roughness_texture;
texture_entity_t metallic_texture;
} simple_lit_properties_t;
path_output simple_lit_render_loop(const shading_context_t* properties, const shading_context_t* context);
void simple_lit_render_aov(const shading_context_t* properties, const shading_context_t* context, aov_output_t* aov_output);
inline material_entity_t material_create_simple_lit_default(const simple_lit_properties_t* properties, material_collection_t* collection)
{
return material_create(properties, sizeof(simple_lit_properties_t), (material_render_loop_f)simple_lit_render_loop, (material_render_aov_f)simple_lit_render_aov, collection);
}
#endif // SIMPLE_LIT_H

View File

@@ -0,0 +1,43 @@
#ifndef STANDARd_LIT_H
#define STANDARd_LIT_H
#include "Material.h"
#include "Rendering/Texture.h"
#include "cglm/common.h"
#include "cglm/struct/vec3.h"
typedef struct
{
vec3s albedo;
vec3s normal;
float diffuse_roughness;
float roughness;
float metallic;
} standard_lit_surface_data_t;
typedef struct
{
vec3s albedo;
float diffuse_roughness;
float roughness;
float metallic;
texture_handle_t albedo_texture;
texture_handle_t normal_texture;
texture_handle_t roughness_texture;
texture_handle_t metallic_texture;
} standard_lit_properties_t;
path_output standard_lit_render_loop(const standard_lit_properties_t* properties, const shading_context_t* context);
float sample_bsdf_pdf(const standard_lit_surface_data_t* surface_data, vec3s V, vec3s L);
void standard_lit_render_aov(const shading_context_t* properties, const shading_context_t* context, aov_output_t* aov_output);
inline material_handle_t material_create_standard_lit_default(const standard_lit_properties_t* properties, material_collection_t* collection)
{
return material_create(properties, sizeof(standard_lit_properties_t), (material_render_loop_f)standard_lit_render_loop, NULL, collection);
}
#endif // STANDARd_LIT_H