Just thought some good weather effects the main one I would like now is a thunder one that you can change the xy start location
but think I should be able to convert the one you shared
Here is 2 Shaders from
Smiley Madness I ended up not using the the Snow Shader because of frame rates but the Lense shader
worked well
function CreateSnowShader()
file = OpenToWrite("snow.ps")
WriteLine(file,"varying mediump vec2 uvVarying;")
WriteLine(file,"uniform float agk_time;")
WriteLine(file,"uniform vec4 Settings;")
WriteLine(file,"uniform sampler2D texture0;") //Added this for colouring
WriteLine(file,"varying vec4 colorVarying;//") //Added this colour varying variable so as it will blend with background
WriteLine(file,"void main( )")
WriteLine(file,"{")
WriteLine(file,"const mat3 p = mat3(13.323122,23.5112,21.71123,21.1212,28.7312,11.9312,21.8112,14.7212,61.3934);")
WriteLine(file,"vec2 uv = uvVarying;")
WriteLine(file,"vec3 acc = vec3(0.0);")
WriteLine(file,"float dof = 5.*sin(agk_time*.1);")
WriteLine(file,"for (int i=0;i<int(Settings.r);i++) {")
WriteLine(file,"float fi = float(i);")
WriteLine(file,"vec2 q = uv*(1.+fi*Settings.g);")
WriteLine(file,"q += vec2(q.y*(Settings.b*mod(fi*7.238917,1.)-Settings.b*.5),Settings.a*-agk_time/(1.+fi*Settings.g*.03));")
WriteLine(file,"vec3 n = vec3(floor(q),31.189+fi);")
WriteLine(file,"vec3 m = floor(n)*.00001 + fract(n);")
WriteLine(file,"vec3 mp = (31415.9+m)/fract(p*m);")
WriteLine(file,"vec3 r = fract(mp);")
WriteLine(file,"vec2 s = abs(mod(q,1.)-.5+.9*r.xy-.45);")
WriteLine(file,"s += .01*abs(2.*fract(10.*q.yx)-1.);")
WriteLine(file,"float d = .6*max(s.x-s.y,s.x+s.y)+max(s.x,s.y)-.01;")
WriteLine(file,"float edge = .005+.05*min(.5*abs(fi-5.-dof),1.);")
WriteLine(file,"acc += vec3(smoothstep(edge,-edge,d)*(r.x/(.25+.02*fi*Settings.g)));")
WriteLine(file,"}")
WriteLine(file,"gl_FragColor = vec4(vec3(acc),1.0);")
//added an additive colour blend
WriteLine(file,"gl_FragColor = texture2D(texture0, uvVarying) + gl_FragColor;")
//change for a subtractive colour blend
//WriteLine(file,"gl_FragColor = texture2D(texture0, uvVarying) - gl_FragColor;")
//change for a multiply color blend
//WriteLine(file,"gl_FragColor = texture2D(texture0, uvVarying) * gl_FragColor;")
WriteLine(file,"}")
CloseFile(file)
endfunction
function CreateLenseFlare()
file = OpenToWrite("lensflare.ps")
WriteLine(file,"uniform float agk_time;")
WriteLine(file,"uniform sampler2D texture0;") //added this for colouring
WriteLine(file,"varying mediump vec2 uvVarying;")
WriteLine(file,"uniform vec2 agk_resolution;")
WriteLine(file,"uniform mediump vec2 Position;")
WriteLine(file,"varying vec4 colorVarying;//") //Added this colour varying variable so as it will blend with background
WriteLine(file,"float noise(float t)")
WriteLine(file,"{")
WriteLine(file,"return texture2D(texture0,vec2(t, 0.0) / agk_resolution.xy).x;")
WriteLine(file,"}")
WriteLine(file,"float noise(vec2 t)")
WriteLine(file,"{")
WriteLine(file,"return texture2D(texture0,(t + vec2(agk_time)) / agk_resolution.xy).x;")
WriteLine(file,"}")
WriteLine(file,"vec3 lensflare(vec2 uv,vec2 pos)")
WriteLine(file,"{")
WriteLine(file,"vec2 main = uv-pos;")
WriteLine(file,"vec2 uvd = uv*(length(uv));")
WriteLine(file,"float ang = atan(main.y, main.x);")
WriteLine(file,"float dist=length(main); dist = pow(dist,.1);")
WriteLine(file,"float n = noise(vec2((ang-agk_time/9.0)*16.0,dist*32.0));")
WriteLine(file,"float f0 = 1.0/(length(uv-pos)*16.0+1.0);")
WriteLine(file,"f0 = f0+f0*(sin((ang+agk_time/18.0 + noise(abs(ang)+n/2.0)*2.0)*12.0)*.1+dist*.1+.8);")
WriteLine(file,"float f2 = max(1.0/(1.0+32.0*pow(length(uvd+0.8*pos),2.0)),.0)*00.25;")
WriteLine(file,"float f22 = max(1.0/(1.0+32.0*pow(length(uvd+0.85*pos),2.0)),.0)*00.23;")
WriteLine(file,"float f23 = max(1.0/(1.0+32.0*pow(length(uvd+0.9*pos),2.0)),.0)*00.21;")
WriteLine(file,"vec2 uvx = mix(uv,uvd,-0.5);")
WriteLine(file,"float f4 = max(0.01-pow(length(uvx+0.4*pos),2.4),.0)*6.0;")
WriteLine(file,"float f42 = max(0.01-pow(length(uvx+0.45*pos),2.4),.0)*5.0;")
WriteLine(file,"float f43 = max(0.01-pow(length(uvx+0.5*pos),2.4),.0)*3.0;")
WriteLine(file,"uvx = mix(uv,uvd,-.2);")
WriteLine(file,"float f5 = max(0.01-pow(length(uvx+0.2*pos),5.5),.0)*2.0;")
WriteLine(file,"float f52 = max(0.01-pow(length(uvx+0.4*pos),5.5),.0)*2.0;")
WriteLine(file,"float f53 = max(0.01-pow(length(uvx+0.6*pos),5.5),.0)*2.0;")
WriteLine(file,"uvx = mix(uv,uvd,-0.5);")
WriteLine(file,"float f6 = max(0.01-pow(length(uvx-0.3*pos),1.6),.0)*6.0;")
WriteLine(file,"float f62 = max(0.01-pow(length(uvx-0.325*pos),1.6),.0)*3.0;")
WriteLine(file,"float f63 = max(0.01-pow(length(uvx-0.35*pos),1.6),.0)*5.0;")
WriteLine(file,"vec3 c = vec3(.0);")
WriteLine(file,"c.r+=f2+f4+f5+f6; c.g+=f22+f42+f52+f62; c.b+=f23+f43+f53+f63;")
WriteLine(file,"c+=vec3(f0);")
WriteLine(file,"return c;")
WriteLine(file,"}")
WriteLine(file,"vec3 cc(vec3 color, float factor,float factor2) // color modifier")
WriteLine(file,"{")
WriteLine(file,"float w = color.x+color.y+color.z;")
WriteLine(file,"return mix(color,vec3(w)*factor,w*factor2);")
WriteLine(file,"}")
WriteLine(file,"void main( )")
WriteLine(file,"{")
WriteLine(file,"vec2 uv = uvVarying*2.0;")
WriteLine(file,"uv.x = uv.x - 1.0;")
WriteLine(file,"uv.y = uv.y - 1.0;")
WriteLine(file,"vec3 color = vec3(1.4,1.2,1.0)*lensflare(uv,(vec2((Position.xy/agk_resolution)*2.0)-1.0));")
WriteLine(file,"color = cc(color,.5,.1);")
WriteLine(file,"gl_FragColor = vec4(color,2.0);")
//added an additive colour blend
WriteLine(file,"gl_FragColor = texture2D(texture0, uvVarying) + gl_FragColor;")
//change for a subtractive colour blend
//WriteLine(file,"gl_FragColor = texture2D(texture0, uvVarying) - gl_FragColor;")
//change for a multiply color blend
//WriteLine(file,"gl_FragColor = texture2D(texture0, uvVarying) * gl_FragColor;")
WriteLine(file,"}")
CloseFile(file)
endfunction
2D Lightning Shader Its not forked but it is positionable
// Project: lightning
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "lightning" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
createShaderFile()
CreateSprite(1,0)
SetSpriteSize(1,1024,768)
LoadSpriteShader(2, "lightning.ps")
SetSpriteShader( 1,2 )
//changing the resolution x will effect where the lightning casts from
//so with a sprite 1024 wide resolution setting to 1024 will set it in
//the middle of the sprite while setting to 2048 for example shifts it
//to the right
SetShaderConstantByName(2,"resolution",1024,768,0,0)
do
SetShaderConstantByName(2,"resolution",GetPointerX()*2,768,0,0)
SetShaderConstantByName(2,"time",timer()*.25,0,0,0)
Print( ScreenFPS() )
Sync()
loop
function createShaderFile()
fw=OpenToWrite("lightning.ps")
WriteLine(fw,"precision lowp float;")
WriteLine(fw,"uniform float time;")
WriteLine(fw,"uniform vec2 resolution;")
WriteLine(fw,"const float count = 2.0;")
WriteLine(fw,"float Hash( vec2 p, in float s ){")
WriteLine(fw," return fract(sin(dot(vec3(p.xy,15.0 * abs(sin(s))),vec3(27.1,61.7, 12.4)))*273758.5453123);")
WriteLine(fw,"}")
WriteLine(fw,"float noise(in vec2 p, in float s)")
WriteLine(fw,"{")
WriteLine(fw," vec2 i = floor(p);")
WriteLine(fw," vec2 f = fract(p);")
WriteLine(fw," f *= f * (3.0-2.0*f);")
WriteLine(fw," return mix(mix(Hash(i + vec2(0.,0.), s), Hash(i + vec2(1.,0.), s),f.x),mix(Hash(i + vec2(0.,1.), s), Hash(i + vec2(1.,1.), s),f.x),f.y) * s;")
WriteLine(fw,"}")
WriteLine(fw,"float fbm(vec2 p)")
WriteLine(fw,"{")
WriteLine(fw," float v = 0.0;")
WriteLine(fw," v += noise(p*6., 0.35);")
WriteLine(fw," v += noise(p*2., 0.25);")
WriteLine(fw," v += noise(p*4., 0.125);")
WriteLine(fw," v += noise(p*16., 0.0625);")
WriteLine(fw," return v;")
WriteLine(fw,"}")
WriteLine(fw,"void main( void ) ")
WriteLine(fw,"{")
WriteLine(fw," vec2 location= ( gl_FragCoord.xy / resolution.xy ) * 2.0 - 1.0;")
WriteLine(fw," location.x*= resolution.x/resolution.y;")
WriteLine(fw," vec3 finalColor = vec3( 0.0 );")
WriteLine(fw," float t = abs(1.0 / ((location.x + fbm( location + time * 5.0)) * (50.0)));")
WriteLine(fw," finalColor += t * vec3( 0.375 +0.1, 0.5, 2.0 );")
WriteLine(fw," gl_FragColor = vec4( finalColor, 3.0 );")
WriteLine(fw,"}")
CloseFile(fw)
endfunction
fubar