Skip to content

Commit 961c9f7

Browse files
committed
Add sea ice / belgica example
1 parent 944e053 commit 961c9f7

26 files changed

+5961
-0
lines changed

Examples/Sea-Ice/PlotRoute.ipynb

+2,033
Large diffs are not rendered by default.

Examples/Sea-Ice/belgica_sea_ice.ipynb

+2,581
Large diffs are not rendered by default.

Examples/Sea-Ice/blank.png

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../Earth/blank.png

Examples/Sea-Ice/ice10.png

14.1 KB
Loading

Examples/Sea-Ice/ice100.png

4.24 KB
Loading

Examples/Sea-Ice/ice20.png

11.1 KB
Loading

Examples/Sea-Ice/ice30.png

14 KB
Loading

Examples/Sea-Ice/ice40.png

16.8 KB
Loading

Examples/Sea-Ice/ice50.png

16.9 KB
Loading

Examples/Sea-Ice/ice60.png

14.7 KB
Loading

Examples/Sea-Ice/ice70.png

13 KB
Loading

Examples/Sea-Ice/ice80.png

12.2 KB
Loading

Examples/Sea-Ice/ice90.png

11.9 KB
Loading

Examples/Sea-Ice/minerva_sailing.glb

26.3 MB
Binary file not shown.
+148
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
[
2+
["1897-08-16 00:00:00", 51.26953340758905, 4.34386826237909, "Antwerp"],
3+
["1897-08-17 00:00:00", 51.58611304403033, 3.024684099415726, "Leaving Antwerp"],
4+
["1897-08-20 00:00:00", 51.04306177717298, 1.50651993780152, "Calais"],
5+
["1897-08-23 00:00:00", 50.11262330523707, -1.5574131969852607, ""],
6+
["1897-08-27 00:00:00", 48.719126453652564, -4.8944577174936965, "*Brest"],
7+
["1897-09-02 00:00:00", 43.250325916094596, -9.348930093100057, "*Off Portugal"],
8+
["1897-09-14 00:00:00", 32.63671092044728, -16.777184832834788, "Madeira"],
9+
["1897-09-17 00:00:00", 28.17458906624457, -16.053729393626224, "*Canary Islands"],
10+
["1897-09-24 00:00:00", 16.492440567998386, -23.82445702188258, "Cabo Verde Islands"],
11+
["1897-10-07 00:00:00", -0.5833333333333334, -29.333333333333332, "Passed equator 10/6 10pm"],
12+
["1897-10-12 00:00:00", -10.788658222330342, -34.07511312311262, "*Off Brazil 2"],
13+
["1897-10-19 00:00:00", -22.193539256415548, -40.44357504673879, "*"],
14+
["1897-10-20 00:00:00", -23.0098341136291, -41.87722683739779, "Cabo Frio"],
15+
["1897-10-21 00:00:00", -23.094953082816815, -42.0315253353462, "Near Rio"],
16+
["1897-10-22 00:00:00", -22.9, -43.166666666666664, "Rio de Janeiro (official arrival 22/10 2pm)"],
17+
["1897-10-30 00:00:00", -22.9, -43.166666666666664, "Rio de Janeiro (dep)"],
18+
["1897-11-04 00:00:00", -26.23071714710112, -48.04684456147329, "Santa Francisco Is (Off Santa Catarina Isle 12pm)"],
19+
["1897-11-05 00:00:00", -28.50985269860602, -48.487274818343245, "*"],
20+
["1897-11-06 00:00:00", -30.39262579157434, -49.73491971375714, "Off Porto Alegre"],
21+
["1897-11-08 00:00:00", -34.408220216288576, -53.774832907259885, "Cabo Polonio"],
22+
["1897-11-09 00:00:00", -34.80183873142795, -54.322510755161545, ""],
23+
["1897-11-10 00:00:00", -35.031854464240766, -54.94921053370017, ""],
24+
["1897-11-11 00:00:00", -34.91798647702233, -56.188631699412326, "Montevideo"],
25+
["1897-11-14 00:00:00", -34.91798647702233, -56.188631699412326, "Montevideo"],
26+
["1897-11-15 00:00:00", -35.36913828708609, -56.23701843243335, "*Leaving (Didn't stop at Beunos Aires)"],
27+
["1897-11-17 00:00:00", -37.92071930740922, -56.318119625063424, ""],
28+
["1897-11-28 00:00:00", -50.65072640343143, -67.81128568446269, "*Puerto Santa Cruz"],
29+
["1897-11-29 00:00:00", -52.402457726705535, -68.35783096842283, "Entering Strait of Magellan"],
30+
["1897-11-30 00:00:00", -52.627574309360185, -70.18471635897484, ""],
31+
["1897-12-01 00:00:00", -53.171514259298824, -70.88460262373157, "Punta Arenas"],
32+
["1897-12-13 00:00:00", -53.171514259298824, -70.88460262373157, "Punta Arenas"],
33+
["1897-12-14 00:00:00", -54.079623441887804, -71.04768956013626, "Hope Harbour"],
34+
["1897-12-15 00:00:00", -54.37886175394167, -70.972790265031, "Cockburn Channel E"],
35+
["1897-12-16 00:00:00", -54.56676443953554, -72.08362718624484, "Cockburn Channel W"],
36+
["1897-12-17 00:00:00", -54.90525986996838, -70.53378521265452, " O'brian Island"],
37+
["1897-12-21 00:00:00", -54.81289069011044, -68.29336254452005, "Ushuaia"],
38+
["1897-12-30 00:00:00", -54.81289069011044, -68.29336254452005, "Ushuaia"],
39+
["1898-01-03 00:00:00", -54.877977794749654, -67.32733649595384, "Harberton"],
40+
["1898-01-04 00:00:00", -55.14656472546485, -66.19976219393143, "*"],
41+
["1898-01-05 00:00:00", -54.73957885126442, -64.90218083883991, "Le Maire Strait"],
42+
["1898-01-06 00:00:00", -54.73098644769246, -63.85583273702932, "Staten Island"],
43+
["1898-01-14 00:00:00", -54.73098644769246, -63.85583273702932, "Leaving for Antarctica"],
44+
["1898-01-17 00:00:00", -58.71666666666667, -63.71666666666667],
45+
["1898-01-22 00:00:00", -63.333333333333336, -62.36666666666667],
46+
["1898-01-29 00:00:00", -64.41666666666667, -61.8],
47+
["1898-02-13 00:00:00", -65.25833, -64.5],
48+
["1898-02-15 00:00:00", -66.88922385028629, -69.39509877045862, "*"],
49+
["1898-02-16 00:00:00", -67.995, -70.65],
50+
["1898-02-18 00:00:00", -68.71666666666667, -76.95],
51+
["1898-02-19 00:00:00", -69.1, -78.35],
52+
["1898-02-20 00:00:00", -69.16667, -79.0],
53+
["1898-02-22 00:00:00", -69.81666666666666, -81.13333333333334],
54+
["1898-03-04 00:00:00", -71.36667, -84.91667, "The ice closed - the Belgica was stuck"],
55+
["1898-03-05 00:00:00", -71.31667, -85.46667],
56+
["1898-03-11 00:00:00", -71.15, -89.25],
57+
["1898-04-09 00:00:00", -70.86666666666666, -89.16666666666667],
58+
["1898-04-11 00:00:00", -70.8, -89.63333333333334],
59+
["1898-04-14 00:00:00", -70.86666666666666, -90.33333333333333],
60+
["1898-04-21 00:00:00", -71.03333, -92.05],
61+
["1898-04-24 00:00:00", -70.9, -92.26667],
62+
["1898-04-25 00:00:00", -70.83333, -92.36667],
63+
["1898-04-26 00:00:00", -70.83333, -92.36667],
64+
["1898-04-27 00:00:00", -70.8, -91.9],
65+
["1898-04-29 00:00:00", -70.73333, -90.96667],
66+
["1898-04-30 00:00:00", -70.71666666666667, -90.51666666666667],
67+
["1898-05-01 00:00:00", -70.68333, -90.23333],
68+
["1898-05-02 00:00:00", -70.63333333333334, -89.93333333333334],
69+
["1898-05-04 00:00:00", -70.55, -89.36667],
70+
["1898-05-06 00:00:00", -70.8, -89.33333333333333],
71+
["1898-05-07 00:00:00", -70.81667, -89.31667],
72+
["1898-05-11 00:00:00", -71.15, -89.25],
73+
["1898-05-12 00:00:00", -71.23333, -89.23333],
74+
["1898-05-14 00:00:00", -71.4, -89.2],
75+
["1898-05-15 00:00:00", -71.48333333333333, -89.18333333333334],
76+
["1898-05-18 00:00:00", -71.3, -88.03333],
77+
["1898-05-20 00:00:00", -71.25, -87.63333333333334],
78+
["1898-05-21 00:00:00", -71.25, -87.45],
79+
["1898-05-24 00:00:00", -71.21667, -87.73333],
80+
["1898-05-27 00:00:00", -71.25, -87.65],
81+
["1898-05-28 00:00:00", -71.31667, -87.61667],
82+
["1898-07-05 00:00:00", -70.86666666666666, -86.33333333333333],
83+
["1898-08-01 00:00:00", -70.71666666666667, -86.56666666666666],
84+
["1898-08-02 00:00:00", -70.7, -86.56666666666666],
85+
["1898-08-03 00:00:00", -70.68333333333334, -86.56666666666666],
86+
["1898-08-04 00:00:00", -70.66666666666667, -86.55],
87+
["1898-08-20 00:00:00", -70.2, -84.05],
88+
["1898-08-27 00:00:00", -70.21666666666667, -83.45],
89+
["1898-08-31 00:00:00", -70.08333, -83.11667],
90+
["1898-09-03 00:00:00", -69.98333, -82.65],
91+
["1898-09-06 00:00:00", -69.91667, -82.6],
92+
["1898-09-07 00:00:00", -69.9, -82.58333333333333],
93+
["1898-09-08 00:00:00", -69.9, -82.63333333333334],
94+
["1898-09-09 00:00:00", -69.85, -82.6],
95+
["1898-09-12 00:00:00", -69.83333333333333, -82.93333333333334],
96+
["1898-09-13 00:00:00", -69.83333, -83.05],
97+
["1898-09-18 00:00:00", -70.0, -82.5],
98+
["1898-09-27 00:00:00", -70.4, -82.61667],
99+
["1898-10-02 00:00:00", -70.4, -82.7],
100+
["1898-10-08 00:00:00", -70.38333, -81.78333],
101+
["1898-10-13 00:00:00", -70.06667, -81.8],
102+
["1898-10-15 00:00:00", -70.0, -81.0],
103+
["1898-10-17 00:00:00", -70.0, -80.75],
104+
["1898-10-18 00:00:00", -70.0, -80.8],
105+
["1898-10-27 00:00:00", -69.63333333333334, -80.6],
106+
["1898-11-01 00:00:00", -69.83333, -81.0],
107+
["1898-11-03 00:00:00", -69.8, -81.31667],
108+
["1898-11-07 00:00:00", -70.0, -81.5],
109+
["1898-11-08 00:00:00", -70.15, -82],
110+
["1898-11-10 00:00:00", -70.15, -82.58333],
111+
["1898-11-22 00:00:00", -70.16667, -82.5],
112+
["1898-11-23 00:00:00", -70.25, -83.16667],
113+
["1898-11-25 00:00:00", -70.41667, -83.45],
114+
["1898-11-29 00:00:00", -70.33333, -83.38333],
115+
["1898-12-02 00:00:00", -70.16667, -83.5],
116+
["1898-12-06 00:00:00", -69.9, -82.81667],
117+
["1898-12-11 00:00:00", -69.81667, -82.75],
118+
["1898-12-13 00:00:00", -69.81667, -82.83333],
119+
["1898-12-17 00:00:00", -70.0, -83.5],
120+
["1898-12-19 00:00:00", -70.3, -84.85],
121+
["1898-12-27 00:00:00", -70.3333, -85.86667],
122+
["1898-12-29 00:00:00", -70.25, -85.85],
123+
["1898-12-31 00:00:00", -70.01667, -85.33333],
124+
["1899-01-01 00:00:00", -69.93333, -85.16667],
125+
["1899-01-02 00:00:00", -69.86666666666666, -85.21666666666667],
126+
["1899-01-15 00:00:00", -70.15, -86.56666666666666],
127+
["1899-01-19 00:00:00", -70.25, -87.08333333333333],
128+
["1899-01-20 00:00:00", -70.26666666666667, -87.2],
129+
["1899-01-23 00:00:00", -70.33333333333333, -87.46666666666667],
130+
["1899-01-24 00:00:00", -70.33333, -87.5],
131+
["1899-01-25 00:00:00", -70.38333333333334, -87.73333333333333],
132+
["1899-02-08 00:00:00", -70.61666666666666, -92.43333333333334],
133+
["1899-02-10 00:00:00", -70.56666666666666, -93.28333333333333],
134+
["1899-02-11 00:00:00", -70.56667, -93.28333],
135+
["1899-02-16 00:00:00", -70.5, -93.95, "Channel opens"],
136+
["1899-02-17 00:00:00", -70.5, -94.03333333333333],
137+
["1899-02-19 00:00:00", -70.5, -94.2],
138+
["1899-02-20 00:00:00", -70.51666666666667, -94.11666666666666],
139+
["1899-02-21 00:00:00", -70.53333333333333, -94.2],
140+
["1899-02-24 00:00:00", -70.58333333333333, -94.45],
141+
["1899-02-27 00:00:00", -70.66666666666667, -94.7],
142+
["1899-03-01 00:00:00", -70.88333, -97.5],
143+
["1899-03-05 00:00:00", -70.58, -97.95],
144+
["1899-03-10 00:00:00", -70.9, -99.58333],
145+
["1899-03-14 00:00:00", -70.55, -102.25, "Open sea"],
146+
["1899-03-27 00:00:00", -54.51824267937001, -72.128826862758, "Cockburn Channel"],
147+
["1899-03-28 00:00:00", -53.171514259298824, -70.88460262373157, "Punta Arenas"]
148+
]

