Question regarding "shaders" on Psx ( TR2 )

Anything other than PlayStation content may be posted here
Post Reply
Abelliqueux
Interested PSXDEV User
Interested PSXDEV User
Posts: 7
Joined: April 29th, 2016, 7:03 am

Question regarding "shaders" on Psx ( TR2 )

Post by Abelliqueux » April 29th, 2016, 7:24 am

Hi there,

I realize this might not be the right place to ask this kind of question but seeing as there seems to be quite a lot of Psx gurus here, I figured I might get some intersting informations in regards to my question.

So here it is ; I noticed in the Tomb Raider II game on PSX that some kind of reflection "shader" is present in the third level ( Bartoli's hideout), in the part where you have to dodge three swords from armored statues. If you look at the swords, you can see a distorted version of the frame buffer. Unfortunately, the TRII iso I have is not playable in no$psx, and I can't get a hint as how this is achieved.

What seems odd to me is that it seems to be only used once in the game, at this place.

So lots of interrogations here ;
Is this kind of effects usual in psx games ?
Is it trivial to achieve ?
Do you have any thoughts on why someone would bother to code such an effect just for it to appear in one place in the game ?
Do you have any background informations ( psx development in general, or Tomb Raider II development in specifics) ?

I'm just curious and love to hear about dev making-of, so any thoughts you might have are welcome !

You can find an article I wrote about it here (in french) : http://arthus.net/game/?tomb-raider-ii-psx-vs-pc
It has pictures, so it might help better understand what I'm talking about.

Thanks for your time !

AB.

User avatar
gwald
1997 Yaroze Enthusiast
1997 Yaroze Enthusiast
Posts: 256
Joined: September 18th, 2013, 8:44 am
I am a: programmer/DBA
PlayStation Model: Net Yaroze
Location: Australia
Contact:

Re: Question regarding "shaders" on Psx ( TR2 )

Post by gwald » April 29th, 2016, 9:47 am

The PSX didn't have the power to do much reflection/post processing and with good graphics.
To me, it looks like the texture UV is translated/rotated just above the sword in VRAM.
You can tell because Lara is in the texture image of the sword she has passed (the sword is behind her).

Actually, On second thoughts, I'd say it's just a pre rended low res images, with the UV being rotated, based on sword/arm.
You can tell by looking closely at the sword.

But it could be using actual VRAM texture if lara moves in the sword image also, ie jumping/shotting
Because the VRAM UV coords would be easy to know in that straight room.

Image
Nice little trick!

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

Re: Question regarding "shaders" on Psx ( TR2 )

Post by LameGuy64 » April 29th, 2016, 12:31 pm

PlayStation homebrew programmer here, the PSX does not support shaders whatsoever. With some fancy trickery however, you can achieve some interesting effects like this cel-shaded rendering trick if you know what you're doing.

By the looks of it, it appears to be using environment mapping with a pre-rendered reflection map which is a pretty common method of achieving chrome-looking effects on objects at the time.
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.

Abelliqueux
Interested PSXDEV User
Interested PSXDEV User
Posts: 7
Joined: April 29th, 2016, 7:03 am

Re: Question regarding "shaders" on Psx ( TR2 )

Post by Abelliqueux » April 29th, 2016, 7:52 pm

Hi,

Thanks for your answers.

Although the gif doesn't reflect that, the "reflection" is in real-time, as you can see the environment moving in it.
You can see it in this video :

https://www.youtube.com/watch?feature=p ... Ojz0#t=149

It's most obvious on the second and last sword.

I have yet to find another place where this effect is used...

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

Re: Question regarding "shaders" on Psx ( TR2 )

Post by Shadow » April 29th, 2016, 8:02 pm

It's possible they actually coded up their own real world reflections engine, but to me, that looks like it's a sequence of pre-loaded and pre-rendered animations since that would have been the best way to keep the frames per second count high whilst in game. I could be wrong since that does look like a very simplistic environment though and the PSX could handle it so long as the logic was optmised in assembler using custom routines and in house libraries. The best thing would be to contact one of the games programmers for confirmation on this.
Development Console: SCPH-5502 with 8MB RAM, MM3 Modchip, PAL 60 Colour Modification (for NTSC), DB-9 breakout headers for both RGB and Serial output and an Xplorer with CAETLA 0.34.

Development Computer: Windows 98, Pentium 3 [400MHz], 128MB SDRAM, DTL-H2000, DTL-H201A, 21" Sony Trinitron CRT, CD-ROM burner, 3.25" and 5.25" Floppy Diskette Drives and a ZIP 100 Diskette Drive.

User avatar
gwald
1997 Yaroze Enthusiast
1997 Yaroze Enthusiast
Posts: 256
Joined: September 18th, 2013, 8:44 am
I am a: programmer/DBA
PlayStation Model: Net Yaroze
Location: Australia
Contact:

Re: Question regarding "shaders" on Psx ( TR2 )

Post by gwald » April 29th, 2016, 9:25 pm

Abelliqueux wrote:Hi,

Thanks for your answers.

Although the gif doesn't reflect that, the "reflection" is in real-time, as you can see the environment moving in it.
You can see it in this video :

https://www.youtube.com/watch?feature=p ... Ojz0#t=149

It's most obvious on the second and last sword.

I have yet to find another place where this effect is used...
The PSX was developed in 1994.. before PC 3D hardware.
It's very limited in 3D power, when every clock cycle counts, reflection isn't important.
IMO, I doubt they would have a reflection feature in the engine just for 1 or 2 scenes.

The gif doesn't show the room, nor lara moving, instead it shows a static image being rotated with the sword.
To me, it looks the same on the video as well, suggesting it's a low res, stretched, static image.
There's ways of dumping the VRAM on hardware, via a memory card or to PC, if I remember correctly the VRAM remains valid after a reset, not 100%.
Shadow's tip about contacting the guys that made it is a good one, there's a few ex-PSX dev's on twitter.

@LameGuy64 The GS (net yaroze) libraries does lighting cell/vertex shading, i guess your using your own stuff?

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

Re: Question regarding "shaders" on Psx ( TR2 )

Post by Shadow » April 29th, 2016, 10:02 pm

Check the YouTube video. You can see Lara in the reflection a she approaches. I reckon it's got to be pre-rendered frames, and they have tracking in real-time to animate and shift the images as you progress. It's a pretty simplistic room setup, so I'm sure they could squeeze it in the framebuffer easily :)

You can dump the framebuffer using NO$PSX, or even using an Xplorer with the original ROM.
I'd do it, but I really don't want to sit and play up to that point in the game.
Development Console: SCPH-5502 with 8MB RAM, MM3 Modchip, PAL 60 Colour Modification (for NTSC), DB-9 breakout headers for both RGB and Serial output and an Xplorer with CAETLA 0.34.

Development Computer: Windows 98, Pentium 3 [400MHz], 128MB SDRAM, DTL-H2000, DTL-H201A, 21" Sony Trinitron CRT, CD-ROM burner, 3.25" and 5.25" Floppy Diskette Drives and a ZIP 100 Diskette Drive.

Abelliqueux
Interested PSXDEV User
Interested PSXDEV User
Posts: 7
Joined: April 29th, 2016, 7:03 am

Re: Question regarding "shaders" on Psx ( TR2 )

Post by Abelliqueux » April 29th, 2016, 10:54 pm

I realize the Psx is old hardware and has no shader language, but I think this might be a homemade reflection engine of some sort.

I remembered that you can actually see this effect in the first level of the game, just after Lara went through all sorts of moving spiked walls. You end up in a room with two rolling stones that does reflect the room. You can see it here :

https://www.youtube.com/watch?list=PLJb ... TYxc#t=616

EDIT : I've gone and made a small video available here
And some captures :
Image
Image

I confirm the switching blades you have to jump other just before that have this reflection too...
I also confirms that it's not pre-rendered, as Lara is moving in the pseudo-reflection.
It should be noted that the reflection image is not horizontally inverted, so does not look like a real reflection,
but still, the effect is impressive in this context.

So I take it from the reactions here that it is not a specific PSX hardware feature that allows for this effect ?
contact one of the games programmers
:) It would be sweet ! How would you do that ?
Last edited by Abelliqueux on April 30th, 2016, 4:18 am, edited 2 times in total.

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

