I have a problem with 2D sprite in 3D game

Graphic based area of development (Graphics Processing Unit), including the Geometry Transform Engine (GTE), TIM, STR (MDEC), etc.
User avatar
NITROYUASH
Serious PSXDEV User
Serious PSXDEV User
Posts: 121
Joined: January 7th, 2018, 12:03 am
I am a: Game Designer
PlayStation Model: SCPH-5502
Steam: NITROYUASH
Location: Russian Federation
Contact:

I have a problem with 2D sprite in 3D game

Post by NITROYUASH » November 11th, 2019, 3:10 am

Hi PSXDEV. What is the name of this problem? For some reason, a 2D sprites in my game will not drawing correctly when they stand on the floor. Can i fix that using the PS1 function or this is more complicated problem? Can't find a sample by the way because i don't know what kind of problem is it. (Something with Z-sort?)

https://youtu.be/LMB4yr6RfUo

The simplified sprite source:

Code: Select all

	long	OTz;
	int		i;
	
	obj_ft4 = (POLY_FT4*)gte_myPrimPtr;

	gte_ldv3(&Sprite.co[0], &Sprite.co[1], &Sprite.co[2]);
	gte_rtpt();

	gte_ldv0(&Sprite.co[3]);
	gte_stsxy3(&obj_ft4->x0, &obj_ft4->x1, &obj_ft4->x2);

	gte_rtps();

	gte_avsz4();
	gte_stotz(&OTz);

	if( OTz > 0 ) {
		if (((OTz >> 2) >= GTE_OT_LENGTH)) {
			gte_stsxy(&obj_ft4->x3);
			
			setUVWH(obj_ft4,
				Sprite.settings.u, Sprite.settings.v,
				Sprite.settings.w, Sprite.settings.h);
	
			obj_ft4->tpage = Sprite.texture.tpage;
			obj_ft4->clut  = Sprite.texture.clutid;
			
			setPolyFT4(obj_ft4);
		
			addPrim(OT + (OTz >> 2), obj_ft4);
			gte_myPrimPtr += GTE_POLY_FT4_size;
		}
	}
Thanks for the helping!

User avatar
NITROYUASH
Serious PSXDEV User
Serious PSXDEV User
Posts: 121
Joined: January 7th, 2018, 12:03 am
I am a: Game Designer
PlayStation Model: SCPH-5502
Steam: NITROYUASH
Location: Russian Federation
Contact:

Re: I have a problem with 2D sprite in 3D game

Post by NITROYUASH » November 11th, 2019, 1:58 pm

Just thought about potential quick-fix.
Maybe i should mark somewhere the floor polygons. Then add the second OT or something like that just for problematic polygons and then draw the sprites always in front of that polygons.

What do you guys think about this?

User avatar
LameGuy64
Psy-Q Enthusiast
Psy-Q Enthusiast
Posts: 381
Joined: April 10th, 2013, 3:47 pm
I am a: Hobbyist Game Developer
Motto: Commercial or not, play it!
PlayStation Model: H2000/7000
Location: Philippines
Contact:

Re: I have a problem with 2D sprite in 3D game

Post by LameGuy64 » November 12th, 2019, 11:58 am

If what you're looking for is bill-boarding sprites in a 3D space, there's a billboard example in PSn00bSDK that demonstrates just that.
Please don't forget to include my name if you share my work around. Credit where it is due.

Dev. Console: SCPH-7000 with SCPH-7501 ROM, MM3, PAL color fix, Direct AV ports, DB-9 port for Serial I/O, and a Xplorer FX with Caetla 0.35.

DTL-H2000 PC: Dell Optiplex GX110, Windows 98SE & Windows XP, Pentium III 933MHz, 384MB SDRAM, ATI Radeon 7000 VE 64MB, Soundblaster Audigy, 40GB Seagate HDD, Hitachi Lite-on CD-RW Drive, ZIP 250 and 3.5" Floppy.

