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:
@@ -19,13 +19,26 @@ inline void quad_create(vec3s center, vec3s forward, vec3s up, float size, uint8
|
||||
vec3s bottom_right = glms_vec3_sub(temp_add, scaled_up);
|
||||
vec3s bottom_left = glms_vec3_sub(temp_sub, scaled_up);
|
||||
|
||||
vertex_t vertex_1 = {.position = top_left, .normal = forward, .uv = {0.0f, 0.0f}};
|
||||
vertex_t vertex_2 = {.position = top_right, .normal = forward, .uv = {1.0f, 0.0f}};
|
||||
vertex_t vertex_3 = {.position = bottom_right, .normal = forward, .uv = {1.0f, 1.0f}};
|
||||
vertex_t vertex_4 = {.position = bottom_left, .normal = forward, .uv = {0.0f, 1.0f}};
|
||||
vec2s uv0 = {0.0f, 0.0f};
|
||||
vec2s uv1 = {1.0f, 0.0f};
|
||||
vec2s uv2 = {1.0f, 1.0f};
|
||||
vec2s uv3 = {0.0f, 1.0f};
|
||||
|
||||
triangle_create(vertex_1, vertex_2, vertex_4, material_id, collection);
|
||||
triangle_create(vertex_2, vertex_3, vertex_4, material_id, collection);
|
||||
vec3s dp1 = glms_vec3_sub(top_right, top_left);
|
||||
vec3s dp2 = glms_vec3_sub(bottom_right, top_left);
|
||||
vec2s duv1 = glms_vec2_sub(uv1, uv0);
|
||||
vec2s duv2 = glms_vec2_sub(uv3, uv0);
|
||||
|
||||
float r = 1.0f / (duv1.x * duv2.y - duv1.y * duv2.x);
|
||||
vec3s tangent = glms_vec3_scale(glms_vec3_sub(glms_vec3_scale(dp1, duv2.y), glms_vec3_scale(dp2, duv1.y)), r);
|
||||
|
||||
vertex_t vertex_0 = {.position = top_left, .normal = forward, .tangent = tangent, .uv = {0.0f, 0.0f}};
|
||||
vertex_t vertex_1 = {.position = top_right, .normal = forward, .tangent = tangent, .uv = {1.0f, 0.0f}};
|
||||
vertex_t vertex_2 = {.position = bottom_right, .normal = forward, .tangent = tangent, .uv = {1.0f, 1.0f}};
|
||||
vertex_t vertex_3 = {.position = bottom_left, .normal = forward, .tangent = tangent, .uv = {0.0f, 1.0f}};
|
||||
|
||||
triangle_create(vertex_0, vertex_1, vertex_3, material_id, collection);
|
||||
triangle_create(vertex_1, vertex_2, vertex_3, material_id, collection);
|
||||
}
|
||||
|
||||
// inline void sphere_create(vec3s center, float radius, uint8_t material_id, triangle_collection_t* collection)
|
||||
|
||||
Reference in New Issue
Block a user