Enhance build system and project documentation
Added LICENSE file with MIT License and copyright notice. Added preview.png binary file for project assets. Changed CMakeLists.txt to include asset copying command. Changed mesh loading in Mesh.c to support smooth normals. Changed ray origin biasing in PathTracing.c and shadow rays. Changed ray-triangle intersection logic in RayIntersection.c. Changed ray_intersect_bvh_count function in Debug.c to static. Changed rendering functions in Scene.c with TODO for optimization. Updated README.md with project description and build instructions. Updated window dimensions in main.c for testing purposes.
This commit is contained in:
@@ -8,10 +8,10 @@ mesh_entity_t mesh_load(const char* filename, uint8_t material_id, triangle_coll
|
||||
{
|
||||
mesh_entity_t entity = {0};
|
||||
|
||||
const C_STRUCT aiScene* scene = aiImportFile(filename,aiProcessPreset_TargetRealtime_MaxQuality);
|
||||
const C_STRUCT aiScene* scene = aiImportFile(filename, aiProcessPreset_TargetRealtime_MaxQuality | aiProcess_GenSmoothNormals);
|
||||
if (scene == NULL)
|
||||
{
|
||||
// fprintf(stderr, "Error loading mesh: %s\n", aiGetErrorString());
|
||||
perror(aiGetErrorString());
|
||||
return entity;
|
||||
}
|
||||
|
||||
@@ -19,10 +19,9 @@ mesh_entity_t mesh_load(const char* filename, uint8_t material_id, triangle_coll
|
||||
{
|
||||
struct aiMesh* mesh = scene->mMeshes[i];
|
||||
|
||||
//TODO: Handle all mesh types, not just triangles
|
||||
//TODO: Handle all primitive types, not just triangles
|
||||
if (mesh->mPrimitiveTypes != aiPrimitiveType_TRIANGLE)
|
||||
{
|
||||
// fprintf(stderr, "Mesh %llu is not a triangle mesh\n", i);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -31,40 +30,43 @@ mesh_entity_t mesh_load(const char* filename, uint8_t material_id, triangle_coll
|
||||
struct aiFace* face = &mesh->mFaces[j];
|
||||
if (face->mNumIndices != 3)
|
||||
{
|
||||
// fprintf(stderr, "Face %llu in mesh %llu does not have 3 indices\n", j, i);
|
||||
continue;
|
||||
}
|
||||
|
||||
uint32_t index1 = face->mIndices[0];
|
||||
uint32_t index2 = face->mIndices[1];
|
||||
uint32_t index3 = face->mIndices[2];
|
||||
|
||||
vec3s point1 = {
|
||||
mesh->mVertices[face->mIndices[0]].x,
|
||||
mesh->mVertices[face->mIndices[0]].y,
|
||||
mesh->mVertices[face->mIndices[0]].z
|
||||
mesh->mVertices[index1].x,
|
||||
mesh->mVertices[index1].y,
|
||||
mesh->mVertices[index1].z
|
||||
};
|
||||
vec3s point2 = {
|
||||
mesh->mVertices[face->mIndices[1]].x,
|
||||
mesh->mVertices[face->mIndices[1]].y,
|
||||
mesh->mVertices[face->mIndices[1]].z
|
||||
mesh->mVertices[index2].x,
|
||||
mesh->mVertices[index2].y,
|
||||
mesh->mVertices[index2].z
|
||||
};
|
||||
vec3s point3 = {
|
||||
mesh->mVertices[face->mIndices[2]].x,
|
||||
mesh->mVertices[face->mIndices[2]].y,
|
||||
mesh->mVertices[face->mIndices[2]].z
|
||||
mesh->mVertices[index3].x,
|
||||
mesh->mVertices[index3].y,
|
||||
mesh->mVertices[index3].z
|
||||
};
|
||||
|
||||
vec3s normal1 = {
|
||||
mesh->mNormals[face->mIndices[0]].x,
|
||||
mesh->mNormals[face->mIndices[0]].y,
|
||||
mesh->mNormals[face->mIndices[0]].z
|
||||
mesh->mNormals[index1].x,
|
||||
mesh->mNormals[index1].y,
|
||||
mesh->mNormals[index1].z
|
||||
};
|
||||
vec3s normal2 = {
|
||||
mesh->mNormals[face->mIndices[1]].x,
|
||||
mesh->mNormals[face->mIndices[1]].y,
|
||||
mesh->mNormals[face->mIndices[1]].z
|
||||
mesh->mNormals[index2].x,
|
||||
mesh->mNormals[index2].y,
|
||||
mesh->mNormals[index2].z
|
||||
};
|
||||
vec3s normal3 = {
|
||||
mesh->mNormals[face->mIndices[2]].x,
|
||||
mesh->mNormals[face->mIndices[2]].y,
|
||||
mesh->mNormals[face->mIndices[2]].z
|
||||
mesh->mNormals[index3].x,
|
||||
mesh->mNormals[index3].y,
|
||||
mesh->mNormals[index3].z
|
||||
};
|
||||
|
||||
//TODO: Handle materials, we use OpenPBR standard for parameter naming
|
||||
|
||||
Reference in New Issue
Block a user