Flip the Y texture coordinate when loading the OBJ model

This commit is contained in:
2024-08-25 01:32:54 +01:00
parent cee57282cb
commit 185f44252f
2 changed files with 3 additions and 3 deletions

View File

@@ -94,7 +94,7 @@ internal FragmentResult phong_shader_fragment(void *shader,
V3f norm;
if (model->normal) {
u64 nm_x = data->tex_coords.u * model->normal->width;
u64 nm_y = (1.0f - data->tex_coords.v) * model->normal->height;
u64 nm_y = data->tex_coords.v * model->normal->height;
Colour pixel = get_pixel(Colour, model->normal, nm_x, nm_y);
hnorm = (V4f){
@@ -118,7 +118,7 @@ internal FragmentResult phong_shader_fragment(void *shader,
Colour output;
if (model->texture) {
u64 tx_x = data->tex_coords.u * model->texture->width;
u64 tx_y = (1.0f - data->tex_coords.v) * model->texture->height;
u64 tx_y = data->tex_coords.v * model->texture->height;
output = get_pixel(Colour, model->texture, tx_x, tx_y);
} else {
output = *colour;