Skip to content

Commit

Permalink
feat: rename spherical to nzSpherical to reflect its polarity.
Browse files Browse the repository at this point in the history
  • Loading branch information
bhouston committed Jul 28, 2020
1 parent cd76e43 commit 28e3949
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/lib/shaders/includes/cubemaps/latLong.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* local direction -> equirectangular uvs
*/
vec2 directionToLatLongUV( in vec3 dir ) {
vec2 s = cartesianToSpherical( dir );
vec2 s = cartesianToNZSpherical( dir );
return vec2(
fract( s.x * RECIPROCAL_PI2 + 0.75 ), // this makes maps -z dir to the center of the UV space.
s.y / PI) ;
Expand All @@ -20,5 +20,5 @@ vec3 latLongUvToDirection( in vec2 latLongUv ) {
vec2 s = vec2(
( latLongUv.x - 0.75 ) * PI2,
latLongUv.y * PI );
return sphericalToCartesian( s );
return nzSphericalToCartesian( s );
}
4 changes: 2 additions & 2 deletions src/lib/shaders/includes/math/spherical.glsl
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#pragma once

// -z is spherical axis
vec3 sphericalToCartesian( vec2 s ) {
vec3 nzSphericalToCartesian( vec2 s ) {
vec2 cs = cos( s );
vec2 ss = sin( s );
return vec3( cs.x * ss.y, cs.y, ss.x * ss.y );
}

// -z is spherical axis
vec2 cartesianToSpherical( vec3 dir ) {
vec2 cartesianToNZSpherical( vec3 dir ) {
return vec2( atan( dir.z, dir.x ), acos( dir.y ) );
}

0 comments on commit 28e3949

Please sign in to comment.