Re: Question regarding "shaders" on Psx ( TR2 )

Post by Shadow » April 30th, 2016, 12:48 am

Abelliqueux wrote:
contact one of the games programmers
:) It would be sweet ! How would you do that ?
Lookup a programmer in the credits and try to find him online :)
Development Console: SCPH-5502 with 8MB RAM, MM3 Modchip, PAL 60 Colour Modification (for NTSC), DB-9 breakout headers for both RGB and Serial output and an Xplorer with CAETLA 0.34.

Development Computer: Windows 98, Pentium 3 [400MHz], 128MB SDRAM, DTL-H2000, DTL-H201A, 21" Sony Trinitron CRT, CD-ROM burner, 3.25" and 5.25" Floppy Diskette Drives and a ZIP 100 Diskette Drive.

Abelliqueux
Interested PSXDEV User
Interested PSXDEV User
Posts: 7
Joined: April 29th, 2016, 7:03 am

Re: Question regarding "shaders" on Psx ( TR2 )

Post by Abelliqueux » April 30th, 2016, 3:55 am

Ok, will try that :)

As for No$Psx, it bugs me about "invalid data in .cue file" when trying to open this particular iso so I can't view the FB...
Any other tool I can use for this ?

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

Re: Question regarding "shaders" on Psx ( TR2 )

Post by Shadow » April 30th, 2016, 4:07 am

Delete the CUE sheet and just load the ISO 'as is'.
Development Console: SCPH-5502 with 8MB RAM, MM3 Modchip, PAL 60 Colour Modification (for NTSC), DB-9 breakout headers for both RGB and Serial output and an Xplorer with CAETLA 0.34.

Development Computer: Windows 98, Pentium 3 [400MHz], 128MB SDRAM, DTL-H2000, DTL-H201A, 21" Sony Trinitron CRT, CD-ROM burner, 3.25" and 5.25" Floppy Diskette Drives and a ZIP 100 Diskette Drive.

Abelliqueux
Interested PSXDEV User
Interested PSXDEV User
Posts: 7
Joined: April 29th, 2016, 7:03 am

Re: Question regarding "shaders" on Psx ( TR2 )

Post by Abelliqueux » April 30th, 2016, 4:55 am

Well, still no luck with no$psx. This iso is the only one that seems to work, the others hang after game menu.
The beta iso opens in no$psx, but does not contain the effect.

I guess I'll have to wait till I can get access to my psx+cheap xplorer knock off in order to view the FB...

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

Re: Question regarding "shaders" on Psx ( TR2 )

Post by Shadow » April 30th, 2016, 5:35 am

You can try PSXFIN (pSX). It dumps the framebuffer too. Press F11.
It's not as good as NO$PSX, but it will do the job :)
Development Console: SCPH-5502 with 8MB RAM, MM3 Modchip, PAL 60 Colour Modification (for NTSC), DB-9 breakout headers for both RGB and Serial output and an Xplorer with CAETLA 0.34.

Development Computer: Windows 98, Pentium 3 [400MHz], 128MB SDRAM, DTL-H2000, DTL-H201A, 21" Sony Trinitron CRT, CD-ROM burner, 3.25" and 5.25" Floppy Diskette Drives and a ZIP 100 Diskette Drive.

Abelliqueux
Interested PSXDEV User
Interested PSXDEV User
Posts: 7
Joined: April 29th, 2016, 7:03 am

Re: Question regarding "shaders" on Psx ( TR2 )

Post by Abelliqueux » April 30th, 2016, 7:45 am

Well, I had a chance to look at the fb with pSX (thanks Shadow!) :

Image

Nothing much to see here... the textures are the one you can see when you rip a TR2 level file.
If it was a pre-rendered env mapping, it would appear in the fb, right ?

User avatar
gwald
1997 Yaroze Enthusiast
1997 Yaroze Enthusiast
Posts: 256
Joined: September 18th, 2013, 8:44 am
I am a: programmer/DBA
PlayStation Model: Net Yaroze
Location: Australia
Contact:

Re: Question regarding "shaders" on Psx ( TR2 )

Post by gwald » April 30th, 2016, 12:35 pm

