Hello! I'm a new member, but I've been lurking for a while here.
Recently I decided to get serious about making a small game for the PS1, and a 3D game at that.
I have experience working with Direct3D and OpenGL, but working on PS1 is quite different! Lots of things are done differently and I can't wrap my head around a few things...
So, the problem I'm having here is that I want to render my game at 512x240, but keep the 4:3 aspect ratio without using LibGS.
Differently from how it is done on PC (this is set up at the projection matrix) I can't find a way to change that.
When you use LibGTE/LibGPU to render, you have to do that by yourself, if not, the results will be stretched thin on screen which does not look good. But they never explain how it is done in LibGS.
I tried to use ScaleMatrixL() to my camera matrix, but it works only when the camera is at the origin, if I try to translate the camera in any directions it will glitch out.
Here's the code I'm using to generate the camera matrix:
(by the way, the camera is always offset by a certain defined vector, so it orbits around the target)
[C]
RotMatrix(&cam->rotation, &cam->view_matrix);
TransposeMatrix(&cam->view_matrix, &temp);
ApplyMatrixLV(&temp, &cam->offset, &f_pos_t);
f_pos_t2 = cam->position;
f_pos_t2.vx -= f_pos_t.vx;
f_pos_t2.vy -= f_pos_t.vy;
f_pos_t2.vz -= f_pos_t.vz;
ApplyMatrixLV(&cam->view_matrix, &f_pos_t2, &f_pos);
f_pos.vx = -f_pos.vx;
f_pos.vy = -f_pos.vy;
f_pos.vz = -f_pos.vz;
TransMatrix(&cam->view_matrix, &f_pos);
ScaleMatrixL(&cam->view_matrix,&cam->aspect);
[/C]
What happens is, it renders correctly while the camera position is 0 or close to it, once it starts to get away from the center, when rotating it will start rotating in weird patterns making an 8 like figure, and it grows as you get farther from the origin point.
My guess is that it's probably the order I'm applying the scaling, but I can't figure out where it should be.
Thanks!
Adjust 3D aspect ratio for non square resolutions
- ArthCarvalho
- Active PSXDEV User
- Posts: 45
- Joined: Jan 29, 2016
- I am a: Artist, Programmer
- PlayStation Model: SCPH-103
-
LameGuy64 Verified
- 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:
In one of my 3D test programs, this is what I did to manually adjust aspect ratio and a first-person camera:
[c]
RotMatrix(&camRot, &viewMtx);
ScaleMatrixL(&viewMtx, &viewScale);
ApplyMatrixLV(&viewMtx, &camPos, &vec);
TransMatrix(&viewMtx, &vec);
[/c]
camRot and camPos are vector coordinates of the camera's position and angle, viewScale is the scale factor you can use to manually adjust the aspect ratio to the view matrix, viewMtx is your view matrix.
[c]
RotMatrix(&camRot, &viewMtx);
ScaleMatrixL(&viewMtx, &viewScale);
ApplyMatrixLV(&viewMtx, &camPos, &vec);
TransMatrix(&viewMtx, &vec);
[/c]
camRot and camPos are vector coordinates of the camera's position and angle, viewScale is the scale factor you can use to manually adjust the aspect ratio to the view matrix, viewMtx is your view matrix.
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.
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.
- ArthCarvalho
- Active PSXDEV User
- Posts: 45
- Joined: Jan 29, 2016
- I am a: Artist, Programmer
- PlayStation Model: SCPH-103
Thanks LameGuy64! So I was really doing it in the wrong order.
If I got it right... Basically what was happening is that I didn't transform the camera translation to account to the new scaled matrix and that's why it started doing those 8 like movements whenever it got farther from the origin point.
You really helped me out here, I was almost giving up and going back to 320x240, but I didn't want to let go of the smoothness 512x240 gives to horizontal movements, so thanks again!
If I got it right... Basically what was happening is that I didn't transform the camera translation to account to the new scaled matrix and that's why it started doing those 8 like movements whenever it got farther from the origin point.
You really helped me out here, I was almost giving up and going back to 320x240, but I didn't want to let go of the smoothness 512x240 gives to horizontal movements, so thanks again!
-
LameGuy64 Verified
- 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:
You're welcome. If you want, you may also want to add an option for anamorphic 16:9 aspect ratio correction into your homebrew for widescreen TVs as that would be really nice in this day and age.
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.
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.
-
gwald Verified
- Net Yaroze Enthusiast
- Posts: 282
- Joined: Sep 18, 2013
- I am a: programmer/DBA
- PlayStation Model: Net Yaroze
- Contact:
How can you make 512x240 to 16:9 ?LameGuy64 wrote:You're welcome. If you want, you may also want to add an option for anamorphic 16:9 aspect ratio correction into your homebrew for widescreen TVs as that would be really nice in this day and age.
With boarders you mean?
-
LameGuy64 Verified
- 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:
With partial borders, yes... The only way to get rid of the boarders that I know of is to use the 384x240 resolution mode as demonstrated in my Marilyn game.
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.
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.
Who is online
Users browsing this forum: No registered users and 6 guests