Texture coordinates

Hey guys
i’m here to get a little help from shader experts
do you think i messed up this code? cause it’s giving me something like “colour sample patch” as output instead of shader output!
i mean this is a really simple and short code but why is this happening? something wrong with the coordinates? a difference between spark and shadertoy corrdinate system maybe?
ezgif.com-gif-maker

precision highp float;

vec4 F (vec2 U, std::Texture2d iChannel1)
{
    vec2 R = std::getRenderTargetSize();
         U = fragment(floor(std::getRenderTargetSize() * std::getVertexTexCoord()));
    return iChannel1.sample(U/R.xy);
}
float ln (vec2 p, vec2 a, vec2 b)
{
    return length(p-a-(b-a)*clamp(dot(p-a,b-a)/dot(b-a,b-a),0.,1.));
}
vec4 T (vec2 U, std::Texture2d iChannel0, std::Texture2d iChannel1)
{
    vec2 R = std::getRenderTargetSize();
         U = fragment(floor(std::getRenderTargetSize() * std::getVertexTexCoord()));
    U -= F(U, iChannel1).xy;
    U -= F(U, iChannel1).xy;
    return iChannel0.sample(U/R.xy);
}
void mainImage( in float iFrame, in std::Texture2d iChannel0, in std::Texture2d iChannel1, out vec4 Q )
{
    vec2 R = std::getRenderTargetSize();
    vec2 U = fragment(floor(std::getRenderTargetSize() * std::getVertexTexCoord()));

    Q = 0.25 *
             (T(U + vec2(1.0, 0.0), iChannel0, iChannel1) +
              T(U - vec2(1.0, 0.0), iChannel0, iChannel1) +
              T(U + vec2(0.0, 1.0), iChannel0, iChannel1) +
              T(U - vec2(0.0, 1.0), iChannel0, iChannel1));
    
    if (U.x<2.||U.y<2.||R.x-U.x<2.||R.y-U.y<2.||iFrame < 1.0)
    Q = vec4(U, 0.0, 0.0);
}

Can you link to the shadertoy?

it was a while ago and i lost the shadertoy link :frowning:

I’m not sure what the channel outputs are supposed to be, or what the output is supposed to look like, but I’m getting a camera texture with a little yellow border.

test-shader.arprojpkg (21.2 KB)

actually it is supposed to be a water simulation filter but first buffer shows the “colour sample” like thing and rest of the shaders show nothing
i can only think of wrong or messed up coordinates but everything is correct.
here is the complete code.
project file

I’m not sure where the problem is. The mouse position color sampler buffer wasn’t even working in that project you uploaded. I simplified the code a bit (not sure what that T function is doing, seems redundant). The main issue in that buffer was that the iMouse value was in pixels and it was being used to sample from a texture (which should be sampled in normalized coordinates)

If that’s the case, maybe the same thing is happening elsewhere in the code.

precision highp float;

// mouse

float ln (vec2 p, vec2 a, vec2 b)
{
    return length(p-a-(b-a)*clamp(dot(p-a,b-a)/dot(b-a,b-a),0.,1.));
}
void mainImage( in vec4 iMouse, in std::Texture2d BufferC, out vec4 C )
{
    vec2 R = std::getRenderTargetSize();
    vec2 U = fragment(std::getVertexTexCoord());

    vec4 M = iMouse;
    M.xy /= R;
    vec4 p = BufferC.sample(U);
    if (M.z>0.)
    {
        if (p.z>0.)
        C =  vec4(M.xy, p.xy);
        else
        C =  vec4(M.xy, M.xy);
    }
    else C = vec4(-R.xy, -R.xy);
}