Floor/Modulo function in Spark SL

Hey there, I’ve run into a problem with a (seemingly) simple shader for Meta Spark. I built this a while back in the patch editor and wanted to convert to a shader asset for practice. The intended effect is to split the cameraTexture into a 2x2 grid, so we multiply the uv position by 2, take the remainder with modulo and sample the texture there…

The same logic works fine in the patch editor but when run through this the final samplePosition is always (0,0). I have a manual modulo commented out which yielded the same results. Seems as though floor() isn’t changing the samplePos which results in the 0.

Additionally, when the mod() lines are commented out, the texture is sampled as expected, which makes me think I’m really just missing something with the mod/floor commands… Any help would be greatly appreciated!

SOLVED: I needed to add ‘vec2 frag = fragment(uv);’ after getting the uv. We are trying to operate on specific pixels so we need to use this in the fragment shader. Silly me. Post will be marked solved.

void mainImage(in std::Texture2d myTex, out vec4 fragColor) 
  //uv values are 0-1
  vec2 uv = std::getVertexTexCoord();

  //multiply by 2 and drop whole number (return to 0-1 range)
  float samplePosX = uv.x * 2.0;
  samplePosX = mod(samplePosX, 1.0);

  float samplePosY = uv.y * 2.0;
  samplePosY = mod(samplePosY, 1.0);

  //manual modulo! floor(samplePos) does nothing (?), end value still always = 0
  // float samplePosX = uvX * 2.0;
  // samplePosX = samplePosX - floor(samplePosX);
  // float samplePosY = uvY * 2.0;
  // samplePosY = samplePosY - floor(samplePosY);

  //new samplePos using new X and Y values
  vec2 newSamplePos = vec2(samplePosX, samplePosY);

  //sample color at new position
  vec4 col = myTex.sample(newSamplePos);

  //always ends up with color sampled from (0,0)
  fragColor = col;