| View previous topic :: View next topic |
| Author |
Message |
J-Fox
Joined: 26 Sep 2007 Posts: 15 Location: Hannover, Germany
|
Posted: Thu Jan 31, 2008 10:23 am Post subject: Reading the depthbuffer - Problem with format? |
|
|
Hey,
| Code: |
#define BUF_WIDTH (512)
#define SCR_WIDTH (480)
#define SCR_HEIGHT (272)
...
sceGuDepthBuffer(zbp,BUF_WIDTH);
sceGuDepthRange(0xFFFF,0x0);
...
sceGuTexMode(GU_PSM_4444,0,0,0);
sceGuCopyImage(GU_PSM_4444,0,0,512,512,512,(void*)(((unsigned int)zbp)+0x4000000),0,0,512,depth);
sceGuTexImage(0,512,512,512,depth);
|
This is some code I wrote for reading the zbuffer to an new array which I would like to use as a sprite-texture.
I have no problems reading the data for the color-framebuffer (format GU_PSM_8888), however, the zbuffer seems to use some weird format:
Rendering the texture "depth" will result in weird colors (well thats ok), some blocks which seem to be 32x32 pixel each (but totally wrong positions - which made me think its swizzled, it doesnt seem to be though) and other weird rotations of the drawn noise which don't match the object in the color-framebuffer.
What do I have to change / do to get the zbuffer as a texture?
(If there is a function which does that - even better!)
PS: Outputting the array to a file gave me unexpected results: It looks like the pixels I wrote to, get a value which loops through ABCDEFG... and 123456... |
|
| Back to top |
|
 |
snow
Joined: 15 Dec 2007 Posts: 31
|
Posted: Thu Jan 31, 2008 12:04 pm Post subject: |
|
|
| I'm still being educated but if I'm not mistaken the zbuffer isn't any sort of image. It's meta data about the depth of the pixels and their color values. Also the order of the meta data is not a contiguous array of pixels as the color(draw) buffer is. Rendering it will give you garbage. |
|
| Back to top |
|
 |
ufoz
Joined: 10 Nov 2005 Posts: 86 Location: Tokyo
|
|
| Back to top |
|
 |
J-Fox
Joined: 26 Sep 2007 Posts: 15 Location: Hannover, Germany
|
Posted: Thu Jan 31, 2008 9:04 pm Post subject: |
|
|
Thanks for pointing that out snow - and thanks alot for the link ufoz, I believed the zbufferfog sample was just using another fogmode made by sony, it was exactly what I have been looking for though =)
Thanks again! |
|
| Back to top |
|
 |
snow
Joined: 15 Dec 2007 Posts: 31
|
Posted: Fri Feb 01, 2008 12:42 am Post subject: |
|
|
| Ah, cool. So an image can be extracted from it. Can I ask what you're doing with it by any chance? |
|
| Back to top |
|
 |
J-Fox
Joined: 26 Sep 2007 Posts: 15 Location: Hannover, Germany
|
Posted: Fri Feb 01, 2008 11:02 am Post subject: |
|
|
Well, I m only trying to do some cool graphics on psp.
- Reading the zbuffer 16bpp - FAILS
- Reading the zbuffer 32bpp - WORKS
- Render to texture 16bpp - WORKS
- Render to texture 32bpp - SLOW
Does anyone know how to read the zbuffer in GU_PSM_5650 just like in GU_PSM_8888? |
|
| Back to top |
|
 |
Visigotico
Joined: 23 Apr 2008 Posts: 11
|
Posted: Sat Jan 30, 2010 1:30 am Post subject: |
|
|
| with GU_PSM_4444 (16 bit draw and display buffers), linear zbuffer seems to be at zbuffer + 2MB. |
|
| Back to top |
|
 |
|