I want to know how to pass an array of data (it will be an encoded map, actually) to the fragment shader so I can query it as an array.

AFAIK this is sadly not implemented in unity, so I'm looking for a nice workaround.

I've thought on using a texture but I don't really know how to query the data without running into precision errors (i.e. query a single texture pixel as if it were an array). It is actually really important that it never fails because of precision, and I rather not rely on the internal floating point implementation.

  • \$\begingroup\$ As far as I know rectangle samplers uses non-normalized UVs, meaning you enter UVs in texel coordinates if that is what are you looking for. \$\endgroup\$
    – wondra
    Commented Aug 10, 2014 at 11:36
  • \$\begingroup\$ What do you mean by rectangle sampler? The only thing I really know is the sampler2d and that uses coordinates from 0.0 to 1.0 (in float). How would I go into using a rectangle sampler? \$\endgroup\$
    – Setzer22
    Commented Aug 10, 2014 at 15:28
  • \$\begingroup\$ There are many kinds of samplers, check official site \$\endgroup\$
    – wondra
    Commented Aug 10, 2014 at 16:13
  • \$\begingroup\$ Ok, so it appears that I need to use an isampler2d instead of a normal sampler2d. I assumed I could just replace the type and it would work out of the box, but it doesn't seem to work under unity :S \$\endgroup\$
    – Setzer22
    Commented Aug 10, 2014 at 16:32
  • \$\begingroup\$ To be honest, I never implemented this (so I might be wrong). As I understand it, one need to create rectangle texture and sample it with rectangle sampler - the prefix is only sampler in/output type. (float vec vs int vec) \$\endgroup\$
    – wondra
    Commented Aug 10, 2014 at 17:06


You must log in to answer this question.

Browse other questions tagged .