1
0
Fork 0
fgdata/Compositor/Shaders/ALS/planet-aurora.vert

33 lines
744 B
GLSL
Raw Normal View History

#version 120
varying vec3 vertex;
varying vec3 normal;
varying vec3 relVec;
uniform float fg_Fcoef;
uniform float osg_SimulationTime;
uniform float arc_id;
void main()
{
normal = gl_Normal;
vertex = gl_Vertex.xyz;
vec3 ep = (gl_ModelViewMatrixInverse * vec4 (0.0, 0.0, 0.0, 1.0)).xyz;
relVec = vertex - ep;
vec4 vert_out = gl_Vertex;
float ang = dot(vert_out.xy, vec2 (0.0, 1.0));
vert_out.x *= (1.0 + 0.05 * sin(ang + 0.1 * osg_SimulationTime + arc_id));
vert_out.y *= (1.0 + 0.05 * sin(ang + 0.12 * osg_SimulationTime + arc_id));
gl_Position = gl_ModelViewProjectionMatrix * vert_out;
// logarithmic depth
gl_Position.z = (log2(max(1e-6, 1.0 + gl_Position.w)) * fg_Fcoef - 1.0) * gl_Position.w;
}