Abelliqueux wrote: I confirm the switching blades you have to jump other just before that have this reflection too...
I also confirms that it's not pre-rendered, as Lara is moving in the pseudo-reflection.
That's a good video!
The reflection isn't correct, too me it looks like they use the VRAM (screen buffer) of the area infront of the rollers, then UV in that image.
You can tell because the reflection is lara's back and not her side.. still it's a good effect.
Your image shows lara in different positions, that must be from the previous screen buffer, which could be copied to a some bigish square texture in your VRAM image. :shrug
It looks like that because, those textures are compressed via a CLUT

I'm not sure it's the same as with the blades tho, I just saw a static image being rotated (with lara in it).

There's been a few interviews on the web/archive.org about the tombraider devs.

Abelliqueux
Interested PSXDEV User
Interested PSXDEV User
Posts: 7
Joined: April 29th, 2016, 7:03 am

Re: Question regarding "shaders" on Psx ( TR2 )

Post by Abelliqueux » May 1st, 2016, 9:06 pm

Well, no luck tracking down the programmers.
I've read some interviews, but mainly they were proud of lighting effects and Lara's ponytail...
Also, I've not checked the Android port for this effect...would be interesting to know...

As for the effect, it is actually used on every blade trap in the game. You can find some in these levels : great wall, bartoli's hideout, xian palace, tibet... I was thinking maybe even on the large fans you can encounter in the opera and oil platform level.

As for the way it's done, I'd speculate it's more straightforward than what you said gwald, as in the case of TR2, the VRAM is static once the level is loaded - i.e: Nothing moves on the VRAM visualization when playing in pSX.
I must insist that the "reflection" is dynamic in every usecase.

I've gone and uploaded some state files for epsxe if someone wants to check.
I'm using the following ISO : [PSX] [PAL-E] [SLES-00718] Tomb Raider II-original
The files go in the epsxe "sstates" folder. If you use a iso with a different SLES, you might have to rename the files.

User avatar
sicklebrick
C Programming Expert
C Programming Expert
Posts: 166
Joined: July 17th, 2013, 9:32 pm
I am a: Chocolate-fueled pug fetish robot.
Location: Scotland

Re: Question regarding "shaders" on Psx ( TR2 )

Post by sicklebrick » September 21st, 2016, 3:16 am

I think gwald's onto something here. I just tested on actual hardware. Here's the VRAM as it is normally:

Image

To the left we see both frames in the VRAM... Essentially one is drawn while the other is being created, then it's 'flipped' and the process continues (Double buffering). The drawn area is the one being sent to the screen at any particular time.


On the right (red outline) we see the Colour Lookup Table (CLUT). So instead of textures being stored as groups of RGB triples (e.g. one byte for Red, one for Green, one for Blue for each pixel)... generally a texture will just use something like 64 colours, and each of its pixels will be 'indexed' to that colour. Those colour indexes are the little swatches on the right.
The fucked up looking unrecognisable bit at the top is the actual indexed texture data, since it's not stored like a normal bitmap it's not very clear to the human eye.
I drew a dick on the stone texture though, so you can see it works. All of the colour swatches have been replaced by random solid colours to make things a little clearer too.

Image

And here are the alterations in game. So much easier to see detail/shapes.

Image

I think in a way this effect exeplifies playstation graphics - "it's crude but it works". Instead of the UV map for these things covering the indexed colour area, as you'd expect, it looks like it's just covering the actual frame area...so costs no more to render than if it were any other texture. Obviously this approach comes with its fair share of issues including the weird warping you see from some angles, the fact it renders itsself, its also likely mapped to the previous frame, the colour reproduction is a little off (see shadows), and it seems to attempt to render different bits of the screen based on viewing angle + position... but it's pretty cool - and actually very clear from the other side with textures cleaned up a bit.

You can get decently fast pixel effects on small areas but you can't operate on the VRAM as if it were a regular chunk of memory and uploading to and downloading from VRAM is kinda slow (for a full frame) and would take up a massive chunk of the main RAM.


For obvious reasons they skipped this effect on the PC because directx doesn't work the same way and seriously... would you want to be the guy in charge of compatibility acrross all of those old 1997 DOS/DirectX machines? I mean we can't even get decent compatibility on open hardware like Android a lot of the time.

Cool effect though, cheers for sharing.

Edit:

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest