From d650b84e1b9ea1d895fb844da3de3ba9b58133f5 Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Tue, 9 Apr 2024 18:35:18 +0200 Subject: [PATCH] fix generateSphere UVs Applies suggestion from student --- src/utilities/shapes.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utilities/shapes.cpp b/src/utilities/shapes.cpp index 87d3c08..774789a 100644 --- a/src/utilities/shapes.cpp +++ b/src/utilities/shapes.cpp @@ -187,10 +187,10 @@ Mesh generateSphere(float sphereRadius, int slices, int layers) { indices.emplace_back(i + 5); for (int j = 0; j < 6; j++) { - glm::vec3 vertex = vertices.at(i+j); + glm::vec3 vertex = vertices.at(i+j) / sphereRadius; uvs.emplace_back( - 0.5 + (glm::atan(vertex.z, vertex.y)/(2.0*M_PI)), - 0.5 - (glm::asin(vertex.y)/M_PI) + 0.5 + (glm::atan(vertex.z, -vertex.x)/(2.0*M_PI)), + 0.5 + (glm::asin(vertex.y)/M_PI) ); }