Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Aurora Effect Frag Shader
- by Eddie Lee (twitter: @eddietree)
- http://illogictree.com
- Jan 30, 2012
- */
- #version 110
- varying vec2 uv;
- uniform sampler2D tex;
- uniform vec4 Misc;
- uniform vec4 Color;
- const float PI = 3.14159;
- void main(void)
- {
- float time = Misc.x; // current time
- float timeOffset = Misc.y; // if multiple auroras, have time offset
- float direction = Misc.z; // direction that the effect is fading
- // fetch perlin height
- vec4 perlinTex = texture2D(tex, vec2(uv.x, time*0.00003+timeOffset) );
- float height = perlinTex.x;
- discard( height < uv.y );
- // gentle fading
- float alphaBuffer = 0.3; // buffer from edge
- float alpha = smoothstep(0.0, height*(1.0-alphaBuffer), uv.y );
- alpha *= (1.0-smoothstep( height*(1.0-alphaBuffer*1.5), height, uv.y ));
- alpha *= smoothstep(0.0, alphaBuffer, uv.x);
- alpha *= 1.0-smoothstep(1.0-alphaBuffer, 1.0, uv.x);
- alpha *= sin( PI*2.0*(uv.x+timeOffset)+direction*time*0.0009)*0.5+0.5;
- alpha *= 0.2f;
- vec3 auroraColor = Color.xyz;
- gl_FragColor = vec4(auroraColor, alpha);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement