LostArtefacts / TRX

Open source re-implementation of Tomb Raider I and Tomb Raider II, along with additional enhancements and bugfixes
https://lostartefacts.dev/
GNU General Public License v3.0
588 stars 38 forks source link

Add reflections (PS1) #1628

Open Richard-L opened 1 year ago

Richard-L commented 1 year ago

Reflective items:

Arsunt had an article on this: https://www.tombraiderforums.com/showthread.php?t=226585

Preparing the article about all of it. Here is a "teaser" for you. It's about how TR reflection UV mapping works. The square central area of the last rendered frame is taken as texture. Only the centred incircle area is used for reflection, everything beyond is never reflected. Let's suppose for now that radius of the circle is 1 and coordinates of its center is (0; 0).

For each vertex of the mesh, a view rotated normal vector is taken (vertex itself coordinate does not matter). Normal vector coordinates in the XY plane will indicate the desired point of the texture. Since the length of the normal vector is always equal to 1, and the Z coordinate is discarded, it is guaranteed to stay inside the circle.

So now the XY coordinates inside this "circle area" are in range -1..1, but for UV we want 0..1. This part is fairly simple: U = (X+1)/2; V = (Y+1)/2;

Bingo!

https://en.wikipedia.org/wiki/UV_mapping https://en.wikipedia.org/wiki/Vertex_normal

Note: Wall mounted blades occur in several levels (O_BLADE = 81): The Great Wall, Bartoli's Hideout, Barkhang Monastery, Floating Island, Temple of Xian.

Arsunt notes: "But there is a problem. It made reflective in two levels only: The Great Wall (only blade is reflective), Bartoli's Hideout (completely reflective). The developers didn't add the effect in other levels for some reason."


Resurrected screenshots and details:

It actually may just be a leftover from them trying to make the windshield reflective (?).

Arsunt:

But there is a problem. It made reflective in two levels only: The Great Wall (only blade is reflective), Bartoli's Hideout (completely reflective). The developers didn't add the effect in other levels for some reason. EmprTomb1

Richard-L commented 3 weeks ago

Edited the OP with details and ressurrected screenshots.