Skip to content

Commit

Permalink
Better bounding for coord value lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
Auburn committed Apr 6, 2024
1 parent 86f9cc8 commit 11e368c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions include/FastNoise/Generators/Utils.inl
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,17 @@ namespace FastNoise
{
int32v hash = seed;
hash ^= (primedPos ^ ...);


int32v zeroCase = hash >> 8;
hash *= hash * int32v( 0x27d4eb2d );
return FS::Convert<float>( hash ) * float32v( 1.0f / (float)-INT_MIN );

int32v floatBits = hash & int32v( 0x7FFFFF ); //fp32 fractional bits
floatBits |= int32v( 0x3F800000 ); // fp32 1.0
float32v f32 = FS::Cast<float>( floatBits ) - float32v( 0.9999999f ); // bring range to 0.0000001 - 1.0

float32v sign = FS::Cast<float>( hash & int32v( -2147483648 ) );

return FS::InvMasked( zeroCase == int32v( 0x7FFFFF ), f32 | sign );
}

FS_FORCEINLINE static float32v Lerp( float32v a, float32v b, float32v t )
Expand Down

0 comments on commit 11e368c

Please sign in to comment.