Fix barycentric coordinates calculation #2

Merged
abdelrahman merged 8 commits from debug-barycentric into main 2024-08-26 17:12:45 +00:00
2 changed files with 19 additions and 10 deletions
Showing only changes of commit c39efad8fb - Show all commits

View File

@ -32,16 +32,22 @@ int main(void) {
return TINY_EXIT_RENDER_INIT_FAILED; return TINY_EXIT_RENDER_INIT_FAILED;
} }
Model obj = load_obj_file(arena, RESOURCE("head.obj"), RESOURCE("head.pnm"), // Model obj = load_obj_file(arena, RESOURCE("head.obj"),
RESOURCE("head_nm.pnm")); // RESOURCE("head.pnm"),
// RESOURCE("head_nm.pnm"));
Model obj =
load_obj_file(arena, RESOURCE("polygon.obj"), RESOURCE("grid.pnm"), NULL);
if (IS_INVALID_MODEL(obj)) { if (IS_INVALID_MODEL(obj)) {
return TINY_EXIT_MODEL_LOAD_FAILED; return TINY_EXIT_MODEL_LOAD_FAILED;
} }
PhongMaterial material = { PhongMaterial material = {
.ambient = 0.3f, // .ambient = 0.3f,
.diffuse = 1.5f, // .diffuse = 1.5f,
.specular = 0.5f, // .specular = 0.5f,
.ambient = 2.0f,
.diffuse = 0.0f,
.specular = 0.0f,
.shininess = 0.1f, .shininess = 0.1f,
}; };
obj.material = material; obj.material = material;

View File

@ -46,11 +46,14 @@ internal M4x4f get_projection_matrix(ProjectionType projection_type);
internal f32 get_intensity(const V3f *normal); internal f32 get_intensity(const V3f *normal);
void load_shaders(void) { void load_shaders(void) {
M4x4f model_view = lookat(g_eye, g_target, g_up); // M4x4f model_view = lookat(g_eye, g_target, g_up);
M4x4f orthographic_projection = // M4x4f orthographic_projection =
get_projection_matrix(PROJECTION_TYPE_ORTHOGRAPHIC); // get_projection_matrix(PROJECTION_TYPE_ORTHOGRAPHIC);
M4x4f perspective_projection = // M4x4f perspective_projection =
get_projection_matrix(PROJECTION_TYPE_PERSPECTIVE); // get_projection_matrix(PROJECTION_TYPE_PERSPECTIVE);
M4x4f model_view = mat4x4_identity;
M4x4f orthographic_projection = mat4x4_identity;
M4x4f perspective_projection = mat4x4_identity;
perspective.model_view = orthographic.model_view = model_view; perspective.model_view = orthographic.model_view = model_view;
perspective.projection = perspective_projection; perspective.projection = perspective_projection;