} = 0.5f; // 0-1, default 0.5 // this defines the tiling public virtual int GetLumaTileIndexOfPixelPosInCell(int x, int y, Size cellSize) { vec2 posInCell01 = vec2.Init(x, y) .add(.5f)// center in the pixel .dividedBy(cellSize); vec2 skewAmt = posInCell01.minus(.5f).multipliedBy(this.Rotation); skewAmt.y = -skewAmt.y; vec2 tile = posInCell01.add(skewAmt.yx());// which tile are we in (x=0,1, y=0,1) ivec2 itile = tile.step(.5f); int tileIdx = itile.x + itile.y * 2; posInCell01 = posInCell01.minus(.5f).abs(); float m = posInCell01.x + posInCell01.y; if (m < 1.0 / 3.0) { tileIdx = 4;// arbitrary number that looks good perceptually. } return(tileIdx); }