thomas6

StarCrunch

[GLOBAL: userInfoPane.html]

StarCrunch

Contributor

787 posts

Corona SDK

28 September 2015 - 10:25 AM

To add to Caleb's excellent summary, the difference in my technique for packing two values is that it encodes an integer[1] using exactly representable floating point values (refer to some of those links I mention above), then decodes them on the shader side accordingly.

Unfortunately, I'm stuck with what GLES 2.0 gives me, so I'm still unsure whether I have an exact decoding or just a good approximation; thus the mention of a test. I'm at least heartened that it no longer wildly freaks out on some values. (To give an analogy, think about trying different identities for, say, 1 - cos(x). Mathematically they're all equal, but in real-world computing, some might give more accurate / stable results than others. In this case I'm aiming for an equation that is 100% exact.)

[1] - Up to 20 bits, so for example two integers from 0 to 1023, but able to just sneak in 1024 as well on a lowest-common-denominator device. Often these will only temporarily be integers, e.g. having undergone a math.floor(x * 1024) transformation, which will be undone once in the shader.

davebollinger

[GLOBAL: userInfoPane.html]

davebollinger

Corona Geek

1,304 posts

Enterprise

16 October 2015 - 06:58 AM

Width of the layer in pixels, height of the layer in pixels (because GLSL sends coordinates in the range of [0,1]), tileset width in tiles, tileset height in tiles, width of each tile in pixels, height of each tile in pixels, and, preferably, margin and spacing of the tileset. That makes at least 6 inputs required, and ideally 8.

If you were willing to trade-off flexibility, might you require that the tileset scheme be one of a few supported configurations, then just pass a single number to describe it? (getting a 4-for-1 deal, otherwise you'd fall back to conventional tile rendering for "atypical" tileset schemes)

Caleb P

[GLOBAL: userInfoPane.html]

Caleb P

Corona Geek

1,424 posts

Corona SDK

17 October 2015 - 04:01 AM

Hm. Interesting idea. I'll think through it. Maybe a better way would be to encode only certain values as presets. That is, the layer width and height could be normal numbers, but the tile size could be presets, 'cause they're usually 16x16/32x32/64x64. Or, alternatively, I could assume people use square tiles and store tile size in one variable. Good stuff to think about; thanks for bringing this approach up.