User avatar
NITROYUASH
Serious PSXDEV User
Serious PSXDEV User
Posts: 121
Joined: January 7th, 2018, 12:03 am
I am a: Game Designer
PlayStation Model: SCPH-5502
Steam: NITROYUASH
Location: Russian Federation
Contact:

Re: I have a problem with 2D sprite in 3D game

Post by NITROYUASH » November 12th, 2019, 3:01 pm

The problem is not in the billboard.
In fact, the problem applies to all 3D polygons.
As you can see, when the sprite-object (it just POLY_FT4) is not centered on the floor-object (POLY_ANYTHING?), something weird will start happening with the Z-Sort between sprite and the floor.
The larger the polygon of the floor, the higher the risk that it will overlap an object above oneself.

User avatar
LameGuy64
Psy-Q Enthusiast
Psy-Q Enthusiast
Posts: 381
Joined: April 10th, 2013, 3:47 pm
I am a: Hobbyist Game Developer
Motto: Commercial or not, play it!
PlayStation Model: H2000/7000
Location: Philippines
Contact:

Re: I have a problem with 2D sprite in 3D game

Post by LameGuy64 » November 13th, 2019, 1:10 pm

That's likely the limits of painter's sort algorithm really as the depth value for Z sorting is computed by averaging the Z coordinates of a polygon, which is typically the center of said polygon.

The best way to work around this is to subdivide polygons with the Z depth computed on each subdivided polygon. The Divide* functions in libgte do not support that, not so sure on libgs as I haven't used that in so long.
Please don't forget to include my name if you share my work around. Credit where it is due.

Dev. Console: SCPH-7000 with SCPH-7501 ROM, MM3, PAL color fix, Direct AV ports, DB-9 port for Serial I/O, and a Xplorer FX with Caetla 0.35.

DTL-H2000 PC: Dell Optiplex GX110, Windows 98SE & Windows XP, Pentium III 933MHz, 384MB SDRAM, ATI Radeon 7000 VE 64MB, Soundblaster Audigy, 40GB Seagate HDD, Hitachi Lite-on CD-RW Drive, ZIP 250 and 3.5" Floppy.

User avatar
Shadow
Admin / PSXDEV
Admin / PSXDEV
Posts: 2380
Joined: December 31st, 2012, 5:37 pm
PlayStation Model: H2000/5502

Re: I have a problem with 2D sprite in 3D game

Post by Shadow » November 13th, 2019, 2:05 pm

Looks like the ordertable is getting overflowed. Have you tried using dual-ordertables? IE: OT1 can be for sprites, but OT2 is then for 3D. Finally, you then sort and draw them. There is a good example by Sony showing how to do this. Basically it gives you a larger ranger of ordertables which helps with that z-sort issue and helps with that annoying flicker :)

Code: Select all

GsSortOt(&WorldOrderingTable2[CurrentBuffer], &WorldOrderingTable1[CurrentBuffer]);
GsDrawOt(&WorldOrderingTable1[CurrentBuffer]);
Development Console: SCPH-5502 with 8MB RAM, MM3 Modchip, PAL 60 Colour Modification (for NTSC), PSIO Switch Board, DB-9 breakout headers for both RGB and Serial output and an Xplorer with CAETLA 0.34.

PlayStation Development PC: Windows 98 SE, Pentium 3 at 400MHz, 128MB SDRAM, DTL-H2000, DTL-H2010, DTL-H201A, DTL-S2020 (with 4GB SCSI-2 HDD), 21" Sony G420, CD-R burner, 3.25" and 5.25" Floppy Diskette Drives, ZIP 100 Diskette Drive and an IBM Model M keyboard.

User avatar
NITROYUASH
Serious PSXDEV User
Serious PSXDEV User
Posts: 121
Joined: January 7th, 2018, 12:03 am
I am a: Game Designer
PlayStation Model: SCPH-5502
Steam: NITROYUASH
Location: Russian Federation
Contact:

