OK I tested Janbo's updates. The first shader code runs fine but I am not sure what is the difference to the previous one. The seconds one with the for loop gave me an error about arrays not being supported when the pixel shader is compiled. So I tried to unroll the loop and use two ripples. It looks a bit odd, with the whole image flickering. I do see what seems like multiple ripples there but can't say too well with the flickering.
Here is what I tried:
main.agc:
// Project: shockwave
// Created: 2017-08-17
SetWindowTitle( "test" )
SetWindowSize( 1024, 768, 0 )
// set display properties
SetVirtualResolution( 1024, 768 )
SetOrientationAllowed( 1, 1, 1, 1 )
SetPrintColor(0,0,0)
imgId1=loadimage("noscanline.png")
sid1=createsprite(imgId1)
SetSpritePosition(sid1, 0, 0)
imgId2=loadimage("noscanline.png")
sid2=createsprite(imgId2)
x = GetSpriteX(sid1) + GetSpriteWidth(sid1)
y = GetSpriteY(sid1)
w = GetSpriteWidth(sid1)
h = GetSpriteHeight(sid1)
SetSpritePosition(sid2, x, y)
SetSpriteSize(sid2, w/2, h/2)
imgId3=loadimage("noscanline.png")
sid3=createsprite(imgId3)
x = x
y = y + GetSpriteHeight(sid2)
SetSpritePosition(sid3, x, y)
SetSpriteSize(sid3, w/2, h/2)
//ShaderID=LoadSpriteShader("pixel.ps" )
ShaderID=LoadFullScreenShader("pixel3.ps")
setShaderConstantByName(ShaderID, "center",0.5,0.5,0.1,0)
setShaderConstantByName(ShaderID, "shockParams",10.0, 0.8, 0.05,0 )
// create quad object
renderImage = CreateRenderImage(1024, 768, 0, 0)
quad = CreateObjectQuad()
SetObjectShader(quad, ShaderID)
do
// render to the render image
SetRenderToImage(renderImage, -1)
ClearScreen()
Update(GetFrameTime())
Render2DBack()
Render2DFront()
SetObjectImage(quad, renderImage, 0)
// render to the screen
SetRenderToScreen()
ClearScreen()
DrawObject(quad)
Swap()
if getpointerpressed()=1
setShaderConstantByName(ShaderID, "center1", GetPointerX()/1024,GetPointerY()/768,0,0)
setShaderConstantByName(ShaderID, "center2", GetPointerX()/1024,GetPointerY()/768,0,0)
Time#=0.0
endif
Time#=Time#+1.5*getframetime()
setShaderConstantByName(ShaderID, "time1",Time#,0,0,0)
setShaderConstantByName(ShaderID, "time2",Time#*2,0,0,0)
Print( ScreenFPS() )
print(Time#)
Sync()
loop
pixel3.ps
uniform sampler2D texture0;
varying vec2 uvVarying;
uniform vec2 center1; // Mouse position
uniform vec2 center2; // Mouse position
uniform float time1; // effect elapsed time
uniform float time2; // effect elapsed time
uniform vec3 shockParams; // 10.0, 0.8, 0.1
void main()
{
vec4 finalColor = texture2D(texture0, uvVarying);
vec2 texCoord = uvVarying;
float dist = distance(uvVarying, center1);
if ((dist >= (time1 - shockParams.z)) && (dist <= (time1 + shockParams.z)))
{
float diff = (dist - time1);
float powDiff = 1.0 - pow(abs(diff*shockParams.x), shockParams.y);
float diffTime = diff * powDiff;
vec2 diffUV = normalize(uvVarying- center1);
texCoord = uvVarying+ (diffUV * diffTime);
}
finalColor *= texture2D(texture0, texCoord);
texCoord = uvVarying;
dist = distance(uvVarying, center2);
if ((dist >= (time2 - shockParams.z)) && (dist <= (time2 + shockParams.z)))
{
float diff = (dist - time2);
float powDiff = 1.0 - pow(abs(diff*shockParams.x), shockParams.y);
float diffTime = diff * powDiff;
vec2 diffUV = normalize(uvVarying- center2);
texCoord = uvVarying+ (diffUV * diffTime);
}
finalColor *= texture2D(texture0, texCoord);
gl_FragColor = finalColor;
}
BTW, the "noscanline.png" image I use here is just downloaded from backslash's post I linked above..