Posted: 7th May 2014 08:43
//-----------------Vert.vs----------------------------
attribute vec4 in_Position;
attribute vec2 in_TextureCoord;
uniform mat4 agk_WorldViewProj;
varying vec2 v_texcoord;
void main()
{
gl_Position = agk_WorldViewProj * in_Position; //vec4(in_Position, 1.0);
v_texcoord = in_TextureCoord;
}
//-----------------Vert.vs----------------------------
//-----------------Pixel.vs---------------------------
varying vec2 v_texcoord;
uniform sampler2D texture0;
uniform float time;
uniform vec2 mouse_pos;
uniform vec2 resolution;
uniform float shock_amplitude;
uniform float shock_refraction;
uniform float shock_width;
void main()
{
vec2 uv = v_texcoord;
uv.x *= (resolution.x/resolution.y);
vec2 texCoord = v_texcoord;
float centre_x = (mouse_pos.x / resolution.x) * (resolution.x/resolution.y);
float centre_y = mouse_pos.y / resolution.y;
float dist = distance(uv, vec2(centre_x,centre_y));
if ( (dist <= (time + shock_width)) && (dist >= (time - shock_width)) )
{
float dif = (dist - time);
float powDiff = 1.0 - pow(abs(dif*shock_amplitude),shock_refraction);
float diffTime = dif * powDiff;
vec2 diffUV = normalize(uv - mouse_pos);
texCoord = uv + (diffUV * diffTime);
texCoord.x *= (resolution.y/resolution.x);
}
gl_FragColor = texture2D(texture0, texCoord);
}
//-----------------Pixel.vs---------------------------
//-----------------AGK--------------------------------
setDisplayAspect(1.0)
setvirtualresolution(640,480)
setSyncRate(60, 0)
global myShader = 1
LoadShader(1,"Vert.vs","pixel.ps")
//SetGlobal3DDepth( 100 )
createsprite(1, loadImage("Back.png"))
createsprite(2, loadImage("Back.png"))
setSpriteShader(2,1)
do
print(x#)
print(y#)
if GetRawMouseLeftReleased() =1
tim#=timer() + 50
x# = getrawmousex()
y# = getrawmousey()
Enabled=1
endif
if timer() > tim#
Enabled = 0
var_time_var#=0
endif
if Enabled=1
var_time_var# = var_time_var# + 0.04
endif
SetShaderConstantByName(1,"time" ,var_time_var#,0.0,0.0,0.0);
SetShaderConstantByName(1,"mouse_pos" , x#, y#,0.0,0.0);
SetShaderConstantByName(1,"resolution" , 640.0, 480.0,0.0,0.0);
SetShaderConstantByName(1,"shock_amplitude" , 10.0,0.0,0.0,0.0);
SetShaderConstantByName(1,"shock_refraction", 0.80,0.0,0.0,0.0 );
SetShaderConstantByName(1,"shock_width" , 0.10,0.0,0.0,0.0);
sync()
loop
//-----------------AGK--------------------------------