aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-02-21 03:48:46 +0100
committerdec05eba <dec05eba@protonmail.com>2021-11-18 15:22:10 +0100
commitc794de8eeac935649aa556f009776567ed201787 (patch)
treeae4d4c6df7536cd115679bf4f96351f7913f9e6f
parent51e5e742e518be511c2cb3234d01459d1233dc85 (diff)
Fix texture coordinates for obj files (flip y coord)
-rw-r--r--shaders/fragment.frag1
-rw-r--r--src/model_loader/ObjModelLoader.cpp2
2 files changed, 1 insertions, 2 deletions
diff --git a/shaders/fragment.frag b/shaders/fragment.frag
index ee6106d..b078a58 100644
--- a/shaders/fragment.frag
+++ b/shaders/fragment.frag
@@ -8,5 +8,4 @@ uniform sampler2D tex;
void main() {
out_color = texture(tex, texcoord_frag);
- //out_color = vec4(1.0, 0.0, 0.0, 1.0);
} \ No newline at end of file
diff --git a/src/model_loader/ObjModelLoader.cpp b/src/model_loader/ObjModelLoader.cpp
index a42f8d7..f70123a 100644
--- a/src/model_loader/ObjModelLoader.cpp
+++ b/src/model_loader/ObjModelLoader.cpp
@@ -179,7 +179,7 @@ namespace amalgine {
if(num_columns == 2) {
columns[0].data[columns[0].size] = '\0';
columns[1].data[columns[1].size] = '\0';
- temp_texture_coords.push_back({ atof(columns[0].data), atof(columns[1].data) });
+ temp_texture_coords.push_back({ atof(columns[0].data), 1.0f - atof(columns[1].data) });
}
} else if(line_data.size > 7 && memcmp(line_data.data, "mtllib ", 7) == 0) {
StringView column_data = { line_data.data + 7, line_data.size - 7 };