forked from gwaldron/osgearth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday_night.earth
58 lines (50 loc) · 1.76 KB
/
day_night.earth
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<!--
osgEarth example - use a layer shader to simulate day/night transition
Run with the "--sky" argument.
Earth at night imagery:
https://earthobservatory.nasa.gov/Features/NightLights/page3.php
-->
<map name="Day/Night Transition">
<xi:include href="readymap_imagery.xml"/>
<TMSImage name="EarthAtNight">
<url>http://readymap.org/readymap/tiles/1.0.0/26/</url>
<shader>
<![CDATA[
#pragma vp_entryPoint dayNight
#pragma vp_location fragment_coloring
#pragma import_defines(OE_NUM_LIGHTS)
#ifndef OE_NUM_LIGHTS
#define OE_NUM_LIGHTS 1
#endif
// stage global - interpolated UP vector at fragment
vec3 vp_Normal;
struct osg_LightSourceParameters
{
vec4 ambient;
vec4 diffuse;
vec4 specular;
vec4 position;
vec3 spotDirection;
float spotExponent;
float spotCutoff;
float spotCosCutoff;
float constantAttenuation;
float linearAttenuation;
float quadraticAttenuation;
bool enabled;
};
uniform osg_LightSourceParameters osg_LightSource[OE_NUM_LIGHTS];
void dayNight(inout vec4 color)
{
vec3 L = normalize(osg_LightSource[0].position.xyz);
vec3 N = normalize(vp_Normal);
float NdotL = dot(N,L);
float vmin = -0.55;
float vmax = 0.0;
float day = (clamp(NdotL, vmin, vmax) - vmin)/(vmax-vmin);
color.a *= (1.0 - day);
}
]]>
</shader>
</TMSImage>
</map>