Re: I have a problem with 2D sprite in 3D game

Post by NITROYUASH » November 13th, 2019, 3:05 pm

Tried to use this function, but for some reason, this will reduces the frame rate to 5-10 frames.

Here is a quick-fix for the floor:

Code: Select all

// Floor planes is the... Um... Floor, okay?
// This fix will need to correctly draw the objects like sprite on the floor
// It will shift the OTz a little
// So you'll need to keep the distance between the floor-marked objects and the other planes below!
u_char floor = (Plane.settings.back != 0) ? 12 : 0;

Code: Select all

addPrim(OT + (OTz >> 2) + floor, obj);
PS:
Oh, yes, if you divide the object into many small parts, it will works too, but you still will see the flickering even with the small polygons and it may be a performance killer.

User avatar
Shadow
Admin / PSXDEV
Admin / PSXDEV
Posts: 2380
Joined: December 31st, 2012, 5:37 pm
PlayStation Model: H2000/5502

Re: I have a problem with 2D sprite in 3D game

Post by Shadow » November 13th, 2019, 11:36 pm

NITROYUASH wrote:
November 13th, 2019, 3:05 pm
Tried to use this function, but for some reason, this will reduces the frame rate to 5-10 frames.
My idea using dual-ordertables reduces the frame rate by 5-10 frames?
Development Console: SCPH-5502 with 8MB RAM, MM3 Modchip, PAL 60 Colour Modification (for NTSC), PSIO Switch Board, DB-9 breakout headers for both RGB and Serial output and an Xplorer with CAETLA 0.34.

PlayStation Development PC: Windows 98 SE, Pentium 3 at 400MHz, 128MB SDRAM, DTL-H2000, DTL-H2010, DTL-H201A, DTL-S2020 (with 4GB SCSI-2 HDD), 21" Sony G420, CD-R burner, 3.25" and 5.25" Floppy Diskette Drives, ZIP 100 Diskette Drive and an IBM Model M keyboard.

User avatar
NITROYUASH
Serious PSXDEV User
Serious PSXDEV User
Posts: 121
Joined: January 7th, 2018, 12:03 am
I am a: Game Designer
PlayStation Model: SCPH-5502
Steam: NITROYUASH
Location: Russian Federation
Contact:

Re: I have a problem with 2D sprite in 3D game

Post by NITROYUASH » November 14th, 2019, 1:19 am

Yes, i just added it to main loop.

Code: Select all

#define OT_LENGTH	12
#define OT_ENTRIES	(1<<OT_LENGTH)
// Main OT (Main position)
GsOT 		myOT[2];
GsOT_TAG 	myOT_TAG[2][OT_ENTRIES];

// Second OT (Second position)
GsOT		myOT2[2];
GsOT_TAG 	myOT2_TAG[2][OT_ENTRIES];

void PrepDisp() {
//. . . .
	GsClearOt(0, 0,  &myOT[ActiveBuffer]);
	GsClearOt(0, 12, &myOT2[ActiveBuffer]);
//. . . .
}

void Display() {
//. . . .
	//Merge OT's (Here is the problem)
	GsSortOt(&myOT[ActiveBuffer], &myOT2[ActiveBuffer]);

	GsDrawOt(&myOT[ActiveBuffer]);		// Draw GS OT
//. . . .
}
Last edited by NITROYUASH on November 14th, 2019, 2:34 am, edited 2 times in total.

User avatar
Shadow
Admin / PSXDEV
Admin / PSXDEV
Posts: 2380
Joined: December 31st, 2012, 5:37 pm
PlayStation Model: H2000/5502

Re: I have a problem with 2D sprite in 3D game

Post by Shadow » November 14th, 2019, 2:05 am

Code: Select all