Examples/Sea-Ice/screen.frag

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
in vec4 vColour;
2+
in vec3 vVertex;
3+
in vec2 vTexCoord;
4+
uniform sampler2D uTexture;
5+
out vec4 outColour;
6+
//Custom uniform
7+
uniform float size = 0.25;
8+
uniform ivec2 res = ivec2(1920,1080);
9+
//uniform ivec2 offset = vec2(0.75,0);
10+
11+
void main(void)
12+
{
13+
//Scale by 1/scaling
14+
//TODO: pass viewport size and calculate correct scaling/aspect
15+
//1080/1920 = 0.5625
16+
float f = float(res[1]) / float(res[0]);
17+
//float size = 0.3;
18+
vec2 scaling = vec2(size*f, size); //, 0.3);
19+
vec2 texCoord = vec2(vTexCoord.x / scaling.x, vTexCoord.y / scaling.y);
20+
21+
//Offset to top right corner
22+
texCoord -= vec2((1.0 - 0.52*size) / scaling.x, -0.085*size / scaling.y);
23+
//Offset to bottom right corner
24+
//texCoord -= vec2((1.0 - 0.52*size) / scaling.x, (1.0 - size) / scaling.y);
25+
texCoord.y = 1.0 - texCoord.y;
26+
27+
if (texCoord.x >= 0.0 && texCoord.y >= 0.0 && texCoord.x <= 1.0 && texCoord.y <= 1.0)
28+
outColour = texture(uTexture, texCoord);
29+
else
30+
discard;
31+
32+
//Discard transparent to skip depth write
33+
//This fixes depth buffer output interfering with other objects
34+
// in transparent areas
35+
if (outColour.a <= 0.1)
36+
discard;
37+
}
38+

