MitchellKehn
6/24/2018 - 12:43 AM

Blinkscript ST Map

A working Blinkscript kernel that performs as an ST map, uses bilinear subsampling. This isn't super useful on its own, but could be handy when working on the 2D camera projection tool.

kernel STMap : ImageComputationKernel <ePixelWise>
{

  Image <eRead, eAccessRandom, eEdgeClamped> src;
  Image <eRead, eAccessPoint> st_map;
  Image <eWrite> dst;

  local:
    int width;
    int height;

  void init() {
    width = src.bounds.x2;
    height = src.bounds.y2;
  }

  void process(int2 pos) {
    int2 uv = int2(st_map(0) * width, st_map(1) * height);
    dst() = src(uv.x, uv.y);
  }

};