3D FPS Example

Programming examples for the Psy-Q SDK
User avatar
Shadow
Admin / PSXDEV
Admin / PSXDEV
Posts: 2670
Joined: Dec 31, 2012
PlayStation Model: H2000/5502
Discord: Shadow^PSXDEV

Post by Shadow » November 7th, 2018, 12:23 pm

Very cool 3D environment :)
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
LameGuy64
Psy-Q Enthusiast
Psy-Q Enthusiast
Posts: 388
Joined: Apr 10, 2013
I am a: Hobbyist Game Developer
Motto: Commercial or not, play it!
PlayStation Model: H2000/7000
Location: Philippines
Contact:

Post by LameGuy64 » November 7th, 2018, 2:20 pm

Yeah, TMD is not exactly suitable for rendering large 3D environments so a serious developer would often make their own rendering system. More sophisticated renderers have stuff like mipmaps and geometry LOD as seen in the Spyro games.

The TMD rendering functions are also pretty bloat and have some limitations to them such as limited control in translucency and not much in the way of special effects such as environment mapping.
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: 124
Joined: Jan 07, 2018
I am a: Game Designer
PlayStation Model: SCPH-5502
Location: Russian Federation
Contact:

Post by NITROYUASH » November 7th, 2018, 8:00 pm

make their own rendering system
*oof*
Okay, sounds hard. Very hard.

User avatar
lamb_of_senpai
Curious PSXDEV User
Curious PSXDEV User
Posts: 14
Joined: Oct 11, 2018

Post by lamb_of_senpai » November 8th, 2018, 1:43 am

NITROYUASH wrote: November 7th, 2018, 8:00 pm
make their own rendering system
*oof*
Okay, sounds hard. Very hard.
It looks like you've got a fairly rectilinear environment, so why not just extend/refine Lameguy64's original method? It looks like you're already working with tiles, so one thing you could do is write your own Blender script to export just the tile location/orientation, size, and associated texture in your own custom format, then write a set of functions to import, generate the geometry, and display it. There are plenty of "cheats" you could do—for instance you could use only a predetermined set of orientations/sizes stored as bit flags to get the read time up, make your exporter merge large groups of contiguous tiles using the same texture into single large tiles, etc. Of course, this wouldn't give you the kind of detail/variety found in a game like Spyro, but it's a good place to start, and you could of course extend this method to include non-tile meshes.

User avatar
NITROYUASH
Serious PSXDEV User
Serious PSXDEV User
Posts: 124
Joined: Jan 07, 2018
I am a: Game Designer
PlayStation Model: SCPH-5502
Location: Russian Federation
Contact:

Post by NITROYUASH » November 15th, 2018, 7:39 am

UPD:
Thanks to Lameguy and this awesome 3D example, i did something like that.
ABBC3_SPOILER_SHOW
It looks like I still have a lot of work, but it's working :p

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

Post by LameGuy64 » November 15th, 2018, 11:01 am

You may want to take a look at this example I made a long time ago that demonstrates how to do 3D transformations with the GTE directly using macros. It is much faster than RotTransPersp3() and gives you more control on how the GTE is being utilized.

You'll need to use dmpsx to convert the weird word codes used in the GTE macro headers to the correct cop2 instructions in your PS-EXE or object file. The Programmer's Tool CD 2.2 has a 32-bit version of dmpsx in it. Alternatively, you can replace the .dw <whatever code> directives in the GTE macros into cop2 instructions to eliminate the need to use dmpsx.
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: 124
Joined: Jan 07, 2018
I am a: Game Designer
PlayStation Model: SCPH-5502
Location: Russian Federation
Contact:

Post by NITROYUASH » November 15th, 2018, 12:05 pm

Sounds great. I will try to work with this code too :)

User avatar
NITROYUASH
Serious PSXDEV User
Serious PSXDEV User
Posts: 124
Joined: Jan 07, 2018
I am a: Game Designer
PlayStation Model: SCPH-5502
Location: Russian Federation
Contact:

Post by NITROYUASH » December 19th, 2018, 8:06 pm

I have a small question about Blender and PS1 geometry. I don't want to make another theme so I will describe the problem here.

So this is the test-map (Blender):
ABBC3_SPOILER_SHOW
And this how it's look in PS1 (after Axis Conversion in Blender ( axis_conversion(to_forward='-Z', to_up='-Y').to_4x4() ) with SVECTOR VX VY VZ)
ABBC3_SPOILER_SHOW
with SVECTOR VX VY -VZ:
ABBC3_SPOILER_SHOW
Better than nothing, but now my model is mirrored.

UPD:
Fixed. It was a problem with my code (?).

Code: Select all

		nclip = RotAverageNclip4(
			&vp[0], &vp[1], &vp[2], &vp[3], 
			(long *)&obj->x0, (long *)&obj->x1, 
			(long *)&obj->x3, (long *)&obj->x2,
			&p, &OTz, &Flag);
Fix:

Code: Select all

		nclip = RotAverageNclip4(
			&vp[3], &vp[2], &vp[1], &vp[0], 
			(long *)&obj->x0, (long *)&obj->x1, 
			(long *)&obj->x3, (long *)&obj->x2,
			&p, &OTz, &Flag);

User avatar
NITROYUASH
Serious PSXDEV User
Serious PSXDEV User
Posts: 124
Joined: Jan 07, 2018
I am a: Game Designer
PlayStation Model: SCPH-5502
Location: Russian Federation
Contact:

Post by NITROYUASH » February 3rd, 2019, 4:10 am

Hmm... I wonder to know how to fix this lines(?) between quads.

Image

User avatar
gwald
Net Yaroze Enthusiast
Net Yaroze Enthusiast
Posts: 282
Joined: Sep 18, 2013
I am a: programmer/DBA
PlayStation Model: Net Yaroze
Contact:

