Skip to content

Commit

Permalink
Increase the texture wrapping cutoff point
Browse files Browse the repository at this point in the history
This fixes an issue in Geffen, where stairs had stretched textures. Textures in lou_in01 are still applied correctly.
  • Loading branch information
hasenbanck committed Jan 7, 2025
1 parent 3a684ba commit 96b0e5c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions korangar_util/src/texture_atlas/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ impl AtlasAllocation {
pub fn map_to_atlas(&self, normalized_coordinates: Point2<f32>) -> Point2<f32> {
// Textured coordinates, that are "clearly bigger" than 1.0 are wrapping. There
// are some values, even though they are for example "1.0112", which are not
// wrapped in the original client. So we chose "1.1" arbitrarily as a cutoff
// point.
let wrapped = normalized_coordinates.map(|value: f32| if value > 1.1 { value.fract() } else { value });
// wrapped in the original client. So we chose "1.5" as a cutoff point. A value
// too low could lead to wrongly applied textures.
let wrapped = normalized_coordinates.map(|value: f32| if value > 1.5 { value.fract() } else { value });
let x = ((wrapped.x * self.rectangle.width() as f32) + self.rectangle.min.x as f32) / self.atlas_size.x as f32;
let y = ((wrapped.y * self.rectangle.height() as f32) + self.rectangle.min.y as f32) / self.atlas_size.y as f32;
Point2::new(x, y)
Expand Down

0 comments on commit 96b0e5c

Please sign in to comment.