Examples/Sea-Ice/screen.vert

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
in vec3 aVertexPosition;
2+
in vec3 aVertexNormal;
3+
in vec4 aVertexColour;
4+
in vec2 aVertexTexCoord;
5+
6+
uniform mat4 uMVMatrix;
7+
uniform mat4 uPMatrix;
8+
uniform mat4 uNMatrix;
9+
10+
uniform vec4 uColour;
11+
12+
out vec4 vColour;
13+
out vec3 vVertex;
14+
out vec3 vNormal;
15+
out vec2 vTexCoord;
16+
void main(void) {
17+
gl_Position = vec4(aVertexPosition, 1.0);
18+
19+
vNormal = normalize(mat3(uNMatrix) * aVertexNormal);
20+
21+
if (uColour.a > 0.0)
22+
vColour = uColour;
23+
else
24+
vColour = aVertexColour;
25+
26+
vTexCoord = aVertexTexCoord;
27+
vVertex = aVertexPosition;
28+
}
29+
3.1 MB
Loading

Examples/Sea-Ice/triShader.frag

+170
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
in vec4 vColour;
2+
in vec3 vNormal;
3+
in vec3 vPosEye;
4+
in vec3 vVertex;
5+
in vec2 vTexCoord;
6+
in vec3 vLightPos;
7+
8+
uniform float uOpacity;
9+
uniform bool uLighting;
10+
uniform float uBrightness;
11+
uniform float uContrast;
12+
uniform float uSaturation;
13+
uniform float uAmbient;
14+
uniform float uDiffuse;
15+
uniform float uSpecular;
16+
uniform float uShininess;
17+
18+
uniform bool uTextured;
19+
uniform sampler2D uTexture;
20+
uniform vec3 uClipMin;
21+
uniform vec3 uClipMax;
22+
uniform bool uOpaque;
23+
uniform vec4 uLight;
24+
25+
#ifdef WEBGL
26+
#define outColour gl_FragColor
27+
#define texture(a,b) texture2D(a,b)
28+
29+
//Before OpenGL 3+ we need our own isnan function
30+
bool isnan3(vec3 val)
31+
{
32+
if (!(val.x < 0.0 || 0.0 < val.x || val.x == 0.0)) return true;
33+
if (!(val.y < 0.0 || 0.0 < val.y || val.y == 0.0)) return true;
34+
if (!(val.z < 0.0 || 0.0 < val.z || val.z == 0.0)) return true;
35+
return false;
36+
}
37+
38+
#else
39+
#define isnan3(v) any(isnan(v))
40+
flat in vec4 vFlatColour;
41+
uniform bool uFlat;
42+
out vec4 outColour;
43+
#endif
44+
45+
uniform bool uCalcNormal;
46+
47+
void calcColour(vec3 colour, float alpha)
48+
{
49+
//Brightness adjust
50+
colour += uBrightness;
51+
//Saturation & Contrast adjust
52+
const vec3 LumCoeff = vec3(0.2125, 0.7154, 0.0721);
53+
vec3 AvgLumin = vec3(0.5, 0.5, 0.5);
54+
vec3 intensity = vec3(dot(colour, LumCoeff));
55+
colour = mix(intensity, colour, uSaturation);
56+
colour = mix(AvgLumin, colour, uContrast);
57+
58+
//Gamma correction
59+
//https://en.wikipedia.org/wiki/Blinn%E2%80%93Phong_reflection_model#OpenGL_Shading_Language_code_sample
60+
//const float screenGamma = 2.2; // Assume the monitor is calibrated to the sRGB color space
61+
//vec3 colorGammaCorrected = pow(color, vec3(1.0 / screenGamma));
62+
63+
outColour = vec4(colour, alpha);
64+
}
65+
66+
void main(void)
67+
{
68+
//Clip planes in X/Y/Z
69+
if (any(lessThan(vVertex, uClipMin)) || any(greaterThan(vVertex, uClipMax))) discard;
70+
71+
vec4 fColour = vColour;
72+
#ifndef WEBGL
73+
if (uFlat)
74+
fColour = vFlatColour;
75+
#endif
76+
float alpha = fColour.a;
77+
if (uTextured && vTexCoord.x > -1.0) //Null texcoord (-1,-1)
78+
{
79+
//With this blending mode, texture is blended over base colour,
80+
//and colour opacity has no effect on texture opacity
81+
//All desired texture opacity must be built in to the texture data
82+
//(Could add another blend mode if we want a dynamic texture opacity)
83+
vec4 tColour = texture(uTexture, vTexCoord);
84+
if (fColour.a > 0.01)
85+
{
86+
//Additive blend alpha channel
87+
alpha = fColour.a + tColour.a * (1.0 - fColour.a);
88+
89+
//Blend the texure colour with the fragment colour using texture alpha
90+
fColour.rgb = vec3(mix(fColour.rgb, tColour.rgb, tColour.a));
91+
}
92+
else
93+
{
94+
//Disable all blending if the base colour opacity <= 0.01
95+
fColour = tColour;
96+
alpha = tColour.a;
97+
}
98+
}
99+
100+
if (uOpacity > 0.0) alpha *= uOpacity;
101+
if (uOpaque) alpha = 1.0;
102+
if (alpha < 0.01) discard;
103+
104+
if (!uLighting)
105+
{
106+
calcColour(fColour.rgb, alpha);
107+
return;
108+
}
109+
110+
vec3 lightColour = uLight.xyz;
111+
112+
//Light direction
113+
vec3 lightDir = normalize(vLightPos - vPosEye);
114+
115+
//Calculate diffuse lighting
116+
vec3 N = normalize(vNormal);
117+
118+
//Default normal...
119+
if (uCalcNormal || dot(N,N) < 0.01 || isnan3(N))
120+
{
121+
//Requires extension in WebGL: OES_standard_derivatives
122+
vec3 fdx = vec3(dFdx(vPosEye.x),dFdx(vPosEye.y),dFdx(vPosEye.z));
123+
vec3 fdy = vec3(dFdy(vPosEye.x),dFdy(vPosEye.y),dFdy(vPosEye.z));
124+
N = normalize(cross(fdx,fdy));
125+
}
126+
127+
//Modified to use energy conservation adjustment
128+
//https://learnopengl.com/Advanced-Lighting/Advanced-Lighting
129+
const float kPi8 = 3.14159265 * 8.0;
130+
131+
//Calculate diffuse component
132+
//Single side or two-sided lighting with abs()?
133+
float diffuse = dot(N, lightDir);
134+
if (uLight.w < 0.5)
135+
diffuse = abs(diffuse);
136+
else
137+
diffuse = max(diffuse, 0.0);
138+
139+
//Compute the specular term
140+
if (diffuse > 0.0 && uSpecular > 0.0)
141+
{
142+
//Specular power, higher is more focused/shiny
143+
float shininess = 256.0 * clamp(uShininess, 0.0, 1.0);
144+
vec3 specolour = lightColour; //Color of light - use the same as diffuse/ambient
145+
//Blinn-Phong
146+
vec3 viewDir = normalize(-vPosEye);
147+
//Normalize the half-vector
148+
vec3 halfVector = normalize(lightDir + viewDir);
149+
150+
//Compute cosine (dot product) with the normal
151+
float NdotHV = dot(N, halfVector);
152+
//Single side or two-sided lighting with abs()?
153+
if (uLight.w < 0.5)
154+
NdotHV = abs(NdotHV);
155+
else
156+
NdotHV = max(NdotHV, 0.0);
157+
158+
//Energy conservation adjustment (more focused/shiny highlight will be brighter)
159+
float energyConservation = ( 8.0 + shininess) / kPi8;
160+
//Multiplying specular by diffuse prevents bands at edges for low shininess
161+
float spec = diffuse * uSpecular * energyConservation * pow(NdotHV, shininess);
162+
163+
//Final colour - specular + diffuse + ambient
164+
calcColour(lightColour * (fColour.rgb * (uAmbient + uDiffuse * diffuse) + vec3(spec)), alpha);
165+
}
166+
else
167+
//Final colour - diffuse + ambient only
168+
calcColour(lightColour * fColour.rgb * (uAmbient + diffuse * uDiffuse), alpha);
169+
}
170+

0 commit comments

Comments
 (0)