2015-02-24 22:30:59 +00:00
|
|
|
#version 150
|
|
|
|
|
|
|
|
uniform mat4 viewProjectionMatrix;
|
|
|
|
uniform float time;
|
2015-03-01 16:01:41 +00:00
|
|
|
uniform bool bottom;
|
2015-03-01 17:19:19 +00:00
|
|
|
uniform bool left;
|
2015-02-24 22:30:59 +00:00
|
|
|
|
|
|
|
layout(points) in;
|
2015-03-01 17:45:31 +00:00
|
|
|
layout(triangle_strip, max_vertices = 146) out;
|
|
|
|
|
|
|
|
in vec3 Color[];
|
|
|
|
out vec3 fColor;
|
2015-02-27 23:00:30 +00:00
|
|
|
|
|
|
|
const float PI = 3.1415926;
|
2015-02-27 23:52:58 +00:00
|
|
|
const float transition_point = 1.178097;
|
|
|
|
const float sin_p1 = 0.4;
|
|
|
|
const float sin_p2 = 2;
|
|
|
|
const float ex_p1 = 1.093;
|
|
|
|
const float ex_p2 = 1.9996;
|
|
|
|
const float begin = 0;
|
2015-03-01 17:19:19 +00:00
|
|
|
const float end = 2.5;
|
2015-02-27 23:52:58 +00:00
|
|
|
|
|
|
|
float radiusFunction(float x) {
|
|
|
|
if (x < transition_point) {
|
|
|
|
return sin_p1 * sin(sin_p2 * x);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return exp(ex_p1 - ex_p2 * x);
|
|
|
|
}
|
|
|
|
}
|
2015-02-24 22:30:59 +00:00
|
|
|
|
|
|
|
void main() {
|
2015-03-01 17:45:31 +00:00
|
|
|
fColor = Color[0];
|
|
|
|
|
2015-02-27 23:52:58 +00:00
|
|
|
float resolution = 8.0;
|
2015-03-01 16:01:41 +00:00
|
|
|
float step = abs(end-begin)/resolution/2.0;
|
|
|
|
float i = 0.0;
|
|
|
|
float render_end = 0.0;
|
|
|
|
if (bottom) {
|
|
|
|
i = begin;
|
|
|
|
render_end = (end-begin)/2.0+step;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
i = (end-begin)/2.0;
|
|
|
|
render_end = end;
|
|
|
|
}
|
2015-03-01 17:19:19 +00:00
|
|
|
for (i; i<render_end; i+=step) {
|
2015-02-27 23:52:58 +00:00
|
|
|
float downRadius = radiusFunction(i);
|
2015-03-01 17:19:19 +00:00
|
|
|
float upRadius = radiusFunction(i+step);
|
|
|
|
float circle_end = 0.0;
|
|
|
|
int j = 0;
|
|
|
|
if (left) {
|
|
|
|
j = 0;
|
|
|
|
circle_end = resolution/2.0;
|
2015-03-01 15:11:43 +00:00
|
|
|
}
|
2015-03-01 17:19:19 +00:00
|
|
|
else {
|
|
|
|
j = int(resolution/2.0);
|
|
|
|
circle_end = resolution;
|
|
|
|
}
|
|
|
|
for (j; j<circle_end; j++) {
|
|
|
|
float leftAngle = PI * 2.0 / resolution * j;
|
2015-02-27 23:52:58 +00:00
|
|
|
float rightAngle = PI * 2.0 / resolution * (j+1);
|
|
|
|
|
2015-03-01 17:56:56 +00:00
|
|
|
vec4 offset = vec4(cos(rightAngle) * downRadius, i, -sin(rightAngle) * downRadius, 0.0);
|
2015-02-27 23:52:58 +00:00
|
|
|
gl_Position = gl_in[0].gl_Position + viewProjectionMatrix * offset;
|
|
|
|
EmitVertex();
|
|
|
|
|
2015-03-01 17:56:56 +00:00
|
|
|
offset = vec4(cos(rightAngle) * upRadius, i + step, -sin(rightAngle) * upRadius, 0.0);
|
2015-02-27 23:52:58 +00:00
|
|
|
gl_Position = gl_in[0].gl_Position + viewProjectionMatrix * offset;
|
|
|
|
EmitVertex();
|
|
|
|
|
2015-03-01 17:56:56 +00:00
|
|
|
offset = vec4(cos(leftAngle) * downRadius, i, -sin(leftAngle) * downRadius, 0.0);
|
2015-02-27 23:52:58 +00:00
|
|
|
gl_Position = gl_in[0].gl_Position + viewProjectionMatrix * offset;
|
|
|
|
EmitVertex();
|
|
|
|
|
2015-03-01 17:56:56 +00:00
|
|
|
offset = vec4(cos(leftAngle) * upRadius, i + step, -sin(leftAngle) * upRadius, 0.0);
|
2015-02-27 23:52:58 +00:00
|
|
|
gl_Position = gl_in[0].gl_Position + viewProjectionMatrix * offset;
|
|
|
|
EmitVertex();
|
|
|
|
|
|
|
|
EndPrimitive();
|
|
|
|
}
|
2015-02-27 23:00:30 +00:00
|
|
|
}
|
2015-02-24 22:30:59 +00:00
|
|
|
|
|
|
|
}
|