forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Reading the depthbuffer - Problem with format?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
J-Fox



Joined: 26 Sep 2007
Posts: 15
Location: Hannover, Germany

PostPosted: Thu Jan 31, 2008 10:23 am    Post subject: Reading the depthbuffer - Problem with format? Reply with quote

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
View user's profile Send private message
snow



Joined: 15 Dec 2007
Posts: 31

PostPosted: Thu Jan 31, 2008 12:04 pm    Post subject: Reply with quote

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
View user's profile Send private message
ufoz



Joined: 10 Nov 2005
Posts: 86
Location: Tokyo

PostPosted: Thu Jan 31, 2008 1:02 pm    Post subject: Reply with quote

See this thread:

http://forums.ps2dev.org/viewtopic.php?t=4421
Back to top
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
J-Fox



Joined: 26 Sep 2007
Posts: 15
Location: Hannover, Germany

PostPosted: Thu Jan 31, 2008 9:04 pm    Post subject: Reply with quote

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
View user's profile Send private message
snow



Joined: 15 Dec 2007
Posts: 31

PostPosted: Fri Feb 01, 2008 12:42 am    Post subject: Reply with quote

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
View user's profile Send private message
J-Fox



Joined: 26 Sep 2007
Posts: 15
Location: Hannover, Germany

PostPosted: Fri Feb 01, 2008 11:02 am    Post subject: Reply with quote

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
View user's profile Send private message
Visigotico



Joined: 23 Apr 2008
Posts: 11

PostPosted: Sat Jan 30, 2010 1:30 am    Post subject: Reply with quote

with GU_PSM_4444 (16 bit draw and display buffers), linear zbuffer seems to be at zbuffer + 2MB.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group