Hi.
I believe the plan is to add per-vertex colors or userdata, though I forget where it’s been mentioned.
Actually, if you don’t need an image, here’s something I showed Vlad a while back that hijacks the texture coordinates:
local rect = display.newRect(0, 0, 200, 200) local mesh = display.newMesh{ x = 100, y = 100, mode = "indexed", vertices = { 0, 0, 0, 100, 50, 0, 100, 100, 100, 0 }, indices = { 1, 2, 3, 2, 3, 4, 3, 4, 5 } } mesh:translate( mesh.path:getVertexOffset() ) rect:translate(mesh.x, mesh.y) rect:setFillColor(1, 0, 1) -- some background for some alpha tests -- Kernel -- local kernel = { category = "generator", name = "corner\_colors" } kernel.vertex = [[P\_DEFAULT vec2 TenBitsPair (P\_DEFAULT float xy) { P\_DEFAULT float axy = abs(xy); P\_DEFAULT float bin = floor(log2(axy)); P\_DEFAULT float num = exp2(16. - bin) \* axy - 65536.; P\_DEFAULT float rest = floor(num / 1024.); P\_DEFAULT float y = num - rest \* 1024.; P\_DEFAULT float y\_bias = step(0., -xy); return vec2(bin \* 64. + rest, y + y\_bias); } P\_DEFAULT vec2 UnitPair (P\_DEFAULT float xy) { return TenBitsPair(xy) / 1024.; } varying P\_COLOR vec4 v\_RGBA; P\_POSITION vec2 VertexKernel (P\_POSITION vec2 pos) { v\_RGBA.rg = UnitPair(CoronaTexCoord.x); v\_RGBA.ba = UnitPair(CoronaTexCoord.y); return pos; }]] kernel.fragment = [[varying P\_COLOR vec4 v\_RGBA; P\_COLOR vec4 FragmentKernel (P\_UV vec2 uv) { return v\_RGBA; }]] graphics.defineEffect(kernel) mesh.fill.effect = "generator.custom.corner\_colors" -- local assert = assert local floor = math.floor local function EncodeTenBitsPair (x, y) assert(x \>= 0 and x \<= 1024, "Invalid x") assert(y \>= 0 and y \<= 1024, "Invalid y") x, y = floor(x + .5), floor(y + .5) local signed = y == 1024 if signed then y = 1023 end local xhi = floor(x / 64) local xlo = x - xhi \* 64 local xy = (1 + (xlo \* 1024 + y) \* 2^-16) \* 2^xhi return signed and -xy or xy end local function Encode (x, y) return EncodeTenBitsPair(x \* 1024, y \* 1024) end local function SetColor (index, r, g, b, a) mesh.path:setUV(index, Encode(r, g), Encode(b, a)) end SetColor(1, 0, 0, 1, 1) -- upper-left SetColor(2, 1, 0, 0, 1) -- lower-left SetColor(3, 0, 1, 1, 1) -- upper-center SetColor(4, 0, 0, 1, 1) -- lower-right SetColor(5, 0, 1, 0, 1) -- upper-right --[[timer.performWithDelay(300, function() local index = math.random(5) SetColor(index, math.random(), math.random(), math.random(), 1) end, 0) --]]
This might be occasionally useful. I was thinking, for instance, of trying to port this on some weekend.
This does some stuff with IEEE float representation, so I would actually be curious if it runs aground on any of your Android devices (or anywhere else, of course).