GsSortOt(&myOT[ActiveBuffer], &myOT2[ActiveBuffer]);
This causes the performance drop?
Development Console: SCPH-5502 with 8MB RAM, MM3 Modchip, PAL 60 Colour Modification (for NTSC), PSIO Switch Board, DB-9 breakout headers for both RGB and Serial output and an Xplorer with CAETLA 0.34.

PlayStation Development PC: Windows 98 SE, Pentium 3 at 400MHz, 128MB SDRAM, DTL-H2000, DTL-H2010, DTL-H201A, DTL-S2020 (with 4GB SCSI-2 HDD), 21" Sony G420, CD-R burner, 3.25" and 5.25" Floppy Diskette Drives, ZIP 100 Diskette Drive and an IBM Model M keyboard.

User avatar
NITROYUASH
Serious PSXDEV User
Serious PSXDEV User
Posts: 121
Joined: January 7th, 2018, 12:03 am
I am a: Game Designer
PlayStation Model: SCPH-5502
Steam: NITROYUASH
Location: Russian Federation
Contact:

Re: I have a problem with 2D sprite in 3D game

Post by NITROYUASH » November 14th, 2019, 2:33 am

Yep, after removing GsSortOt, everything will be fine again.

RetroPsx
BANNED
BANNED
Posts: 28
Joined: December 27th, 2017, 2:45 am

Re: I have a problem with 2D sprite in 3D game

Post by RetroPsx » November 15th, 2019, 12:12 am

Hi

I noticed that this SDK From this site works in 3D

Is there a 3D engine for this SDK?

is there any tutorial on this one?

User avatar
NITROYUASH
Serious PSXDEV User
Serious PSXDEV User
Posts: 121
Joined: January 7th, 2018, 12:03 am
I am a: Game Designer
PlayStation Model: SCPH-5502
Steam: NITROYUASH
Location: Russian Federation
Contact:

Re: I have a problem with 2D sprite in 3D game

Post by NITROYUASH » November 15th, 2019, 4:59 am

Off Topic
I noticed that this SDK From this site works in 3D
What SDK?

User avatar
LameGuy64
Psy-Q Enthusiast
Psy-Q Enthusiast
Posts: 381
Joined: April 10th, 2013, 3:47 pm
I am a: Hobbyist Game Developer
Motto: Commercial or not, play it!
PlayStation Model: H2000/7000
Location: Philippines
Contact:

Re: I have a problem with 2D sprite in 3D game

Post by LameGuy64 » November 15th, 2019, 12:06 pm

If there's an OT overflow going on the program should become unstable as data around the data segment is being corrupted or crash immediately if the overflow went to the other OT, as the latter would likely cause a GPU deadlock in a double OT/primitive buffer setup.
Please don't forget to include my name if you share my work around. Credit where it is due.

Dev. Console: SCPH-7000 with SCPH-7501 ROM, MM3, PAL color fix, Direct AV ports, DB-9 port for Serial I/O, and a Xplorer FX with Caetla 0.35.

DTL-H2000 PC: Dell Optiplex GX110, Windows 98SE & Windows XP, Pentium III 933MHz, 384MB SDRAM, ATI Radeon 7000 VE 64MB, Soundblaster Audigy, 40GB Seagate HDD, Hitachi Lite-on CD-RW Drive, ZIP 250 and 3.5" Floppy.

RetroPsx
BANNED
BANNED
Posts: 28
Joined: December 27th, 2017, 2:45 am

Re: I have a problem with 2D sprite in 3D game

Post by RetroPsx » November 15th, 2019, 10:44 pm

Psy-Q SDK and all possible resources in this site

User avatar
Dedok179
Active PSXDEV User
Active PSXDEV User
Posts: 66
Joined: June 11th, 2015, 7:23 pm
I am a: Programmer, Developer.
PlayStation Model: SCPH-5502
Location: Tula,RU

Re: I have a problem with 2D sprite in 3D game

Post by Dedok179 » November 15th, 2019, 11:32 pm

