Author Topic: [FF7PC] Cosmos Lighting: a real-time lighting and shadow mod  (Read 22629 times)

Cosmos

  • *
  • Posts: 34
    • View Profile

   


Overview

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

Features
  • Real-time physically-based lighting
  • Real-time shadows through shadow maps
  • Field character shadows

Current limitations
  • Single directional light
-> lights direction and other parameters can now be customized per-field through config.toml file on the lighting/ folder
  • Constant ambient lighting
-> lights direction and other parameters can now be customized per-field through config.toml file on the lighting/ folder
  • Global material parameters
-> parameters can now be customized with PBR textures
  • Field Shadows only apply to floor surfaces (walkmesh)
  • No lighting or shadows in world map mode

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

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










« Last Edit: 2023-08-29 08:08:52 by Cosmos »

Cosmos

  • *
  • Posts: 34
    • View Profile
Dev Log

05/2021
  • Implemented support for PBR textures (normal map, roughness map, metalness map, AO map)
    Spoiler: show


04/2021
  • Implemented deferred draw calls for most scene models
  • Improved shadow map setup by setting frustum target to the scene AABB center
  • Implemented character field shadows by projecting 3D models into the walkmesh
    Walkmesh reference: http://wiki.ffrtt.ru/index.php?title=FF7/Field/Walkmesh
    Field camera reference: http://wiki.ffrtt.ru/index.php?title=FF7/Field/Camera_Matrix
    Spoiler: show
  • Implemented method that extrudes the walkmesh to fade out sharp shadow discontinuities
    Spoiler: show
  • Implemented field shadow fade out with distance from occluder to the walkmesh floor
    Spoiler: show
  • Added ImGui window for adjusting parameters and debugging
    Spoiler: show
  • Improved field shadows using the stencil buffer to assure that they are only drawn over the background

03/2021

Requests
« Last Edit: 2021-05-24 13:11:53 by Cosmos »

Aavock

  • *
  • Posts: 303
    • View Profile
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!
« Last Edit: 2021-04-10 16:56:18 by Aavock »

Luigi Brosse

  • *
  • Posts: 55
    • View Profile
So inpressive!

AuthenticM

  • *
  • Posts: 148
    • View Profile
Fantastic work.

It's really impressive how much of a difference it makes in battles.

Holgar

  • *
  • Posts: 7
    • View Profile
I love this so much, keep up the good work!

Kuraudo.

  • SOLDIER
  • *
  • Posts: 354
  • Maktub
    • View Profile
    • Behemoth Productions
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!

Kaldarasha

  • *
  • Posts: 2449
  • Prince of Model Editing
    • View Profile
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?

« Last Edit: 2021-04-11 16:53:55 by Kaldarasha »

Salk

  • *
  • Posts: 608
    • View Profile
I must join the others and congratulate the author.

Impressive work.

Cosmos

  • *
  • Posts: 34
    • View Profile
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.

LeonhartGR

  • *
  • Posts: 2577
  • ~Whatever...~ Enjoy life!
    • View Profile
    • LeonhartGR Productions
Amazing work mate! Well done!

Jeehan

  • *
  • Posts: 8
    • View Profile
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 !

Kuraudo.

  • SOLDIER
  • *
  • Posts: 354
  • Maktub
    • View Profile
    • Behemoth Productions
Cannot wait for this to have a beta!

Cosmos

  • *
  • Posts: 34
    • View Profile
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

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

Cosmos

  • *
  • Posts: 34
    • View Profile
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

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.
« Last Edit: 2021-05-08 16:12:21 by Cosmos »

Edentaylor001

  • *
  • Posts: 7
    • View Profile
Woooooow. That looks so beautiful. Really takes the game to another level.

Aavock

  • *
  • Posts: 303
    • View Profile
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!

Kuraudo.

  • SOLDIER
  • *
  • Posts: 354
  • Maktub
    • View Profile
    • Behemoth Productions
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.

Tsetra

  • *
  • Posts: 329
    • View Profile
Wow, this is huge! Well done!

Cosmos

  • *
  • Posts: 34
    • View Profile
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.


AuthenticM

  • *
  • Posts: 148
    • View Profile
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.



That's super cool! Keep up the great work, man.

Cosmos

  • *
  • Posts: 34
    • View Profile
The PBR textures must be created by combining them into a single texture as in the example below.



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

Salk

  • *
  • Posts: 608
    • View Profile
Amzing... Thanks, Cosmos!

Kuraudo.

  • SOLDIER
  • *
  • Posts: 354
  • Maktub
    • View Profile
    • Behemoth Productions
Super!!! Thank you Cosmos for this amazing news. Just unbelievable.

AuthenticM

  • *
  • Posts: 148
    • View Profile
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!