Original Post
I've spent the last few days writing a texture pre-processor that adds (static) lighting to meshes. It looks quite good, but there are a few issues at the moment. Part of the process is to produce a 'position map' of the mesh, where the 3D location that each point on a texture corresponds to is encoded in the red, green and blue colour components. For example, here is a position map of a cube mesh I made:
The problem I was having is that 8 bits per direction isn't accurate enough for my purposes. So I've created textures with 16 bits per colour channel instead (D3DFMT_A16B16G16R16). I then set this as the render target, render coloured triangles as before, copy it to a system memory surface of the same format, lock it, read the bytes and ... the data is in A8R8G8B8 format. Argh! Why is this happening? How do I render to 16 bits per channel texture formats correctly? There's quite a lot of code, but if you want to see any particular bits then please ask.
The problem I was having is that 8 bits per direction isn't accurate enough for my purposes. So I've created textures with 16 bits per colour channel instead (D3DFMT_A16B16G16R16). I then set this as the render target, render coloured triangles as before, copy it to a system memory surface of the same format, lock it, read the bytes and ... the data is in A8R8G8B8 format. Argh! Why is this happening? How do I render to 16 bits per channel texture formats correctly? There's quite a lot of code, but if you want to see any particular bits then please ask.