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 

Problem with z buffer

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



Joined: 16 Jul 2007
Posts: 13
Location: Poland

PostPosted: Thu Sep 13, 2007 3:36 am    Post subject: Problem with z buffer Reply with quote

I'm developing my own layer over ps2 hardware and I have problem with z-buffer.

I wrote code that draw white sprite on entire screen and two triangles over this sprite. But when I swap z values of triangle 1 vertices with triangle 2 I have same effect on the screen.

What I'm doing with z buffer in loop:
- set ZBUF_1 register fields to:
ZBP = byte pointer to z buf / 8192
PSM = 0
ZMSK = 0 (z buffer is updated always)
- draw sprite on entire screen with z coordinate = 1
- set ZBUF_1 ZMSK field to 1 (z buffer is updated regardless of depth test)
- set TEST_1 register fields to:
ZTE = 1
ZTST = 11 (GREATER)
- draw triangle 1 with z value = 100
- draw triangle 2 over triangle 1 with z value = 10

After this operations triangle 2 is over triangle 1.
I think that z values don't fill z-buffer but z-test is working because when sprite is not drawed I have "doted" triangles (tested with random z values) on the sreeen

Can anyone say what I'm doing wrong?
Back to top
View user's profile Send private message Visit poster's website
Lukasz



Joined: 19 Jan 2004
Posts: 248
Location: Denmark

PostPosted: Thu Sep 13, 2007 5:21 am    Post subject: Reply with quote

Your description looks correct, the only thing I can think of with the z-buffer is that it is prohibited to set ZTE=0 in TEST, as this can cause a malfunction.

That being said, there could many other origins of the problems like incorrect code, errors in gif packet, etc. I'd recommend to printf what youre actually sending to the GS and make sure you are waiting for GS FINISH, so you are 100% sure everything is correctly setup and the GS is done drawing.
_________________
Lukasz.dk
Back to top
View user's profile Send private message Visit poster's website
MaikeruDev



Joined: 16 Jul 2007
Posts: 13
Location: Poland

PostPosted: Thu Sep 13, 2007 7:18 am    Post subject: Reply with quote

Lukasz wrote:
Your description looks correct, the only thing I can think of with the z-buffer is that it is prohibited to set ZTE=0 in TEST, as this can cause a malfunction.


I setted ZBUF.ZMSK = 1, TEST.ZTE = 1 and TEST.ZTST = ALWAYS before sending sprite and now everything is OK. You have right that setting ZTE to 0 may cause malfunction, thank You.

Lukasz wrote:

That being said, there could many other origins of the problems like incorrect code, errors in gif packet, etc. I'd recommend to printf what youre actually sending to the GS and make sure you are waiting for GS FINISH, so you are 100% sure everything is correctly setup and the GS is done drawing.


I know. I have checked everything n-times :)
And I have question about GS FINISH event. When I'm using only PATH3 Am I supposed to check this event? Acctualy I tested code with FINISH event checking in CSR register and without it (Of course with writing to FINISH register at end of drawing). Results was the same - nice triangles without any bugs :)

Thank You again. Now I can do another step :)
Back to top
View user's profile Send private message Visit poster's website
Lukasz



Joined: 19 Jan 2004
Posts: 248
Location: Denmark

PostPosted: Thu Sep 13, 2007 5:14 pm    Post subject: Reply with quote

You run into problems without using FINISH, if you try to render more polygons than what's possible timewise within a frame. Because if you only wait for VBLANK you might get artifacts as some of the polygons are drawn after vblank. But if you wait for FINISH, you will get a slowdown, but no articfacts :-)

Checking for this event on PATH3 I find important, as you are probably generating all your gif packets on the fly and therefor using alot of EE power just to setup packets. If you start stressing the EE, you might not be able to setup the gif packet on EE and have the GS render it, all within a frame.
_________________
Lukasz.dk
Back to top
View user's profile Send private message Visit poster's website
MaikeruDev



Joined: 16 Jul 2007
Posts: 13
Location: Poland

PostPosted: Thu Sep 13, 2007 6:28 pm    Post subject: Reply with quote

I was thinking about it after my post. So I don't know actually how GS draws everything without artifacts when I'm not synchronizing it with FINISH but only with VBLANK.

My result:

PS. Check PM
Back to top
View user's profile Send private message Visit poster's website
emoon



Joined: 18 Jan 2004
Posts: 91
Location: Stockholm, Sweden

PostPosted: Fri Sep 14, 2007 7:17 am    Post subject: Reply with quote

hint:

include screenshot.h and use ps2_screenshot_file(...)
Back to top
View user's profile Send private message Visit poster's website
MaikeruDev



Joined: 16 Jul 2007
Posts: 13
Location: Poland

PostPosted: Wed Nov 07, 2007 8:38 am    Post subject: Reply with quote

Sorry for late, but thanks for hint emoon. I wrote "download texture" and after "screenshot" functions based on Your code and documentation distributed with linux, but using my own object-oriented library that I'm developing.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 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