Skip to content

Commit

Permalink
Fix IcoSphere UV coordinates (bevyengine#1871)
Browse files Browse the repository at this point in the history
Changes made:
- Swap Y/Z when calculating UV coordinates
- Correct mapping in the UV coordinates
- Fix typo in Azimuth
  • Loading branch information
OptimisticPeach authored and ostwilkens committed Jul 27, 2021
1 parent a471f75 commit 99430b9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions crates/bevy_render/src/mesh/shape/icosphere.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ impl From<Icosphere> for Mesh {
);
}
let generated = IcoSphere::new(sphere.subdivisions, |point| {
let inclination = point.z.acos();
let azumith = point.y.atan2(point.x);
let inclination = point.y.acos();
let azimuth = point.z.atan2(point.x);

let norm_inclination = 1.0 - (inclination / std::f32::consts::PI);
let norm_azumith = (azumith / std::f32::consts::PI) * 0.5;
let norm_inclination = inclination / std::f32::consts::PI;
let norm_azimuth = 0.5 - (azimuth / std::f32::consts::TAU);

[norm_inclination, norm_azumith]
[norm_azimuth, norm_inclination]
});

let raw_points = generated.raw_points();
Expand Down

0 comments on commit 99430b9

Please sign in to comment.