forked from gwaldron/osgearth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfeature_offset_polygons.earth
112 lines (94 loc) · 3.8 KB
/
feature_offset_polygons.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!--
osgEarth Sample
This one demonstrates use of the "terrainshader" extension to use
GLSL to affect a polygon offset effect.
-->
<map name="Feature Overlay Demo" type="geocentric" version="2">
<options>
<lighting>false</lighting>
<overlay_blending>false</overlay_blending>
<terrain min_lod="8"/>
</options>
<extensions>
<terrainshader>
<description>
A GLSL snippet that pushes the terrain back to prevent high-altitude z fighting.
</description>
<code>
<![CDATA[
#version 110
#pragma vp_entryPoint "dp_vert" // name of entry point function
#pragma vp_location "vertex_view" // where to insert this shader in the pipeline
varying out float tt;
void dp_vert(inout vec4 v)
{
const float R = 6371000.0; // Approximate radius of the earth
const float dmin = 100000.0; // Minimum vertex distance at which to apply effect
const float dmax = R; // Vertex distance at which to apply maximum effect
const float maxOffset = 250000.0; // Maximum offset (applied at dmax)
float d = length(v.xyz);
float t = clamp( (d-dmin)/(dmax-dmin), 0.0, 1.0 );
float offset = t*maxOffset;
vec3 n = normalize(v.xyz);
v.xyz = v.xyz + n*offset;
tt = t;
}
]]>
</code>
</terrainshader>
</extensions>
<image name="world" driver="gdal">
<url>../data/world.tif</url>
</image>
<model name="countries" driver="feature_geom">
<features name="states" driver="ogr">
<url>../data/world.shp</url>
<buffer distance="-0.05"/>
<resample max_length="5.0"/>
</features>
<styles>
<style type="text/css">
p1 {
fill: #ffff8066;
}
p2 {
fill: #80ffff66;
}
p3 {
fill: #ff80ff66;
}
p4 {
fill: #ff808066;
}
p5 {
fill: #80ff8066;
}
</style>
<selector class="p1">
<query>
<expr><![CDATA[ POP_CNTRY <= 14045470 ]]></expr>
</query>
</selector>
<selector class="p2">
<query>
<expr><![CDATA[ POP_CNTRY > 14045470 and POP_CNTRY <= 43410900 ]]></expr>
</query>
</selector>
<selector class="p3">
<query>
<expr><![CDATA[ POP_CNTRY > 43410900 and POP_CNTRY <= 97228750 ]]></expr>
</query>
</selector>
<selector class="p4">
<query>
<expr><![CDATA[ POP_CNTRY > 97228750 and POP_CNTRY <= 258833000 ]]></expr>
</query>
</selector>
<selector class="p5">
<query>
<expr><![CDATA[ POP_CNTRY > 258833000 ]]></expr>
</query>
</selector>
</styles>
</model>
</map>