|
Re: How to get 16it floats out of a bmap... pixel_for_vec dont work!
[Re: EvilSOB]
#384620
10/05/11 12:46
10/05/11 12:46
|
Joined: May 2005
Posts: 2,713 Lübeck
Slin
Expert
|
Expert
Joined: May 2005
Posts: 2,713
Lübeck
|
dds is just a container format which can store all kind of texture data, compressed and uncompressed and so on. So this really depends on how you save it. But I guess that there is no basic format for compressed 16bit fp textures, because of that I´d assume that your texture is uncompressed. On bmap_lock, what format is returned? Edit: Also, you should probably go with 32bit instead of 16, as otherwize things get quite tricky, because there is no corresponding datatype. Something like this could then work:
#include <d3d9.h>
/* DX Lock flags */
#define D3DLOCK_READONLY 0x00000010L
#define D3DLOCK_DISCARD 0x00002000L
#define D3DLOCK_NOOVERWRITE 0x00001000L
#define D3DLOCK_NOSYSLOCK 0x00000800L
#define D3DLOCK_DONOTWAIT 0x00004000L
#define D3DLOCK_NO_DIRTY_UPDATE 0x00008000L
void ReadPixels(float **pixels, BMAP* rbmap)
{
LPDIRECT3DTEXTURE9 dxtex = rbmap->d3dtex;
D3DLOCKED_RECT dxrect;
unsigned char *bmp;
bmap_preload(rbmap);
dxtex->LockRect(0, &dxrect, NULL, D3DLOCK_READONLY);
bmp = dxrect.pBits;
var width = bmap_width(rbmap);
var height = bmap_height(rbmap);
*pixels = sys_malloc(width*height*sizeof(float));
var x, y;
for(y = 0; y < height; y++)
{
memcpy(pixels[y*width], bmp[y*dxrect.Pitch], sizeof(float*width));
}
dxtex->UnlockRect(0);
}
Last edited by Slin; 10/05/11 13:11.
|
|
|
Re: How to get 16it floats out of a bmap... pixel_for_vec dont work!
[Re: Slin]
#384636
10/05/11 15:56
10/05/11 15:56
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
OP
Expert
|
OP
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Compile error dude ...pBits is not a member of "VOID"
Im digging for it now, but no luck so far...
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: How to get 16it floats out of a bmap... pixel_for_vec dont work!
[Re: EvilSOB]
#385301
10/16/11 02:56
10/16/11 02:56
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
OP
Expert
|
OP
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Klaatu ... Verada ... Nictu !!! Thread Resurrection time!
OK, Ive finally gotten to the pixel data via the BMAP.finalbits pointer. Luckily the data is actually uncompressed. Purely by luck.
BUT, Im able to pull the RAW 16-bit floats out of the DX-data, but am having a lot of difficulty converting them to 32-bit lite-c floats. (my pointer maths is still severely rusty still...)
So, any suggestions on how to convert these 16bit floats to 32bit floats? And / or ultimately to lite-c (scaled?) 'long's or 'short's?
Thanks again guys.
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: How to get 16it floats out of a bmap... pixel_for_vec dont work!
[Re: EvilSOB]
#385309
10/16/11 13:30
10/16/11 13:30
|
Joined: Oct 2004
Posts: 900 Lgh
rojart
User
|
User
Joined: Oct 2004
Posts: 900
Lgh
|
...So, any suggestions on how to convert these 16bit floats to 32bit floats?... Use D3DXFloat16To32Array and consult the SDK help for more details.
|
|
|
Re: How to get 16it floats out of a bmap... pixel_for_vec dont work!
[Re: rojart]
#385314
10/16/11 14:00
10/16/11 14:00
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
OP
Expert
|
OP
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Been there, tried that, and failed...
Looks to be another obscure D3D function that conitec didnt bother to fully implement in their d3d9.h header.
And I dont know D3D well enough to perform a manual override on it. Tried and failed...
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: How to get 16it floats out of a bmap... pixel_for_vec dont work!
[Re: EvilSOB]
#385348
10/17/11 05:24
10/17/11 05:24
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
OP
Expert
|
OP
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Ive finally come up with my own converter. Here it is in case anyone else is interested...
//-----------------------------------------------
// Convert (D3D) float16 to (acknex) float32
//-----------------------------------------------
float float16to32(short num)
{ long z = (num & 0x8000) <<16;
z = z | (((num & 0x7C00) >>10 ) +0x70) <<23;
z = z | (num & 0x03ff) <<13;
return(*((float*)&z)); }
//-----------------------------------------------
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
|