agk_resolution is the resolution of the render target whether its an image you render to or the screen buffer.
But actually, you don't want to replace
iResolution you want to remove it entirely.
If you then replaced
gl_FragCoord with
uvVarying you need to pass it from the vertex shader to the fragment shader.
Actually it's not necessary to replace something at all, you could make it work with some magic calculations maybe even hard code it into the shader,
but you want to, because you don't want to pass so many uniforms to the shader and maybe even use the build in commands to alter some uniforms.
And thats why you want to pass
uvVarying = uv * uvBounds0.xy + uvBounds0.zw; from the Vertex shader to the Fragment shader.
uvBounds0 is a uniform and is passed from AppGameKit to the "shader set" using
SetObjectUVScale and
SetObjectUVOffset.
uvBounds0.xy=SetObjectUVScale (you want to alter this)
uvBounds0.zw=SetObjectUVOffset
Not testet Code
VertexShader:
attribute vec3 position;
attribute vec2 uv; // NEW
varying vec2 uvVarying; // NEW
uniform mat4 agk_WorldViewProj;
uniform vec4 uvBounds0; //NEW
void main()
{
uvVarying = uv * uvBounds0.xy + uvBounds0.zw; //NEW
gl_Position = agk_WorldViewProj * vec4(position, 1);
}
FragmentShader:
varying vec2 uvVarying; //NEW
uniform float agk_time; //NEW
float hash( float n ) { return fract(sin(n)*753.5453123); }
float noise( in vec3 x )
{
vec3 p = floor(x);
vec3 f = fract(x);
f = f*f*(3.0-2.0*f);
float n = p.x + p.y*157.0 + 113.0*p.z;
return mix(mix(mix( hash(n+ 0.0), hash(n+ 1.0),f.x),
mix( hash(n+157.0), hash(n+158.0),f.x),f.y),
mix(mix( hash(n+113.0), hash(n+114.0),f.x),
mix( hash(n+270.0), hash(n+271.0),f.x),f.y),f.z);
}
float n ( vec3 x ) {
float s = noise(x);
for (float i = 2.; i < 10.; i++) {
s += noise(x/i)/i;
}
return s;
}
void main(void)
{
vec2 uv = uvVarying; //NEW
float a = abs(n(vec3(uv+agk_time*3.14,sin(agk_time)))-n(vec3(uv,cos(agk_time+3.))));
float alp=pow(a, .3);
gl_FragColor = vec4(0,0, 1.0, 1.0-(alp*2.));
}