Qhimm.com Forums

Final Fantasy 7 => General Discussion => Topic started by: Lollie on 2021-02-19 11:26:25

Title: [FF7PC] Are there any mods that fix the PC port's broken lighting?
Post by: Lollie on 2021-02-19 11:26:25
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 (https://forums.qhimm.com/index.php?topic=20540.msg285477#msg285477)!

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) (https://imgur.com/a/TOLqYMm)
(https://i.imgur.com/luPvAbW.jpg)
(https://i.imgur.com/nPtcRoB.jpg)
Title: Re: [FF7PC] Are there any mods that fix the PC port's broken lighting?
Post by: Kuraudo. on 2021-02-22 05:38:04
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.
Title: Re: [FF7PC] Are there any mods that fix the PC port's broken lighting?
Post by: Fewtch on 2021-02-23 05:08:28
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.  ???
Title: Re: [FF7PC] Are there any mods that fix the PC port's broken lighting?
Post by: Kuraudo. on 2021-02-23 06:06:32
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 (http://forums.qhimm.com/index.php?topic=20612.0)
Title: Re: [FF7PC] Are there any mods that fix the PC port's broken lighting?
Post by: Kaldarasha on 2021-02-23 08:07:23
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.
Title: Re: [FF7PC] Are there any mods that fix the PC port's broken lighting?
Post by: Lollie on 2021-02-23 13:36:26
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 (https://docs.google.com/spreadsheets/d/1DUjmyW94zcYoX7gIW5yAT4giTPeNmCR4TCaHAiXOLlU/edit#gid=235822118&range=A172:F172) 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 (http://forums.qhimm.com/index.php?topic=9658.0) can't currently edit which models appear per field in FF7-PS1, so I don't know how to test this theory..
Title: Re: [FF7PC] Are there any mods that fix the PC port's broken lighting?
Post by: Kaldarasha on 2021-04-07 17:23:24
In other news someone is working on light with a new approach with amazing results.
Title: Re: [FF7PC] Are there any mods that fix the PC port's broken lighting?
Post by: Kuraudo. on 2021-04-10 17:55:09
Here you can found the new mod now available: Cosmos Lighting (http://forums.qhimm.com/index.php?topic=20612.0)
Title: Re: [FF7PC] Are there any mods that fix the PC port's broken lighting?
Post by: Lollie on 2021-07-19 10:02:11
Here you can found the new mod soon to be available: Cosmos Lighting (http://forums.qhimm.com/index.php?topic=20612.0)
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.
(https://i.imgur.com/X1aL5qh.png)

The original lighting can be found in the first lighting channel, outlined here in Makou Reactor (https://forums.qhimm.com/index.php?topic=9658.0)'s Field Models editor.
(https://i.imgur.com/B9OJuwm.png)

By zeroing out the second and third lighting channels, the first channel can be isolated. And so we get this.
(https://i.imgur.com/EVm2J2M.png)
(https://i.imgur.com/wSTK2fJ.gif)
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.
(https://i.imgur.com/Q7XCwMU.jpg)

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.
(https://i.imgur.com/Ls8Ovg2.png)

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.
(https://i.imgur.com/IltPelW.gif)

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.
(https://i.imgur.com/twU8mGr.gif)

...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.
Title: Re: [FF7PC] Are there any mods that fix the PC port's broken lighting?
Post by: Sega Chief on 2021-07-21 15:30:04
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):

(https://i.imgur.com/v5BMPVY.png)
Title: Re: [FF7PC] Are there any mods that fix the PC port's broken lighting?
Post by: Kaldarasha on 2021-07-21 18:33:05
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.
Title: Re: [FF7PC] Are there any mods that fix the PC port's broken lighting?
Post by: Lollie on 2021-07-28 08:49:19
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.
(https://i.imgur.com/76Sv7Ml.png)
[full-res screenshot comparison via this Imgur album] (https://imgur.com/a/cxL4iCE)

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.
(https://i.imgur.com/S6zQxe5.png)
Title: Re: [FF7PC] Are there any mods that fix the PC port's broken lighting?
Post by: Kuraudo. on 2023-03-26 18:43:10
Just would like to point out the following video (https://www.youtube.com/watch?v=mMRC-joIYUE), 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.

Title: Re: [FF7PC] Are there any mods that fix the PC port's broken lighting?
Post by: Bonez on 2023-03-28 03:33:37
Is it weird I think it actually looks better on PC than PS1?
Title: Re: [FF7PC] Are there any mods that fix the PC port's broken lighting?
Post by: Kuraudo. on 2023-03-28 15:43:05
OG was meant to be displayed on CRT (https://i.gifer.com/IBlJ.gif) screen at that time, the scanline is good in hiding artifacts.

I believe it's just de gustibus: a matter of taste.
Title: Re: [FF7PC] Are there any mods that fix the PC port's broken lighting?
Post by: Lollie on 2023-04-05 05:00:31
Just would like to point out the following video (https://www.youtube.com/watch?v=mMRC-joIYUE), 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 (https://www.blackmagicdesign.com/products/intensitypro4k) 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.
Title: Re: [FF7PC] Are there any mods that fix the PC port's broken lighting?
Post by: Kuraudo. on 2023-04-11 14:56:29
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 (https://www.blackmagicdesign.com/products/intensitypro4k) 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. (https://forums.qhimm.com/index.php?topic=20612.0)

Just FYI for posterity NTSC-J mode (https://forums.qhimm.com/index.php?topic=21407.0) new FFNx feature available: reworked Movies and Game color rendering (https://github.com/julianxhokaxhiu/FFNx/pull/575). The resulting colors are more faithful to the original artistic intent

Just FYI for posterity Fix direct color (https://github.com/julianxhokaxhiu/FFNx/pull/587) new FFNx fix. Fix black color on field backgrounds.
Title: Re: [FF7PC] Are there any mods that fix the PC port's broken lighting?
Post by: playzoffs on 2023-09-13 11:44:07
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 (http://"https://krnl.fun/")
hdstreamz.uno (http://"https://hdstreamz.uno")

Title: Re: [FF7PC] Are there any mods that fix the PC port's broken lighting?
Post by: Kuraudo. on 2023-09-24 10:23:32
The aforementioned is fixed in FFNx by Cosmos (https://forums.qhimm.com/index.php?topic=20612.0), here (https://github.com/julianxhokaxhiu/FFNx/pull/607).

EDIT: Also as of now, Lollie open two new issues, here (https://github.com/julianxhokaxhiu/FFNx/issues/610) and here (https://github.com/julianxhokaxhiu/FFNx/issues/609).
Title: Re: [FF7PC] Are there any mods that fix the PC port's broken lighting?
Post by: anideind on 2024-01-20 12:03:41
I think it is more possible, that textures are unaffected by the light on the PSX to keep the stress on the hardware small.
Title: Re: [FF7PC] Are there any mods that fix the PC port's broken lighting?
Post by: kerihobo on 2024-02-01 08:58:11
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:

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

(https://i.imgur.com/N8rEiAC.png)

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)