Update rendering, material handling, and shading logic
Changed README.md to update rendering settings and build instructions. Changed BSDF.h to add functions for normal unpacking and tangent transformation. Changed RayIntersection.h to include tangent vector in hit_result_t. Changed Common.h to include vec2.h for 2D vector handling. Changed String.h to add string_copy function and improve is_absolute_path. Changed GeometryUtilities.h to enhance quad creation with tangent calculations. Changed Mesh.h to include tangents in the vertex structure. Changed Triangle.h to add tangents in the vertex structure for better normal mapping. Changed Light.h to include tangents in the light shading context. Changed SkyLight.h to introduce a new structure for sky lights. Changed Material.h to include tangents in the shading context. Changed SimpleLit.h to add normal and tangent textures for detailed shading. Changed Texture.h to introduce a new structure for texture assets. Changed BSDF.c to add functions for unpacking normals and transforming tangents. Changed PathTracing.c to include tangents in the shading context. Changed RayIntersection.c to calculate normals and tangents in ray-triangle intersections. Changed Mesh.c to improve material texture loading and handle tangents. Changed Material.c to enhance material collection initialization and resizing. Changed SimpleLit.c to incorporate normal mapping with normal textures. Changed Texture.c to improve management of texture assets and resources.
This commit is contained in:
@@ -10,11 +10,12 @@
|
||||
|
||||
typedef struct
|
||||
{
|
||||
vec3s normal;
|
||||
vec3s position;
|
||||
vec3s normal;
|
||||
vec3s tangent;
|
||||
vec2s uv;
|
||||
vec3s wi;
|
||||
vec3s wo;
|
||||
vec2s uv;
|
||||
|
||||
const texture_collection_t* textures;
|
||||
} shading_context_t;
|
||||
@@ -27,7 +28,9 @@ typedef vec3s (*evaluate_bsdf_f)(const shading_context_t* context, const void* p
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// Should we heap allocate this? It is a bit of a waste to have it on the stack.
|
||||
char properties[PROPERTY_SIZE];
|
||||
|
||||
// TODO: alpha, displacement, etc.
|
||||
vec3s emission; // We have to have emission outside of data because data is only for bsdf, and emission is not part of bsdf. Maybe another shading properties struct is needed if the number of properties increases.
|
||||
compute_surface_data_f compute_surface_data;
|
||||
@@ -60,4 +63,14 @@ vec3s sample_material_bsdf(const material_t* material, const shading_context_t*
|
||||
float sample_material_bsdf_pdf(const material_t* material, const shading_context_t* context);
|
||||
vec3s evaluate_material_bsdf(const material_t* material, const shading_context_t* context);
|
||||
|
||||
inline material_entity_t invalid_material_entity()
|
||||
{
|
||||
return (material_entity_t){.id = INVALID_MATERIAL_ID};
|
||||
}
|
||||
|
||||
inline bool is_material_entity_valid(material_entity_t entity)
|
||||
{
|
||||
return entity.id != INVALID_MATERIAL_ID;
|
||||
}
|
||||
|
||||
#endif // MATERIAL_H
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
typedef struct
|
||||
{
|
||||
vec3s albedo;
|
||||
vec3s normal;
|
||||
float roughness;
|
||||
float metallic;
|
||||
} simple_lit_data_t;
|
||||
@@ -19,6 +20,7 @@ typedef struct
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user