forked from gwaldron/osgearth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeomshader.earth
60 lines (46 loc) · 1.79 KB
/
geomshader.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
<!--
osgEarth Sample - Geometry Shader
This example shows how to inject a GLSL Geometry Shader into the Terrain
Rendering pipeline.
-->
<map name="readymap.org">
<xi:include href="readymap_imagery.xml"/>
<xi:include href="readymap_elevation.xml"/>
<terrainshader>
<code><![CDATA[
#version 330
#pragma vp_entryPoint demo
#pragma vp_location geometry
layout(triangles) in;
layout(triangle_strip) out;
layout(max_vertices = 3) out;
// Internal helper functions:
void VP_LoadVertex(in int);
void VP_EmitModelVertex();
uniform float osg_FrameTime;
vec3 vp_Normal;
vec2 rotate(in vec2 p, in float angle)
{
return vec2(cos(angle)*p.x + sin(angle)*p.y,
cos(angle)*p.y - sin(angle)*p.x);
}
void demo()
{
float strength = mod(osg_FrameTime, 6.28);
// For each vertex in the input triangle:
for(int i=0; i < 3; ++i)
{
// Loads per-vertex data "i" into the stage globals:
VP_LoadVertex(i);
// Transform the vertex:
vec4 pos = gl_in[i].gl_Position;
pos.xy = rotate(pos.xy, strength);
gl_Position = pos;
// Copies stage globals to output and calls EmitVertex():
VP_EmitModelVertex();
}
EndPrimitive();
}
]]></code>
</terrainshader>
</map>