www.tombraiderforums.com  

Go Back   www.tombraiderforums.com > Tomb Raider Series > Tomb Raider II

Reply
 
Thread Tools
Old 09-09-21, 07:43   #1
Arsunt
Historian
 
Arsunt's Avatar
 
Join Date: Jan 2010
Location: Russia
Posts: 354
Lightbulb Tomb Raider Reflection Effect: How it works

Hi people! It seems that there is one topic that I have been asked to talk about for a long time - the graphic effect of reflection in the classic Tomb Raider games on PS1. As always all pictures are clickable.

All you may need to know is a very basic understanding of:
Tomb Raider I

In TR1, this effect could be seen on save crystals — they had a mirror-like surface with a blue hue. Also, the reflection was used when Lara died in the hand of Midas — she turned into a golden statue.



Save crystal is a single 3D mesh, but Lara had several meshes, such as a foot, hand, head or torso. The meshes that were supposed to become reflective were set in the program code very simply — when a certain mesh was rendered, it was marked with a reflection flag and a tint colour was set for it. Colour for golden Lara was #A09860, and colour for a save crystal was #4040FF. All such cases were hardcoded.

If mesh was marked as reflective it used special environment map texture tinted with given colour instead of it's own textures. In simple words this reflection texture was a screenshot that has been cropped in such a way that a central square part left with a side equal to the height of the screen.

However, to be compatible with reflections, there is an additional requirement for the mesh; a set of vertex normals has to be specified for it. Vertex normals are used for proper lighting calculation, but in the case of reflections they get a double function. Bad news is that some meshes don't have them because of simplified lighting, normally it's static meshes or room geometry. Good news is that vertex normals have already been calculated by the level editor and they are definitely presented for save crystal and all Lara's meshes.


Tomb Raider II

In TR2, tinted reflection was left only for Golden Lara in PS1 Dozy mode (flying cheat mode that could be enabled via patching script file). The original gold colour #A09860 is inherited from TR1. The problem is Midas room walls are orange tinted and bright, and reflection looks nice. But for most TR2 rooms it's not. So to compensate all of this and to make gold more sweet in any room I used a different tint colour for TR2Main — #FFC040.



The format of PS1 level file has been changed for TR2. Each mesh, in addition to the usual set of textured polygons, could be given an additional set of reflective polygons, so there were objects with meshes that reflect partially. The reflection effect were not hardcoded anymore, except golden Lara in Dozy mode. Alas such reflective polygons data was not supported by PC level file format.

All common reflection effects had no tint, and the original mesh texture was not completely replaced with the reflection texture as it was in TR1, but the reflection texture was overlaid on top of the normal texture with 50% opacity. If you played PS1 version you remember this effect on traps: rolling wheel blades, wall mounted blades, deadly statues with swords.



But you probably missed a reflective effect on Boathouse Key (Venice) and Library Key (Bartoli's Hideout), as well as a mask of flamethrower guy.



There was even one small reflective polygon under windshield of the fast snowmobile. It was certainly leftover bug, so I did not port it to TR2Main. But instead I decided to add one more reflective thing into TR2Main that was absent in PS1 version — windshield of the armed snowmobile. Just compare screenshots, I bet Core Design intended to make this reflective in 1997, but they did not because of possible performance issues.




But how it works?

Vertex normals have already been calculated by the level editor and they are presented for all meshes that supposed to be reflective.

The screenshot can be taken in one of few ways.
  • Take it from the back-buffer every time when we need to draw a reflective polygon (this is what PS1 does), but in this case only objects behind the polygon are reflected. This is because on PS1 polygons are drawn in order from furthest to nearest, so closer polygons overlap those farther away. Apart from possible graphical artefacts, this method has a significant drawback, it can be very slow.
  • Just keep a copy of the fully rendered previous frame (this is what TR2Main does). And since a frame is copied directly into video memory, without transferring it to RAM, this method is damn fast and runs once per frame.
Let's summarise. For the reflection effect we have vertex normals and a slightly cropped screenshot. But how are they related to each other? Before we continue, please watch this short video, you will understand everything without any explanations.



  1. There are vertex normals and the environment map texture.



  2. Put all vertex normals in the center of the texture and scale them to fit texture's height.




  3. Connect UV coordinates pointed by vertex normals.




  4. Wrap the mesh in a texture with 50% opacity using UV specified coordinates.


  5. Done!

You may notice that only incircle part of square texture is used, corners are unused. To confirm this, we can run a funny experiment. Instead of an environment map texture let's take this texture with a rainbow radial gradient and some hatch outside the circle. Also we change it's opacity to 100%.







We can see a rainbow, but no sign of a hatched part. Also by colour you can find vertex normal.


Thanks for reading!

Hope you enjoyed this article. If you still have questions on this and other topics, feel free to ask. I will be happy to answer.
__________________
To seek. To learn. To do. (C) Quest for Glory

Last edited by Arsunt; 09-09-21 at 16:22.
Arsunt is offline   Reply With Quote
Old 09-09-21, 08:29   #2
Heartache
Professor
 
Heartache's Avatar
 
Join Date: Dec 2008
Posts: 3,334
Default

thank you so much for this. youre doing such an astounding job on these old games
__________________
Hi, I'm Marissa. I'm super excited to take trf's look to the next level.
Heartache is offline   Reply With Quote
Old 09-09-21, 13:15   #3
tlr online
Administrator
 
tlr online's Avatar
 
Join Date: Jun 2000
Posts: 59,502
Thumbs up

Thank you very much for posting your work Arsunt.
tlr online is online now   Reply With Quote
Old 09-09-21, 14:56   #4
ANoDE
Golden
 
ANoDE's Avatar
 
Join Date: May 2005
Location: Austria
Posts: 6,282
Default

Thanks for the detailed descriptipn of the process, and thanks for pringing TR2 back to life!
__________________
🎶 ~ Help me leave behind some reasons to be missed ~ 🎶
ANoDE is offline   Reply With Quote
Old 09-09-21, 20:31   #5
GFY2013
Archaeologist
 
GFY2013's Avatar
 
Join Date: Jun 2013
Location: not far enough
Posts: 1,586
Default

Thanks for the explanation, neat!
__________________
we're all clowns
GFY2013 is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 12:37.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.