Post by gwald » February 3rd, 2019, 10:30 am

I think it's because of the lack of float precision (but I get this even with floats on 3DS :? ).
The only way I know how to fix it, is to use vector lookups (indices), ie use the same exact vectors that the surrounding faces use.
But it could be the emulator being over precise, try a different render or emulator... try it on hardware and even on a CTR screen, it might not even be noticeable...

User avatar
Shadow
Admin / PSXDEV
Admin / PSXDEV
Posts: 2670
Joined: Dec 31, 2012
PlayStation Model: H2000/5502
Discord: Shadow^PSXDEV

Post by Shadow » February 3rd, 2019, 4:03 pm

It would be from the PCSXR emulator. Use real hardware like gwald said.
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: 124
Joined: Jan 07, 2018
I am a: Game Designer
PlayStation Model: SCPH-5502
Location: Russian Federation
Contact:

Post by NITROYUASH » February 3rd, 2019, 7:50 pm

This is not an emulator problem.
Tested on PCSXR, EPSXE, NO$PSX and PS3.
The only way I know how to fix it, is to use vector lookups (indices), ie use the same exact vectors that the surrounding faces use.
Examples? :0

Sblorgz
Curious PSXDEV User
Curious PSXDEV User
Posts: 22
Joined: May 18, 2015

Post by Sblorgz » February 3rd, 2019, 11:42 pm

The official way to do that is to fill the holes with degenerated triangles (i.e. rendered as textured lines).

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

Post by LameGuy64 » February 4th, 2019, 12:19 am

The seams happen when there are two connecting polygons (tris and quads) that are subdivided at different levels and the point of the quad that is subdivided does not always line up with the edge of a lesser subdivided or undivided quad.

Usual workarounds according to the PlayStation documents is to sort very thin triangle strips around the edges of a subdivided quad. That's what my custom quad subdivision routines do to hide the seams though the seams will become visible again when transparency is used.
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: 124
Joined: Jan 07, 2018
I am a: Game Designer
PlayStation Model: SCPH-5502
Location: Russian Federation
Contact:

Post by NITROYUASH » February 4th, 2019, 5:57 am

The seams happen when there are two connecting polygons (tris and quads) that are subdivided at different levels and the point of the quad that is subdivided does not always line up with the edge of a lesser subdivided or undivided quad.
I confirm this. After some tests with division, i managed reduce the seams. Thanks!

User avatar
NITROYUASH
Serious PSXDEV User
Serious PSXDEV User
Posts: 124
Joined: Jan 07, 2018
I am a: Game Designer
PlayStation Model: SCPH-5502
Location: Russian Federation
Contact:

Post by NITROYUASH » March 30th, 2019, 12:38 am

I have a question about UV for plane(s):

Previously i was using this function:
setUVWH(obj_ft4, U_out, V_out, W_out, H_out);
ABBC3_SPOILER_SHOW
But this isn't working with POLY_FT3.

Now i want to use this 2 functions:
setUV3(obj_ft3, U0,V0, U1,V1, U2,V2);
setUV4(obj_ft3, U0,V0, U1,V1, U2,V2, U3,V3);

How to set the UV correctly for POLY_FT3 and POLY_FT4 using the UV3/UV4?

Texture Info:
ABBC3_SPOILER_SHOW
Thanks c:

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

Post by LameGuy64 » March 30th, 2019, 1:20 pm

setUVWH() just sets all 4 UV coordinates of a quad based on the values you've specified to its arguments. The macro basically does:

Code: Select all

obj_ft4->u0 = U_out;
obj_ft4->v0 = V_out;
obj_ft4->u1 = U_out+W_out;
obj_ft4->v1 = V_out;
obj_ft4->u2 = U_out;
obj_ft4->v2 = V_out+H_out;
obj_ft4->u3 = U_out+W_out;
obj_ft4->v3 = V_out+H_out;
Assuming U_out and V_out are basically offsets of the texture image relative to its tpage you'll have to do it like this if you want to use setUV* macros:

Code: Select all

setUV3(obj_ft3, U_out, V_out, U_out+W_out, V_out, U_out, V_out+H_out);
setUV4(obj_ft4, U_out, V_out, U_out+W_out, V_out, U_out, V_out+H_out, U_out+W_out, V_out+H_out);
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: 124
Joined: Jan 07, 2018
I am a: Game Designer
PlayStation Model: SCPH-5502
Location: Russian Federation
Contact:

Post by NITROYUASH » March 30th, 2019, 8:49 pm

Almost working. The texture is flipped to the right :D
ABBC3_SPOILER_SHOW
Quick fix for me:

Code: Select all

setUV3(obj_ft3, U_out+W_out,V_out, U_out+W_out,V_out+H_out, U_out,V_out);
ABBC3_SPOILER_SHOW
Last edited by NITROYUASH on March 31st, 2019, 1:16 am, edited 1 time in total.

likeabaus
Extreme PSXDEV User
Extreme PSXDEV User
Posts: 133
Joined: Jul 27, 2016

Post by likeabaus » March 31st, 2019, 1:04 am

I'm a bit late to the party here, but this is quite impressive LameGuy64!

3D rendering is not an easy task for homebrew developers on the original PlayStation . This is pretty freakin' cool!

User avatar
MihaiGamerXD
Active PSXDEV User
Active PSXDEV User
Posts: 38
Joined: Mar 09, 2019
I am a: Programmer
PlayStation Model: SCPH-1001

Post by MihaiGamerXD » July 12th, 2019, 5:33 am

Nice example LameGuy64! But I have one more problem. I want to set the resolution to 640x480, but the screen is glitchy!
How can I fix that?

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests