-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Globe View: Latest shader changes for native port (#11015)
* Add globe view shader changes * Add globe view shader uniforms * Fix flow * Fix lint * Add _prelude.vertex.glsl shader changes * Fix incorrect attribute name * Make elevationVector depend on PROJECTION_GLOBE_VIEW * Address review feedback * Inject precision qualifiers very first * Reduce shader instructions by splitting function mix_globe_mercator * Add missing change to extract pow instruction out of vertex shader * Expose prelude precision qualifiers for native * Adjust precision qualifiers in globe atmosphere shader to fix an issue on Android Co-authored-by: Daniel Eke <daniel.eke@mapbox.com>
- Loading branch information
1 parent
2f62bba
commit 5e069ff
Showing
14 changed files
with
265 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
|
||
#define EPSILON 0.0000001 | ||
#define PI 3.141592653589793 | ||
#define EXTENT 8192.0 | ||
|
||
#ifdef FOG | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,31 @@ | ||
uniform mat4 u_proj_matrix; | ||
uniform mat4 u_globe_matrix; | ||
uniform mat4 u_merc_matrix; | ||
uniform mat4 u_up_vector_matrix; | ||
uniform float u_zoom_transition; | ||
uniform vec2 u_merc_center; | ||
|
||
attribute vec3 a_globe_pos; | ||
attribute vec2 a_merc_pos; | ||
attribute vec2 a_uv; | ||
|
||
varying float v_depth; | ||
|
||
void main() { | ||
gl_Position = u_globe_matrix * vec4(a_globe_pos + elevationVector(a_uv * 8192.0) * elevation(a_uv * 8192.0), 1.0); | ||
vec2 uv = a_uv * EXTENT; | ||
vec4 up_vector = u_up_vector_matrix * vec4(elevationVector(uv), 1.0); | ||
float height = elevation(uv); | ||
|
||
vec4 globe = u_globe_matrix * vec4(a_globe_pos + up_vector.xyz * height, 1.0); | ||
|
||
vec4 mercator = vec4(a_merc_pos, height, 1.0); | ||
mercator.xy -= u_merc_center; | ||
mercator.x = wrap(mercator.x, -0.5, 0.5); | ||
mercator = u_merc_matrix * mercator; | ||
|
||
vec3 position = mix(globe.xyz, mercator.xyz, u_zoom_transition); | ||
|
||
gl_Position = u_proj_matrix * vec4(position, 1.0); | ||
|
||
v_depth = gl_Position.z / gl_Position.w; | ||
} |
Oops, something went wrong.