Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question
    
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. –  wondra Aug 10 at 11:36
    
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? –  Setzer22 Aug 10 at 15:28
    
There are many kinds of samplers, check official site –  wondra Aug 10 at 16:13
    
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 –  Setzer22 Aug 10 at 16:32
    
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) –  wondra Aug 10 at 17:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.