Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- This is a fragment shader file, if you don't know anything about it
- you can run it here online -> http://editor.thebookofshaders.com/
- just copy and paste the code
- */
- precision mediump float;
- uniform vec2 u_resolution;
- uniform vec2 u_mouse;
- uniform float u_time;
- float diatance(vec2 p1, vec2 p2){ //distance function
- return
- (sqrt(
- (pow( (p2.y - p1.y) , 2.0) + pow( (p2.x - p1.x), 2.0))
- ));
- }
- void main() {
- vec2 centre = vec2(u_resolution.x/2.0,u_resolution.y/2.0);
- float R,G,B,A, dist, size1, size2, tmp;
- vec3 color;
- size1 = 100.0;
- size1 *= ((abs(sin(u_time / 3.0))) + 0.5); //--comment this line to stop growth
- // animation
- centre.y *= (abs(sin(u_time*2.0))); //--comment to stop position animation
- size2 = (size1 * 4.0);
- size2 *= (abs( sin( u_time / 2.0 )) / 5.0 ) + 0.8; //--animating warmth | comment to stop
- dist = distance(gl_FragCoord.xy, centre); //--distance of each pixel from centre
- if( dist <= size1){ //--sun color
- tmp = dist/size1;
- R = 1.0;
- G = (1.0 - pow((dist/size1)*0.9,8.0));
- B = (1.0 - pow(tmp,0.5));
- }
- else if(dist <= size2){ //--set shine/warmth color
- tmp = dist/size2;
- R = (1.0 - clamp(pow(tmp,5.0),0.0,0.7));
- G = (1.0 - clamp(pow(tmp,3.0),0.0,0.2));
- B = (pow (tmp,1.0));
- }
- else{ //--set sky color
- R = 0.3;
- B = 1.0;
- G = 0.8;
- }
- color = vec3(R,G,B);
- A = 1.0;
- gl_FragColor = vec4(color,A);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement