Author Topic: [FF7PC] Are there any mods that fix the PC port's broken lighting?  (Read 16542 times)

Lollie

  • *
  • Posts: 9
    • View Profile
    • Lollie.me
Ever since the '98 Eidos port (and right up to the most recent console ports), every room in FF7 has had broken lighting. The ports light everything from the camera's position (like a camera flash), instead of using each room's lighting information. Edit: See Reply #8!

Are there any mods that fix the lighting? Or any hard info on why the lighting is broken like this?

(Imgur album with full-res comparison images)

« Last Edit: 2021-07-20 01:45:15 by Lollie »

Kuraudo.

  • SOLDIER
  • *
  • Posts: 355
  • Maktub
    • View Profile
    • Behemoth Productions
You are talking of the 3d models light in field right? That's a known issue. But I'm not sure if anything was done yet.
« Last Edit: 2021-02-23 06:47:14 by Kuraudo. »

Fewtch

  • *
  • Posts: 78
  • All good things in time
    • View Profile
    • ArtStation
Its wild that Ive never noticed this before, nor have a heard any mention of it anywhere, but there it is, impossible to miss now that I see it.  ???

Kuraudo.

  • SOLDIER
  • *
  • Posts: 355
  • Maktub
    • View Profile
    • Behemoth Productions
Anyway I did use search and these are the topics where there is some information about it:

2005: http://forums.qhimm.com/index.php?topic=4582.msg61116#msg61116
2009: http://forums.qhimm.com/index.php?topic=8896.msg116056#msg116056
2016: http://forums.qhimm.com/index.php?topic=16822.msg238245#msg238245
2016: http://forums.qhimm.com/index.php?topic=17323.msg246294#msg246294
2017: http://forums.qhimm.com/index.php?topic=17377.msg246931#msg246931

Long story short at the moment there is no mod and/or fix that adjust that behavior.

EDIT: As of now Cosmos create a mod for it, Cosmos Lighting
« Last Edit: 2021-04-10 17:54:22 by Kuraudo. »

Kaldarasha

  • *
  • Posts: 2449
  • Prince of Model Editing
    • View Profile
Its wild that Ive never noticed this before, nor have a heard any mention of it anywhere, but there it is, impossible to miss now that I see it.  ???

I have brought this up some years ago on the reunion thread. The problem is a bit difficult. The main problem is probably a difference in displaying coordinations. The PSX has some strange logic and doesn't follow the usual xyz. Though the PSX does also bake the light on the models and I can't say in what position it does that. On PC the light is applied in real time on the model.

Lollie

  • *
  • Posts: 9
    • View Profile
    • Lollie.me
2005: http://forums.qhimm.com/index.php?topic=4582.msg61116#msg61116
Wow, 2005. This thread in particular gave some decent insight into FF7's field lighting, thank you for digging it up!

I have brought this up some years ago on the reunion thread. The problem is a bit difficult. The main problem is probably a difference in displaying coordinations. The PSX has some strange logic and doesn't follow the usual xyz. Though the PSX does also bake the light on the models and I can't say in what position it does that. On PC the light is applied in real time on the model.
Ah, I saw your name in Reunion's big spreadsheet about this bug! I never realized that FF7-PS1's lighting wasn't being updated on every frame, that's a funny quirk. Thanks for the info!

After a little poking around, I have a suspicion that lighting is baked into models based on what the first available animation is for each model per field (this usually ends up being a neutral standing pose). It seems though that Makou Reactor can't currently edit which models appear per field in FF7-PS1, so I don't know how to test this theory..

Kaldarasha

  • *
  • Posts: 2449
  • Prince of Model Editing
    • View Profile
In other news someone is working on light with a new approach with amazing results.

Kuraudo.

  • SOLDIER
  • *
  • Posts: 355
  • Maktub
    • View Profile
    • Behemoth Productions
Here you can found the new mod now available: Cosmos Lighting
« Last Edit: 2021-07-31 17:57:37 by Kuraudo. »

Lollie

  • *
  • Posts: 9
    • View Profile
    • Lollie.me
Here you can found the new mod soon to be available: Cosmos Lighting
This is ridiculously cool, very promising.. Hopefully it progresses so that it can be controlled per scene, somehow!



I ended up returning to FF7PC this weekend to do some testing, and I have a better understanding of how the lighting system works. My original assumptions were totally wrong. There's no coordinates mismatch between PS1 and PC, no automatic "lit from the camera's position", none of that.

So... The correct lighting data is technically still here in the PC version. But there's something weirder going on. Here's an example from "md1stin", the very first scene in the game.


The original lighting can be found in the first lighting channel, outlined here in Makou Reactor's Field Models editor.


By zeroing out the second and third lighting channels, the first channel can be isolated. And so we get this.


Notice how the vertex lighting pinches the same way down Cloud's forehead, and down the front of his pants. Or how the gradients in his hair travel in similar directions.

Now, the lighting on PC is still noticeably darker compared to PS1. Unfortunately, Makou Reactor currently lacks the ability to edit Field Models data for FF7-PS1, so I can't test how all the lighting channels function on PS1. I don't know if the other two light channels are contributing to the lighting on PS1, or if they're supposed to be disabled, or something else.

My suspicion is that there's a value on PS1 that says which channels are active (possibly the "Unknown" value in Makou Reactor's Field Editor?). If this value exists, it is being ignored on PC, meaning FF7-PC is using all of the lighting channels instead. I don't have a way to test this though, so I can only call this a big guess. Chances are I'm totally wrong!

Another part of the lighting that's currently broken is the textures on Field Models. They're all darker than they're supposed to be. My suspicion (big fat guess! probably wrong!) is that vertex lighting isn't being applied additively to textures, and is merely tinting the textures. This means model textures never get to be brightened, only darkened. I'm unable to test this theory, but as a proof of concept, I tried multiplying the brightness of textures by adding a dirty hack to "pixel.hlsl" in FF7-PC's "shaders" folder. You can already see how much of a difference this makes.


For prosperity, here's my dirty little shader hack for "pixel.hlsl". This affects literally every single texture in the game. Model textures look better, but every background becomes blindingly bright, so it's only good for curiosity's sake.
Code: [Select]
if(texture_flag != 0)
{
if(texture_color.a == 0.0) discard;

texture_color *= 2; // dirty hack!!

color *= texture_color;
}



Finally, here's how the Field Model lighting works.


Global light is an ambient tint. It tints the entire model with a flat color, with no additional lighting.
Black (#000000) causes the model's base brightness to be a flat black, while White (#FFFFFF) causes the model to appear fully unlit. Most scenes use a Dark Gray by default (eg: #404040, #595959).

Directional light has three channels, where each channel features a Vector3, X / Y / Z.
You might think these are "position" or "rotation" values. They're more like "Strength" values? They have a 16-bit range, from -32768 to +32767, where 0 is the "OFF" value.

Edit: It's been brought to my attention, it's possible that light direction is determined via a vector dot product, and then light intensity is calculated via vector length. I'll have to do more testing later to confirm this. (end edit)

To demonstrate the basics of how Directional Light works, here is a GIF. Please enjoy this animation of Tifa stuck in the Light Box.


On PS1, directional lighting is baked into field models on a per-scene basis. A model can rotate and move as much as they like, but directional lighting will stick to the model like paint.
On PC, directional lighting reacts to model rotation. A boost in lighting features! Note: Directional lighting is local to field models, and so a model's position does not affect lighting at all.


...And that's all I've got! I hope this information is useful to... someone who knows anything about altering the inner workings of FF7-PC.
« Last Edit: 2021-07-20 10:24:58 by Lollie »

Sega Chief

  • *
  • Posts: 4086
  • These guys is sick
    • View Profile
I'm no expert on how the models/lighting etc. work but you mentioned that you were guessing that lighting wasn't being applied additively to Cloud's PC field model textures, and I think I can confirm that this is the case.

Opening Cloud's PC field model in Kimera, there are a few groups assigned to polygons to display the textures for his right eye, left eye, and mouth. They use no blending mode (where the options are Average, Additive, Substractive, Unknown, and None):


Kaldarasha

  • *
  • Posts: 2449
  • Prince of Model Editing
    • View Profile
I think it is more possible, that textures are unaffected by the light on the PSX to keep the stress on the hardware small. On PC they just didn't cared about this behavior and they probably didn't knew of it.

Lollie

  • *
  • Posts: 9
    • View Profile
    • Lollie.me
I'm no expert on how the models/lighting etc. work but you mentioned that you were guessing that lighting wasn't being applied additively to Cloud's PC field model textures, and I think I can confirm that this is the case.
I ended up doing some more poking around, and the answer might be even simpler. On PC, textures on models appear to be rendered half as bright as they're supposed to be. Like, if a vertex color has a range of 0-100%, textures on models seemingly only reach 0-50%. Doubling how bright textures render could actually be the way to fix them. It could probably be done via the "pixel.hlsl" shader file, if someone can figure out what variable FF7-PC needs in order to specifically target textures on models. (otherwise, you end up with backgrounds, menu graphics, and world-map skies being rendered too bright as a result.)

I landed on this answer while having a quick peek at the World Map, it turns out this texture brightness rendering issue affects *all* textured models. It's not the only issue, but it makes a big difference.

[full-res screenshot comparison via this Imgur album]

I think it is more possible, that textures are unaffected by the light on the PSX to keep the stress on the hardware small. On PC they just didn't cared about this behavior and they probably didn't knew of it.
Naw, PS1 could handle both vertex lighting and vertex colors on textured models without any big issues - Crash Bandicoot, Tekken 2, and Tomb Raider are all examples.

Here's a quick shot from FF7-PS1 (using a very high internal resolution in DuckStation to get a clean screenshot). You can see that the same features are darker on the more shadowed side of Cloud's face. Textures are definitely affected by field lighting in FF7-PS1.

Kuraudo.

  • SOLDIER
  • *
  • Posts: 355
  • Maktub
    • View Profile
    • Behemoth Productions
Just would like to point out the following video, we can observe that PS1 is darker compare with PC. - not valid

We should have real PS1 hardware and Steam version on the same screen, with the same settings for both inputs on the display - with all "enhancement" disabled (if to define the difference of bright/contrast/color interpolation which should be different in fact.)

And not emulated versions.

« Last Edit: 2023-07-26 17:59:21 by Kuraudo. »

Bonez

  • Cosmo Memory Dev
  • Global moderator
  • *
  • Posts: 264
  • What goes here?
    • View Profile
Is it weird I think it actually looks better on PC than PS1?

Kuraudo.

  • SOLDIER
  • *
  • Posts: 355
  • Maktub
    • View Profile
    • Behemoth Productions
OG was meant to be displayed on CRT screen at that time, the scanline is good in hiding artifacts.

I believe it's just de gustibus: a matter of taste.
« Last Edit: 2023-10-17 12:42:24 by Kuraudo. »

Lollie

  • *
  • Posts: 9
    • View Profile
    • Lollie.me
Just would like to point out the following video, we can observe that PS1 is darker compare with PC.
I'd say this is largely a result of the video capture tools used for this video. The PS1's composite video output already wasn't all that clean, and the most common capture devices of 2012 (when the video was created) were cheaper USB devices - workable, but less than ideal.

I agree though, it would be much better to test this on real hardware. I'm open to doing it too - I have a Blackmagicdesign Intensity Pro capture card available, I just have to replace my PC first. 😅



So life and work got in the way of testing, and this unfortunately fell by the wayside. However, I did come to a conclusion on what part of the PC port's lighting is broken, and in hindsight it was extremely obvious:
The broken model lighting on PC is a direct result of how the PC port updates lighting on every frame. On PS1, vertex lighting is completely static, as if it is baked onto the model when the scene is loaded into the game.

Rotate a character on the PC version, and the lighting shifts across the model the way you'd expect a light to move... except, this isn't how the lighting functions on the PS1 version. Rotate a character on the PS1 version, and the lighting sticks to the model like paint. So of course, there's no way the lighting on the PC version could ever match the PS1 version, not in its current state.

My guess is: The only way to fix the lighting on models is to find a way to freeze or disable updates to vertex lighting, the moment the scene is loaded in. Lighting needs to stick to the models like paint, and then it'll start behaving correctly on PC.
« Last Edit: 2023-04-05 14:25:06 by Lollie »

Kuraudo.

  • SOLDIER
  • *
  • Posts: 355
  • Maktub
    • View Profile
    • Behemoth Productions
I'd say this is largely a result of the video capture tools used for this video. The PS1's composite video output already wasn't all that clean, and the most common capture devices of 2012 (when the video was created) were cheaper USB devices - workable, but less than ideal.

I agree though, it would be much better to test this on real hardware. I'm open to doing it too - I have a Blackmagicdesign Intensity Pro capture card available, I just have to replace my PC first. 😅



So life and work got in the way of testing, and this unfortunately fell by the wayside. However, I did come to a conclusion on what part of the PC port's lighting is broken, and in hindsight it was extremely obvious:
The broken model lighting on PC is a direct result of how the PC port updates lighting on every frame. On PS1, vertex lighting is completely static, as if it is baked onto the model when the scene is loaded into the game.

Rotate a character on the PC version, and the lighting shifts across the model the way you'd expect a light to move... except, this isn't how the lighting functions on the PS1 version. Rotate a character on the PS1 version, and the lighting sticks to the model like paint. So of course, there's no way the lighting on the PC version could ever match the PS1 version, not in its current state.

My guess is: The only way to fix the lighting on models is to find a way to freeze or disable updates to vertex lighting, the moment the scene is loaded in. Lighting needs to stick to the models like paint, and then it'll start behaving correctly on PC.
Yes, correct. That's really cool capture card you got there! I hope to see one comparison video from your side one day, that would be awesome.

Just FYI for posterity, As per Kaldarasha: "That's partly true. It's true that psx does the calculation once, but it can also update that calculation, if the script is requesting it (ambient shader). There is actually another problem, the xyz values are differently handled logical-wise on pc and psx. The third problem - and this in regards of the difference in brightness between pc and psx - is that psx has a different colour system, which sacrifice the precision in the black and white spaces in favour of the mid tones. Then we have also the dotmask of the CRT monitors, which does also act differently on the colours. This all leads to different look between psx and pc."

It would require a lot of RE and would over-complicate the code ending up in other issues. Long story short: we can play PS1 or upgrade to 100 times better real-time lighting and shadows.

Just FYI for posterity NTSC-J mode new FFNx feature available: reworked Movies and Game color rendering. The resulting colors are more faithful to the original artistic intent

Just FYI for posterity Fix direct color new FFNx fix. Fix black color on field backgrounds.
« Last Edit: 2023-09-24 10:23:00 by Kuraudo. »

playzoffs

  • *
  • Posts: 1
    • View Profile
I'm no expert on how the models/lighting etc. work but you mentioned that you were guessing that lighting wasn't being applied additively to Cloud's PC field model textures, and I think I can confirm that this is the case.
 krnl download
hdstreamz.uno

« Last Edit: 2023-11-23 09:51:53 by playzoffs »

Kuraudo.

  • SOLDIER
  • *
  • Posts: 355
  • Maktub
    • View Profile
    • Behemoth Productions
The aforementioned is fixed in FFNx by Cosmos, here.

EDIT: Also as of now, Lollie open two new issues, here and here.
« Last Edit: 2024-01-21 10:18:37 by Kuraudo. »

anideind

  • *
  • Posts: 1
    • View Profile
I think it is more possible, that textures are unaffected by the light on the PSX to keep the stress on the hardware small.

kerihobo

  • *
  • Posts: 6
    • View Profile
I ended up returning to FF7PC this weekend to do some testing, and I have a better understanding of how the lighting system works.

Wow so much amazing info there. I am actually trying to make my own shader in Unity that will behave exactly like this for a hobby FF7 classic remake that I'm working on in my spare time. I have it working but a few functions I'm not 100% certain about as I don't get identical results.

I'm unsure about a few things:
  • the size of the lightbox
  • How all 3 channels and their axes combine (add, max?)
  • Whether Global light adds to the overall result like how typical ambient light works, or if it multiplies with vertexColor etc.
  • If min/max values are -32768/32767, then I expect values seen in MakouReactor are actually so small they should barely equate to the lightbox gradient encompassing the player at all. 3000 for example is less than 10%, that's a very un-moved lightbox, quite close to zero. Even with 3 axes on 3 separate lights (a total of 9 lights seeing as each axis is pretty much a light?). I only seem able to get a similar result by really pushing that box across, like in your Tifa GIF?

Also if the shader itself has any additional magic going on, like some classic diffuse-wrapping.



Actually I have many more questions, too many, but they could all be answered if there was some nice realtime way I could adjust those light values in the scene, alas MR doesn't preview lighting.

So I was wondering... what was your approach was for adjusting the light for the Tifa GIF? Is there some tool or other way I can use MR?

Lastly, did you come to a conclusion on this one?
Edit: It's been brought to my attention, it's possible that light direction is determined via a vector dot product, and then light intensity is calculated via vector length. I'll have to do more testing later to confirm this. (end edit)
« Last Edit: 2024-02-01 13:36:54 by kerihobo »