You need to add "uv1Varying = uv * uvBounds1.xy + uvBounds1.zw;"
Like so:
blend.vs+ Code Snippetattribute vec3 position;
attribute vec2 uv;
varying vec2 uv0Varying;
varying vec2 uv1Varying;
uniform vec4 uvBounds0;
uniform vec4 uvBounds1;
uniform mat4 agk_World;
uniform mat4 agk_ViewProj;
void main()
{
vec4 pos = agk_World * vec4(position,1);
gl_Position = agk_ViewProj * pos;
uv0Varying = uv * uvBounds0.xy + uvBounds0.zw;
uv1Varying = uv * uvBounds1.xy + uvBounds1.zw;
}
blend.ps+ Code Snippet// constant values sent through from AGK code.
uniform sampler2D texture0;
uniform sampler2D texture1;
// Anything that the vertex shader passes as output needs to
// be defined here as input. The vertex shader is passing the
// texture coordinate, so it is defined again here.
varying vec2 uv0Varying;
varying vec2 uv1Varying;
void main()
{
vec4 colorResult0 = texture2D(texture0, uv0Varying);
vec4 colorResult1 = texture2D(texture1, uv1Varying); // you can change here the second uvlayer by texture2D(texture1, texCoord1) if you use different uvchanel for each texture
gl_FragColor = mix(colorResult0, colorResult1, colorResult1.a); // mix with the alpha of the second texture. You can mix with a third texture if you want to use seamless texture and repeat it.
}
AGK Code (play with uvscale and uvoffset in stage 1)
+ Code Snippet// create a sphere to see the texture
CreateObjectBox(1,20,20,20)
// position and orientate the camera
SetCameraPosition(1,0,100,-200)
SetCameraLookAt(1,0,0,0,0)
SetGenerateMipmaps(1)
LoadImage(1,"texture0.jpg") // no need for alpha with this one
LoadImage(2,"texture1.png") // with alpha ;)
CreatePointLight(1,-5,5,5,500,200,200,200)
// initial rotation values
angle_x# = 0.0
// main loop
SetObjectRotation(1,-60,-60,0.0)
SetObjectScale(1,4,2,2)
LoadShader(3, "blend.vs", "blend.ps")
SetObjectShader(1,3)
SetObjectImage(1,1,0)
SetObjectImage(1,2,1)
SetObjectUVScale(1,1,2.0,2.0)
SetObjectUVOffset(1,1,-0.25,-0.25)
do
angle_x# = angle_x# + 1
SetObjectRotation(1,0, angle_x#,0.0)
sync()
loop