Qhimm.com Forums

Final Fantasy 7 => Graphics => Releases => Topic started by: Cosmos on 2021-04-10 16:27:54

Title: [FF7PC] Cosmos Lighting: a real-time lighting and shadow mod
Post by: Cosmos on 2021-04-10 16:27:54
(https://i.imgur.com/9emnVZr.png)

(https://i.imgur.com/wBVgIwv.gif)    (https://i.imgur.com/CMjQpcr.gif)


Overview

Cosmos Lighting is a FFNx mod that adds real-time lighting and shadows to the PC version of FFVII.

Features

Current limitations
-> lights direction and other parameters can now be customized per-field through config.toml file on the lighting/ folder
-> lights direction and other parameters can now be customized per-field through config.toml file on the lighting/ folder
-> parameters can now be customized with PBR textures

Download

The first version of this mod has been integrated into FFNx. You can try it with the latest FFNx canary build.
https://github.com/julianxhokaxhiu/FFNx/releases/tag/canary

Please enable lighting in the FFNx.toml settings file. Enable the FFNx DevTools if you want to play with parameters such as light direction and color.

For modders

Here is a script to convert PBR textures to the format expected by FFNx.
https://forums.qhimm.com/index.php?topic=20670.0 (https://forums.qhimm.com/index.php?topic=20670.0)

Credits

Thanks to everyone involved into making FFNx, specially its main contributors Aali and TrueOdin.
This mod would not be possible without their awesome work!

Screenshots

Spoiler: show
(https://i.imgur.com/s3TtjYy.png)(https://i.imgur.com/9bFNptk.png)
(https://i.imgur.com/2g446Y9.png)(https://i.imgur.com/cmW5WFn.png)
(https://i.imgur.com/01v4buq.png)(https://i.imgur.com/xcSkKmN.png)
(https://i.imgur.com/aePwvnr.png)(https://i.imgur.com/9uPRzko.png)
(https://i.imgur.com/tTRDCNp.png)(https://i.imgur.com/PjTm9f8.png)
(https://i.imgur.com/XbLdLiR.png)(https://i.imgur.com/bc4uKJu.png)
(https://i.imgur.com/rAy820X.png)(https://i.imgur.com/xZUo5Se.png)
(https://i.imgur.com/kwagcpR.png)(https://i.imgur.com/M2Pv58d.png)
(https://i.imgur.com/rU121vK.png)(https://i.imgur.com/Y4jgPSR.png)
(https://i.imgur.com/BSPltWp.png)(https://i.imgur.com/3OzukF4.png)
Title: Re: [FF7PC] Cosmos Lighting: a real-time lighting and shadow mod (WIP)
Post by: Cosmos on 2021-04-10 16:28:42
Dev Log

05/2021


04/2021

03/2021

Requests
Title: Re: [FF7PC] Cosmos Lighting: a real-time lighting and shadow mod (WIP)
Post by: Aavock on 2021-04-10 16:49:25
Impressive work Cosmos! It gives a massive rejuvenation boost look to it especially combined with ninostyle's models.

 I'm a little concerned about the source of light but this will definitely be quite interesting to test. Thanks a lot for your contribution!
Title: Re: [FF7PC] Cosmos Lighting: a real-time lighting and shadow mod (WIP)
Post by: Luigi Brosse on 2021-04-10 20:05:07
So inpressive!
Title: Re: [FF7PC] Cosmos Lighting: a real-time lighting and shadow mod (WIP)
Post by: AuthenticM on 2021-04-10 20:08:38
Fantastic work.

It's really impressive how much of a difference it makes in battles.
Title: Re: [FF7PC] Cosmos Lighting: a real-time lighting and shadow mod (WIP)
Post by: Holgar on 2021-04-10 22:15:45
I love this so much, keep up the good work!
Title: Re: [FF7PC] Cosmos Lighting: a real-time lighting and shadow mod (WIP)
Post by: Kuraudo. on 2021-04-10 22:35:32
It's literally jaw-dropping. That's generation-skipping stuff.

It looks so good! Very excited for this mod Cosmos, thanks for making this happen!
Title: Re: [FF7PC] Cosmos Lighting: a real-time lighting and shadow mod (WIP)
Post by: Kaldarasha on 2021-04-11 13:05:58
That's super impressive work!

When you are done with it, I have a few ideas which could need your magic hands.

The light layer effect could be probably better simulated through shaders. TrueOdin has implemented a way to allow upscaled textures to be compatible with the games fading technique but in certain situations it just kills performance. Aali himself said a long time ago that this has to be solved through shaders.

Blending of 3D models could need a different look. Currently the game makes all faces transparent, so you see the whole meshes. I think that it would look better in any situation (when summoning, in the temple of the ancients) if only what you see gets transparent.

Reflections and refraction of surfaces. This would be just a tiny nice detail. Reflections would be seen on the floor in Shinra HQ. It would need a mask to define which part is reflective and which not. Maybe an extra image for the mask? Similar would be refraction effects. Maybe the elevator in Shinra HQ, but for sure the glass like thing in the Forgotten City in the screen before you meet Aerith and the broken glass dome over her.

Emission on magic effects. This could be particular hard to get it working correctly. I could imangine that a condition to determine if an effect emits light, could be if an effect has some transparency or not. Another solution could be to make it for external textures only and having a flag on them (like an _EXY_ in the name, where XY would be a number between 1 and 100 and setting the strength of the emission).

That are just some ideas and I hope you pick some up.

Btw. do you know if skinned meshes are possible through shaders?

Title: Re: [FF7PC] Cosmos Lighting: a real-time lighting and shadow mod (WIP)
Post by: Salk on 2021-04-11 15:03:44
I must join the others and congratulate the author.

Impressive work.
Title: Re: [FF7PC] Cosmos Lighting: a real-time lighting and shadow mod (WIP)
Post by: Cosmos on 2021-04-13 11:47:06
Thank you, I'm glad you guys like it!

I'm a little concerned about the source of light but this will definitely be quite interesting to test. Thanks a lot for your contribution!
Right now there is only one single directional light but it should not be too difficult to add support for point/spot lights. I think it would be cool to be able to save parameters such as light direction and color to some file format so that it can be customized per field/battle scene. I also read about the game already having some kind of lights (point lights?), so maybe we can use those because implementing a way to manually place lights would be a lot of work I think.

The light layer
Blending of 3D models
Reflections and refraction of surfaces.
Emission on magic effects.

Btw. do you know if skinned meshes are possible through shaders?

Thank you for the suggestions. I think I will currently focus on finishing the lighting mod but maybe once I finish I may see if I can help on those.

I am not sure what you mean with the "light layer", can you explain this? (I bought the game like a month ago but I haven't actually played it that much lol)
About blending of 3D models, I suppose that the problem is seeing back faces when doing alpha blending. A possible solution is using dither transparency if you don't mind the dither pattern.
About reflections, that would be cool but as you say it would require a way to specify what regions of the walkmesh are reflective.
About emissive magic effects, maybe a solution would be using HDR dds textures so that the effects have already the emission value in the texture. This would also probably need bloom and tone mapping post-effects.
About skinned meshes, do you mean doing the bone calculations on shader instead of doing them on the CPU? If that's the case I think it could be done.
Or maybe you mean using smooth skinned meshes, that would be difficult I think because the game seems to only support rigid skinning.
Title: Re: [FF7PC] Cosmos Lighting: a real-time lighting and shadow mod (WIP)
Post by: LeonhartGR on 2021-04-20 04:19:49
Amazing work mate! Well done!
Title: Re: [FF7PC] Cosmos Lighting: a real-time lighting and shadow mod (WIP)
Post by: Jeehan on 2021-04-30 14:46:54
Could we have a little update on the progress of the project please?  I find it incredible, but I can't imagine how much work it is! Is it a very complicated project to realize?

This is amazing !
Title: Re: [FF7PC] Cosmos Lighting: a real-time lighting and shadow mod (WIP)
Post by: Kuraudo. on 2021-05-04 20:42:30
Cannot wait for this to have a beta!
Title: Re: [FF7PC] Cosmos Lighting: a real-time lighting and shadow mod (WIP)
Post by: Cosmos on 2021-05-05 00:13:13
Could we have a little update on the progress of the project please?  I find it incredible, but I can't imagine how much work it is! Is it a very complicated project to realize?

This is amazing !

Thank you for the kind words. Actually the PR has just been approved on GitHub so probably will be merged soon.  I'll update the topic as soon as a Canary build is release.
https://github.com/julianxhokaxhiu/FFNx/pull/227 (https://github.com/julianxhokaxhiu/FFNx/pull/227)

About the complexity of the project, as you can see in the PR above, it's almost 3000 lines of code and there is still a lot that could be improved lol
Title: Re: [FF7PC] Cosmos Lighting: a real-time lighting and shadow mod
Post by: Cosmos on 2021-05-08 11:56:29
The first version has been integrated into FFNx!

You can try it with FFNx v1.9.0.7 canary build.
[https://github.com/julianxhokaxhiu/FFNx/releases/tag/canary (http://[https://github.com/julianxhokaxhiu/FFNx/releases/tag/canary)

Please enable lighting in the FFNx.toml settings file.
Also, enable the FFNx DevTools for playing with parameters such as light direction and color.

Hope you guys like it!

It would be great if a moderator moves this topic to the Release section, thank you.
Title: Re: [FF7PC] Cosmos Lighting: a real-time lighting and shadow mod
Post by: Edentaylor001 on 2021-05-08 19:31:05
Woooooow. That looks so beautiful. Really takes the game to another level.
Title: Re: [FF7PC][TSUNAMODS] Cosmos Lighting: a real-time lighting and shadow mod
Post by: Aavock on 2021-05-09 23:53:41
Definitely a must have from now on, outstanding job Cosmos! It makes all 3D models blends with the 2D backgrounds and makes the game overall more immersive.

Sometimes (and depending on the zone) the shadows feels too pronounced but I guess this will be more balanced in the future.

Keep the great work!
Title: Re: [FF7PC][TSUNAMODS] Cosmos Lighting: a real-time lighting and shadow mod
Post by: Kuraudo. on 2021-05-10 18:49:29
I just pop in to say this is a great achievement, congratulations Cosmos!

This is game changing.

This also demonstrates the thousands of possibilities that open up when more people collaborate together, in fact I can only see more great things coming out of this.
Title: Re: [FF7PC][TSUNAMODS] Cosmos Lighting: a real-time lighting and shadow mod
Post by: Tsetra on 2021-05-22 18:29:49
Wow, this is huge! Well done!
Title: Re: [FF7PC][TSUNAMODS] Cosmos Lighting: a real-time lighting and shadow mod
Post by: Cosmos on 2021-05-24 13:04:46
New lighting feature incoming!

I implemented support for PBR textures such as normal map, roughness map, metalness map and AO map!
There is still no environment map but that is next in my list.

(https://i.imgur.com/d1k3sqU.gif)
Title: Re: [FF7PC][TSUNAMODS] Cosmos Lighting: a real-time lighting and shadow mod
Post by: AuthenticM on 2021-05-25 04:45:09
New lighting feature incoming!

I implemented support for PBR textures such as normal map, roughness map, metalness map and AO map!
There is still no environment map but that is next in my list.

(https://i.imgur.com/d1k3sqU.gif)

That's super cool! Keep up the great work, man.
Title: Re: [FF7PC][TSUNAMODS] Cosmos Lighting: a real-time lighting and shadow mod
Post by: Cosmos on 2021-05-25 13:32:19
The PBR textures must be created by combining them into a single texture as in the example below.

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

I created a script to automatically batch convert an entire folder of textures. See link below for details.
http://forums.qhimm.com/index.php?topic=20670.0 (http://forums.qhimm.com/index.php?topic=20670.0)
Title: Re: [FF7PC][TSUNAMODS] Cosmos Lighting: a real-time lighting and shadow mod
Post by: Salk on 2021-05-27 05:44:49
Amzing... Thanks, Cosmos!
Title: Re: [FF7PC][TSUNAMODS] Cosmos Lighting: a real-time lighting and shadow mod
Post by: Kuraudo. on 2021-05-27 21:27:30
Super!!! Thank you Cosmos for this amazing news. Just unbelievable.
Title: Re: [FF7PC][TSUNAMODS] Cosmos Lighting: a real-time lighting and shadow mod
Post by: AuthenticM on 2021-06-02 13:54:02
Please enable lighting in the FFNx.toml settings file. Enable the FFNx DevTools if you want to play with parameters such as light direction and color.

Hey, I need a little noob help with this. I enabled the devtools (by switching the value to "true"), but nothing happens when I press F12 on my keyboard, other than putting notepad in fullscreen. What am I missing?

Thank you!
Title: Re: [FF7PC][TSUNAMODS] Cosmos Lighting: a real-time lighting and shadow mod
Post by: Xezcente on 2021-06-04 01:48:03
I'm just gonna echo the sentiments of everyone when I say that this looks great! Thank you. Definitely a must have from now on.
Title: Re: [FF7PC][TSUNAMODS] Cosmos Lighting: a real-time lighting and shadow mod
Post by: Cosmos on 2021-06-05 08:39:40
Hey, I need a little noob help with this. I enabled the devtools (by switching the value to "true"), but nothing happens when I press F12 on my keyboard, other than putting notepad in fullscreen. What am I missing?

Thank you!

Once you set the devtools to "true" and save you should see the debug menu in the game window as in the screenshot below.

(https://i.imgur.com/74BuKlI.png)

Then choose "Tools" -> "Lighting Debug" and you'll get the lighting debug options.

By the way, execute the game in windowed mode because at least in my case I cannot get the mouse to show in fullscreen mode.
Also, the "F12" shortcut is to toggle on and off the debug menu from the game window, not from notepad lol
Title: Re: [FF7PC][TSUNAMODS] Cosmos Lighting: a real-time lighting and shadow mod
Post by: AuthenticM on 2021-06-05 14:16:41
Also, the "F12" shortcut is to toggle on and off the debug menu from the game window, not from notepad lol

lmfao. Thank you.

So from reading further, this F12 debug menu seems to be used to modify the lighting feature in various ways, and not to activate or deactivate it, correct? It feels like the FFNx.toml file is where the feature would be toggled on or off, but my issue is that I can't find anything in that file that relates to the lighting feature. I have 7th Heaven 2.3.1.0 installed, as well as the latest stable version of FFNx (obtained from the 7th Heaven General Settings menu).

Is the lighting feature only available from the "canary" channel?
Title: Re: [FF7PC][TSUNAMODS] Cosmos Lighting: a real-time lighting and shadow mod
Post by: Cosmos on 2021-06-06 08:59:44
lmfao. Thank you.

So from reading further, this F12 debug menu seems to be used to modify the lighting feature in various ways, and not to activate or deactivate it, correct? It feels like the FFNx.toml file is where the feature would be toggled on or off, but my issue is that I can't find anything in that file that relates to the lighting feature. I have 7th Heaven 2.3.1.0 installed, as well as the latest stable version of FFNx (obtained from the 7th Heaven General Settings menu).

Is the lighting feature only available from the "canary" channel?

Yes, lighting is currently only available in the canary build so please check the link in the first post if you want to try it.
Title: Re: [FF7PC][TSUNAMODS] Cosmos Lighting: a real-time lighting and shadow mod
Post by: AuthenticM on 2021-06-06 17:57:00
Yes, lighting is currently only available in the canary build so please check the link in the first post if you want to try it.

Thank you, much appreciated.
Title: Re: [FF7PC][TSUNAMODS] Cosmos Lighting: a real-time lighting and shadow mod
Post by: Lollie on 2021-07-20 04:39:50
Echoing the sentiments of everyone else here, this is a really cool mod. Very happy to see this. I hope FF7-PC can be configured/modded to take control of your lighting system, somehow!

Right now there is only one single directional light but it should not be too difficult to add support for point/spot lights. [...] I also read about the game already having some kind of lights (point lights?), so maybe we can use those because implementing a way to manually place lights would be a lot of work I think.
So.. I've asked about FF7's lighting before, and I ended up doing some testing over this weekend. What I found is that the way lighting works in FF7 isn't quite like you'd expect.

Here's a huge post with what I was able to figure out about lighting in FF7 (https://forums.qhimm.com/index.php?topic=20540.msg285477#msg285477).

The short version is: Field models have one ambient color and three lighting channels, each with three axes. Each channel controls light intensity on a specific axis (it accepts positive and negative values, where "0" is the center of the range and represents zero strength), and then the actual light direction is determined based on the values of the three axes. Lights are local to each model. An NPC can move around, and their lighting will follow their position — but lighting on FF7-PC is affected by model rotation.

(https://i.imgur.com/B9OJuwm.png)
(https://i.imgur.com/X1aL5qh.png)

However, the way lighting is processed in FF7-PC is broken. The correct lighting data is still in the game, and it looks correct when the first lighting channel is isolated. But as far as I can tell, the PC version may be displaying *too much* lighting information, or maybe isn't blending the lighting correctly. (Model textures also don't receive lighting correctly. The most simple fix is for their brightness to be multiplied by 2 via shader.)

Unfortunately (or fortunately, if you want a clean slate to work with), there are no point lights in any of the scenes. There are foreground layers that are blended additively, but that's about it.
Title: Re: [FF7PC][TSUNAMODS] Cosmos Lighting: a real-time lighting and shadow mod
Post by: Kaldarasha on 2021-07-20 13:17:58
The light on PSX is backed on the models (to save computing time and memory) and the yxz calculation is different. The values don't seem to be displayed correctly on PC compared to PSX. You can see the wrong behavior on the worldmap on some 3D models like towns.
Title: Re: [FF7PC][TSUNAMODS] Cosmos Lighting: a real-time lighting and shadow mod
Post by: Cosmos on 2021-07-21 01:49:48
Echoing the sentiments of everyone else here, this is a really cool mod. Very happy to see this. I hope FF7-PC can be configured/modded to take control of your lighting system, somehow!

Thank you, I am glad you like it. About being able to configure the lighting settings, yes I will implement this in the future. But I won't do it until all parameters in the lighting settings are finalized. This is because I don't want anyone to start doing the hard work of customizing it for each field/battle and then have a change that breaks compatibility.


So.. I've asked about FF7's lighting before, and I ended up doing some testing over this weekend. What I found is that the way lighting works in FF7 isn't quite like you'd expect.

Here's a huge post with what I was able to figure out about lighting in FF7 (https://forums.qhimm.com/index.php?topic=20540.msg285477#msg285477).

Thank you for this info.

Actually I did look into this light data like a month ago but was totally confused on how to use it. If I understand correctly this is like having 3 directional lights, each one having its direction along each of the X, Y, Z axis. I suppose that this is a very rough way to imitate global illumination instead of just having a constant ambient color that would look flat. This a very ad-hoc way of doing lighting so I am not really interested on replicating this way of doing lighting. This is not how lighting is done in modern games so I think we would do much better if we don't use this data at all. For indirect lighting, I am working on implementing Image Base Lighting( IBL) / environment maps.
Title: Re: [FF7PC][TSUNAMODS] Cosmos Lighting: a real-time lighting and shadow mod
Post by: Lollie on 2021-07-21 05:36:55
If I understand correctly this is like having 3 directional lights, each one having its direction along each of the X, Y, Z axis. I suppose that this is a very rough way to imitate global illumination instead of just having a constant ambient color that would look flat. This a very ad-hoc way of doing lighting so I am not really interested on replicating this way of doing lighting. This is not how lighting is done in modern games so I think we would do much better if we don't use this data at all.
You understand it correctly! And honestly, considering the way you're doing lighting with this mod, I think ignoring this data will probably be the right call overall.

That said, I can think of one way to use the data. If you look at the first field model in a scene, and only use that model's *first* lighting channel, you might be able to use the first channel's values as the lighting direction for the scene's global light. It could be good as a starting point at least, and then lighting direction could be fine-tuned later. I have a suspicion that the first lighting channel is the only one that's actually important in most scenes.

For indirect lighting, I am working on implementing Image Base Lighting( IBL) / environment maps.
That'll be very cool, that's exciting. Wishing you good luck!
Title: Re: [FF7PC][TSUNAMODS] Cosmos Lighting: a real-time lighting and shadow mod
Post by: olearyf2525 on 2021-07-21 17:09:01
New lighting feature incoming!

I implemented support for PBR textures such as normal map, roughness map, metalness map and AO map!
There is still no environment map but that is next in my list.

(https://i.imgur.com/d1k3sqU.gif)

Beautiful work Cosmos. Have you seen this topic?
https://forums.qhimm.com/index.php?topic=20540.0;topicseen
Title: Re: [FF7PC][TSUNAMODS] Cosmos Lighting: a real-time lighting and shadow mod
Post by: Kuraudo. on 2021-07-23 19:47:20
Just wanna say Everytime I pop in this topic there is some new stuff out of this planet.

Keep it up Cosmos! It's fantastic.
Title: Re: [FF7PC][TSUNAMODS] Cosmos Lighting: a real-time lighting and shadow mod
Post by: Cosmos on 2021-07-31 07:36:30
Beautiful work Cosmos. Have you seen this topic?
https://forums.qhimm.com/index.php?topic=20540.0;topicseen
Yes, I replied to the author of that topic just a little above your comment.
Title: Re: [FF7PC] Cosmos Lighting: a real-time lighting and shadow mod
Post by: WolfMan on 2021-08-16 23:41:17
I like these models. Where do I find them?
Title: Re: [FF7PC] Cosmos Lighting: a real-time lighting and shadow mod
Post by: Chrysalis on 2021-08-18 01:13:29
It looks really awesome, I am really looking forward to playing the game with this on when its complete.
Title: Re: [FF7PC] Cosmos Lighting: a real-time lighting and shadow mod
Post by: Cosmos on 2021-09-01 13:38:12
I like these models. Where do I find them?

You can download them here: https://www.nexusmods.com/finalfantasy7/mods/4?tab=files
Title: Re: [FF7PC] Cosmos Lighting: a real-time lighting and shadow mod
Post by: Kuraudo. on 2021-09-08 22:34:15
Great, can't wait to see more!
Title: Re: [FF7PC] Cosmos Lighting: a real-time lighting and shadow mod
Post by: Kuraudo. on 2022-12-14 17:25:53
Excited for Image Base Lighting (IBL) / environment maps feature, can't imagine how awesome it will look. Also, the "Save light parameters per scene", could be an helpful super tool for mod purpose.

PS: FYI Bahamut Zero and Supernova are glitched atm. [SOLVED] (https://github.com/julianxhokaxhiu/FFNx/pull/603)