RetroPsx wrote:
November 15th, 2019, 10:44 pm
Psy-Q SDK and all possible resources in this site
If you are hoping to come to the ready, then no. It doesn’t work like that.

RetroPsx
BANNED
BANNED
Posts: 28
Joined: December 27th, 2017, 2:45 am

Re: I have a problem with 2D sprite in 3D game

Post by RetroPsx » November 16th, 2019, 11:46 pm

I am looking for information to be ready

So tell me a resume how it works and how to configure its environment of development "psx" in 3D?

User avatar
Shadow
Admin / PSXDEV
Admin / PSXDEV
Posts: 2380
Joined: December 31st, 2012, 5:37 pm
PlayStation Model: H2000/5502

Re: I have a problem with 2D sprite in 3D game

Post by Shadow » November 17th, 2019, 2:19 pm

NITROYUASH wrote:
November 14th, 2019, 2:33 am
Yep, after removing GsSortOt, everything will be fine again.
Hmm. That's very interesting. I didn't realise that it caused such a massive performance drop! :?

Off Topic
RetroPsx wrote:
November 16th, 2019, 11:46 pm
I am looking for information to be ready

So tell me a resume how it works and how to configure its environment of development "psx" in 3D?
Warning issued. Do not hijack and post off topic and silly related questions in poor and broken English.
Development Console: SCPH-5502 with 8MB RAM, MM3 Modchip, PAL 60 Colour Modification (for NTSC), PSIO Switch Board, DB-9 breakout headers for both RGB and Serial output and an Xplorer with CAETLA 0.34.

PlayStation Development PC: Windows 98 SE, Pentium 3 at 400MHz, 128MB SDRAM, DTL-H2000, DTL-H2010, DTL-H201A, DTL-S2020 (with 4GB SCSI-2 HDD), 21" Sony G420, CD-R burner, 3.25" and 5.25" Floppy Diskette Drives, ZIP 100 Diskette Drive and an IBM Model M keyboard.

User avatar
NITROYUASH
Serious PSXDEV User
Serious PSXDEV User
Posts: 121
Joined: January 7th, 2018, 12:03 am
I am a: Game Designer
PlayStation Model: SCPH-5502
Steam: NITROYUASH
Location: Russian Federation
Contact:

Re: I have a problem with 2D sprite in 3D game

Post by NITROYUASH » November 17th, 2019, 4:50 pm

Shadow wrote:
November 17th, 2019, 2:19 pm
NITROYUASH wrote:
November 14th, 2019, 2:33 am
Yep, after removing GsSortOt, everything will be fine again.
Hmm. That's very interesting. I didn't realise that it caused such a massive performance drop! :?
As said Lameguy, it's maybe a problem with OT overflow (OT_ENTRIES?), not in SortOT. I should test it when i will need that function. Thanks guys for helping by the way c:

User avatar
Shadow
Admin / PSXDEV
Admin / PSXDEV
Posts: 2380
Joined: December 31st, 2012, 5:37 pm
PlayStation Model: H2000/5502

Re: I have a problem with 2D sprite in 3D game

Post by Shadow » November 17th, 2019, 7:31 pm

If that were the case though, a timeout warning would be issued. Since the library was written by SN Systems we would need to dissemble it to find out exactly what it's doing, but yes the best way would be to simply test it and share the results :)
Development Console: SCPH-5502 with 8MB RAM, MM3 Modchip, PAL 60 Colour Modification (for NTSC), PSIO Switch Board, DB-9 breakout headers for both RGB and Serial output and an Xplorer with CAETLA 0.34.

PlayStation Development PC: Windows 98 SE, Pentium 3 at 400MHz, 128MB SDRAM, DTL-H2000, DTL-H2010, DTL-H201A, DTL-S2020 (with 4GB SCSI-2 HDD), 21" Sony G420, CD-R burner, 3.25" and 5.25" Floppy Diskette Drives, ZIP 100 Diskette Drive and an IBM Model M keyboard.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest