Good way of getting floats into a shader

Hi

lately i’ve had quite a lot ideas of things i could do with shaders. But a lot of them have one issue: I’d need 32 bit floats as input. As far as i know, you can only use vectors for that which would be limited to 4 values. So i thought “shouldn’t be that hard to get them packed into the color channels of a texture and decode them on the GPU”. Turns out it is.
Sadly it looks like Unity doesn’t support the IntBitsToFloat function (or an older cg library, which doesn’t include it), so this doesn’t work. Another way i thought of was simply doing the whole decoding process myself, but due to the lack of bit access in shaders, this would result in way to many instructions (Edit: Just realised, i could get away with a lot less instructions than i originally thought. But still too many of them). Last one was simply storing a single float in two pixels instead of just one. Tough it’s an easy and quick way, two lookups for one value doesn’t seem reasonable to me and might be even slower than the instruction heavy way.

So my question is, does anyone have any good ways to do this without wasting an absurd amount of instructions or texture lookups on getting a single float value?

Thanks
Chicken

As far as I know, you don’t need a float property but just a float uniform, which you can set with Material.SetFloat :

If you can get away with encoding 0 to 1 then there are functions in UnityCG.cginc to do this for you e.g. EncodeFloatRGBA.
Otherwise yeah its very hard.
I’m currently moving floating point data via mesh uv’s, but obviously thats not always suitable.

@MartinKraus
Yeah i know, but i dont need just one float but probably at least a few hundreds (maybe even thousands) :smile: So basically a usual texture where each pixel represents a float value instead of colors.

@Noisecrime
I now about it. But again, i need full 32bit floats with a precision at least close to the IEEE 754 standard. As said, i know a few ways to get them, but they would end up beeing slower than cpu computation (and thats obviously not worth the mess).