Custom UV render pass?

Hello. I am currently writing a piece of software that requires pre-rendered UV maps for quick texture mapping. I have tried using the default UV maps that blender renders.

[ATTACH=CONFIG]410041[/ATTACH]
But the amount of information stored in the color channels is not enough. When I use a shader to map a texture onto this image it comes out pixelated. I believe this happens because the individual color channels can only store 256 values, so using a texture that is bigger than 256x256 is impossible.

I have tried increasing the color depth of the rendered image to increase the number of UV values, but I do not possess the knowledge to make a shader that would be able to use such a map.

I have come across a UV map that uses all four colour channels.



The integer parts of the x and y coordinates are stored in the R and B channels, and the fraction parts are stored in the G and A channels.

My question would be, is it possible to somehow have blender output this type of UV map?

You transform the 256 values (0-255) to 0.0-1.0 range for UV coordinates, do you not? Use higher bit precision, 16- or 32 bits per channel and it gives you accurate coordinates. Use a suitable library to read the raster format, OpenEXRfor example has both source code and precompiled binaries available.

And how is bit depth related to UV map resolution? You write that you are restricted to size 256x256…

If your UV-pass can only contain values 0-255, there’s no point in using textures larger than 256 because the extra pixels just pile on top of each other. There is not enough precision to put, say, pixels 1023 and 1024, into their proper locations.

I tried using higher bit precision, but I had problems converting those values back into coordinates in the actual shader.

Anyway I figured out how to seperate the integer and fraction parts of the UV map into different channels by using compositing nodes.