[MOD] ShaderMod, glow boosts and soft shadow approximations.

The place to discuss scripting and game modifications for X4: Foundations.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

magitsu
Posts: 402
Joined: Wed, 12. Dec 18, 21:59
x4

Re: [MOD] ShaderMod, now with soft release!

Post by magitsu » Tue, 16. May 23, 12:28

Skeeter wrote:
Thu, 11. May 23, 04:47
Also whoever let characters have lighting that strong on the skin lol, that defo needs fixing how anyone can look at characters and not notice how strong light affects em and wince i dunno lol. Real ppl dont look like that with light on them.
This alone would be massive improvement. Which could be already pretty much fixed by what Jon showed in the previous post.

I want it integrated to X4. Non-shimmering npcs. But overall non-shimmering would of course be a more valuable goal.
viewtopic.php?p=5185150#p5185150

Realspace
Posts: 1372
Joined: Wed, 15. Nov 06, 10:21
x4

Re: [MOD] ShaderMod, now with soft release!

Post by Realspace » Tue, 16. May 23, 17:18

A question...even if I still was not able to start the game with these shaders of yours.
Could this mod be used to change the lighting in different parts of the game? While the light is decent for ships and interiors, the backgrounds are terribly pale, not contrasty enough. Light in space should have much more contrast, shadows stronger and light sources or reflection as stars and planets very bright. On contrary, vanilla stars are greysh, no matter the model, materials and textures I changed in my STARS mod. So I use Reshade to increase a lot the contrast. But increasing contrast everywhere is not the best solution, writings and interiors are better without to the eye, also fog is better without contrast. The backgrounds need it.
Thank you

GageDragon
Posts: 59
Joined: Tue, 26. Apr 16, 01:21
x4

Re: [MOD] ShaderMod, now with soft release!

Post by GageDragon » Tue, 16. May 23, 20:14

Have same issue as the others. Cursor changes to x4 on launch and nothing else happens. Let it sit 25 minutes and nothing. Tried installing manually and using vortex also tried renaming the cat and dat to 10 and placing them in the root folder instead with same result. X4 cursor and nothing else. Removed reshade and all other mods as well as deleting shader cache and setting graphics to low all same result.

JonMicheelsen
Posts: 33
Joined: Tue, 15. Aug 17, 22:08
xr

Re: [MOD] ShaderMod, code release!

Post by JonMicheelsen » Thu, 25. May 23, 13:40

To all of you! And sorry for the late reply was abroad for a few days, away completely form the computer! :D

Code only version! Still very WIP!
Since many have reported issues with the cat file version, here is now a code version, with a readme for install instructions. In short, something about load order got messed up, messing with the compiling causing it to either perma black screen or fail on launch. After debugging a bit with some of the Egosoft Discord users, I've decided to just do it like this for now.

Features for now:
Screen space shadows, short range near, where the vanilla shadows have gaps and far range at the distance where the vanilla shadows fade away.
Massive work on multiple fronts to reign in specular aliasing!
Various refinement of ambient occlusion.
New retroreflective diffuse model - for ambient and most analytical light types.
Skin shader with epidermal/subdermal specular and scattering approximation. Still very WIP.

Some characters may look wonk, I have yet to do a pass on all the textures, so be aware of that!
Last edited by JonMicheelsen on Sun, 4. Jun 23, 22:16, edited 1 time in total.

JonMicheelsen
Posts: 33
Joined: Tue, 15. Aug 17, 22:08
xr

Re: [MOD] ShaderMod, code release!

Post by JonMicheelsen » Sat, 27. May 23, 12:34

Now version pushed with major skin shader improvement! Still the same link: link no longer relevant

https://media.discordapp.net/attachment ... /image.png
https://media.discordapp.net/attachment ... /image.png
https://media.discordapp.net/attachment ... /image.png
https://media.discordapp.net/attachment ... /image.png
https://media.discordapp.net/attachment ... /image.png
https://media.discordapp.net/attachment ... /image.png
https://media.discordapp.net/attachment ... /image.png
https://media.discordapp.net/attachment ... 723695.png
https://media.discordapp.net/attachment ... 017748.png
https://media.discordapp.net/attachment ... /image.png
https://media.discordapp.net/attachment ... /image.png
https://media.discordapp.net/attachment ... /image.png

Good subsurface is key to anything alive looking. There is a lot of things going on here. The fancy subsurface models used by UE and Unity's HDR pipeline* is doing things I haven't figured out how to do in the X4 engine, or that I might in fact not have the needed access to be able to do. So I had to approach the same concepts differently.
When Egosoft recently updated all HDR pipeline, they upped the bit depth of a lot of buffers, that actually doesn't need it for HDR lighting - but it allows me to use "fat buffer" techniques and do things like bit packing sub surface pre scattered normals from the base pass in the same pixels that also stores the base color, giving me more diverse data to run the lighting code on. This also allows me to implement it on the forward rendered parts of the game, if I need to!
To fake the scattered color I calculate relative skin brightness - what light is not absorbed - and then combined with some relative view angle math - I use that to resample the skin textures pre blurred. With that bias I can further refine the pre scattered normals in the base pass. In short, dark skin, dark freckles, red blemishes, scars, moles, etc will absorb more light and leave less to scatter, just like the fancy models does. So while I can't add a fancy post lighting separate scatter pass, I can instead pre scatter, a bit better actually, than the old school "pre-integrated" approaches, that XR used, that caused the strong red rim glow it often had on characters.
There is available texture channels to further refine this, but I currently haven't done that yet! So it would be possible to make thin things like ears and noses or the pointiest of Teladi scales have more and the thin skin with the skull right underneath have less of the effect. This is what you would call less or more extinction of the scattering. This requires going through all the textures though! I may try to parse some RenderDoc captured character meshes into obj files, so I can bake some accurate thickness maps for this.

In addition to scattering and absorption, there is also multi layer reflections going on here, with energy conservations built into it. This effectively scatters the reflections more as the light goes through the skin. Think of it like this, the surface is smooth, with sharp reflections - like greasy skin - but a lot of light makes it through the surface down to the deeper less smooth and more opaque layers, so you get a less shiny wider scattered reflection response from the remaining light. This is extra icing on the cake of realism :stuck_out_tongue:

Currently all subsurface responses are identical. I have done some tests of different species profiles. I'll looking into bit packing some more data to refine this on a race basis. On that note, do we have access to the material definitions of characters at all, or is that currently also locked in the black box .xac files?
Subsurface species test setup https://www.shadertoy.com/view/DtcXRM
*https://advances.realtimerendering.com/ ... 202018.pdf
Last edited by JonMicheelsen on Sun, 4. Jun 23, 22:15, edited 1 time in total.

JonMicheelsen
Posts: 33
Joined: Tue, 15. Aug 17, 22:08
xr

Re: [MOD] ShaderMod, Now with proper install instructions!

Post by JonMicheelsen » Sat, 27. May 23, 20:01

Added proper install instructions to the first initial page one post and the GitHub readme, sorry for the inconvenience - I was figuring it out myself too! :P Let me know if anything is not clear now!?

Cpt.Badger
Posts: 31
Joined: Fri, 30. Dec 11, 03:17
x4

Re: [MOD] ShaderMod, Now with proper install instructions!

Post by Cpt.Badger » Mon, 29. May 23, 13:40

Thank you for this.

It does look very promising.
I was playing arond with Screen Space Shadows a bit, trying to figure out their performance impact vs the improved visual fidelity, but no conclusions yet.

My biggest gripe with X4 visuals are in fact the skin shaders.
Yours already are a vast improvement!

Looking forward for future development of this. :)

JonMicheelsen
Posts: 33
Joined: Tue, 15. Aug 17, 22:08
xr

Re: [MOD] ShaderMod, Now with proper install instructions!

Post by JonMicheelsen » Mon, 29. May 23, 17:22

Thank you!
The best way to evaluate the cost of the performance hit of the screens space shadows is to fly real close to something in direct sunlight, and have it cover the whole screen. Because the way it works, the shadows only iterate on lit things, and they only run for the main sun. So, things already fully occluded in the shadows, as well as empty backdrop space/planets, is ignored by it. There is a debug mode where you can preview it if you're really curious. Uncomment: "#define JON_MOD_SSSHADOWS_DEBUG_MODE" and "#define JON_MOD_SSSHADOWS_LIGHT_TO_DEBUG 0" In debug mode, magenta is where screen space shadows are evaluated - and only there! Green is where they cover.

Known issues: Currently the tube shaped area light are not currently working! Working on it, as well as if I can fix this artefact, that is what causes the lighting on stations to be awful in a few places. (Note there is a custom debug mode on here, that color codes the different light types) https://cdn.discordapp.com/attachments/ ... /image.png

Cpt.Badger
Posts: 31
Joined: Fri, 30. Dec 11, 03:17
x4

Re: [MOD] ShaderMod, Now with proper install instructions!

Post by Cpt.Badger » Tue, 30. May 23, 21:56

JonMicheelsen wrote:
Mon, 29. May 23, 17:22
There is a debug mode where you can preview it if you're really curious. Uncomment: "#define JON_MOD_SSSHADOWS_DEBUG_MODE" and "#define JON_MOD_SSSHADOWS_LIGHT_TO_DEBUG 0" In debug mode, magenta is where screen space shadows are evaluated - and only there! Green is where they cover.
Great to know, thanks! I will try play with this a bit when I get a more time, probably next week.
Will let you know if I find / notice anything of value.

Cheers.

JonMicheelsen
Posts: 33
Joined: Tue, 15. Aug 17, 22:08
xr

Re: [MOD] ShaderMod, Now with proper install instructions!

Post by JonMicheelsen » Tue, 30. May 23, 22:32

New big push.

Changes:
  • More refinement of subsurface scattering model; ambient term, and view dependent through-scatter.
  • envmap_probe type lighting now fully updated to use all the new features and confirmed working.
  • arealight_gen now fully updated to use all the new features and confirmed working.
  • More screenspace shadow and screenspace reflection tweaks

Cpt.Badger
Posts: 31
Joined: Fri, 30. Dec 11, 03:17
x4

Re: [MOD] ShaderMod, Now with proper install instructions!

Post by Cpt.Badger » Wed, 31. May 23, 13:17

Played around a bit with Screenspace Shadows in debug mode.

My observations are as follows:

- there is some noticeable shadows pop-in, mainly around the cone-shaped ship elements like ramp servomotors
- I can't see much visual difference with screen space shadows on or off
- there does not seem to be any measurable performance impact for those shadows, for my 3080Ti GPU (but the game is notoriously hard to benchmark anyways so can't say for sure)

Debug mode is certainly useful. :)

JonMicheelsen
Posts: 33
Joined: Tue, 15. Aug 17, 22:08
xr

Re: [MOD] ShaderMod, Now with proper install instructions!

Post by JonMicheelsen » Sun, 4. Jun 23, 22:02

New version out with lot's of improvements! Also, it has changed name to be Linux friendly(include file paths) and it works with cat/dat files now, so no need to use -prefersinglefiles anymore!!
Install instructions and new Github link in the first post on page 1

JonMicheelsen
Posts: 33
Joined: Tue, 15. Aug 17, 22:08
xr

Re: [MOD] ShaderMod, Now as cat/dat, no longer needs -prefersinglefiles

Post by JonMicheelsen » Sun, 4. Jun 23, 22:49

I was too quick to post there, if anyone downloaded already, I missed repacking the files with the new paths, sorry about that. :oops: Pushed again, link here: https://github.com/JonMicheelsen/jm_x4_shaders

GageDragon
Posts: 59
Joined: Tue, 26. Apr 16, 01:21
x4

Re: [MOD] ShaderMod, Now as cat/dat, no longer needs -prefersinglefiles

Post by GageDragon » Sun, 4. Jun 23, 23:15

Still not loading for me. Just crashes to desktop.


edit: yes it is working now after the latest push
Last edited by GageDragon on Mon, 5. Jun 23, 01:12, edited 1 time in total.

JonMicheelsen
Posts: 33
Joined: Tue, 15. Aug 17, 22:08
xr

Re: [MOD] ShaderMod, Now as cat/dat, no longer needs -prefersinglefiles

Post by JonMicheelsen » Mon, 5. Jun 23, 00:39

Alright, I got it now, that I had non-pushed code file in the same folder, made it load those instead of the ext_01.dat ones, making it appear as working, when it wasn't. Paths in .cat file now fixed and tested, with the code files not present, and it's pushed!

JonMicheelsen
Posts: 33
Joined: Tue, 15. Aug 17, 22:08
xr

Re: [MOD] ShaderMod, Now as cat/dat, no longer needs -prefersinglefiles

Post by JonMicheelsen » Mon, 5. Jun 23, 15:50

A first time restart is probably needed after enabling the mod in extensions menu!

One discord user reported an artifact, that went away after restarting the game. Since the game changes shaders that are already compiled in the main menu on launch, a first time restart is recommended. It shouldn't be needed on new versions however.

Cpt.Badger
Posts: 31
Joined: Fri, 30. Dec 11, 03:17
x4

Re: [MOD] ShaderMod, Now as cat/dat, no longer needs -prefersinglefiles

Post by Cpt.Badger » Mon, 5. Jun 23, 16:49

Latest push still crashes for me, so reverted back to non-.cat version.

JonMicheelsen
Posts: 33
Joined: Tue, 15. Aug 17, 22:08
xr

Re: [MOD] ShaderMod, Now as cat/dat, no longer needs -prefersinglefiles

Post by JonMicheelsen » Mon, 5. Jun 23, 20:35

Cpt.Badger wrote:
Mon, 5. Jun 23, 16:49
Latest push still crashes for me, so reverted back to non-.cat version.
Was this the download https://github.com/JonMicheelsen/jm_x4_shaders? And, does your folder structure look exactly like this? ...\X4 Foundations\extensions\jm_x4_shaders\"cat/dat files here" If not, it needs too, since the shader includes wont work otherwise. Everyone else on Discord have reported it works fine now.

Cpt.Badger
Posts: 31
Joined: Fri, 30. Dec 11, 03:17
x4

Re: [MOD] ShaderMod, Now as cat/dat, no longer needs -prefersinglefiles

Post by Cpt.Badger » Tue, 6. Jun 23, 16:58

JonMicheelsen wrote:
Mon, 5. Jun 23, 20:35
Cpt.Badger wrote:
Mon, 5. Jun 23, 16:49
Latest push still crashes for me, so reverted back to non-.cat version.
Was this the download https://github.com/JonMicheelsen/jm_x4_shaders? And, does your folder structure look exactly like this? ...\X4 Foundations\extensions\jm_x4_shaders\"cat/dat files here" If not, it needs too, since the shader includes wont work otherwise. Everyone else on Discord have reported it works fine now.
Yes to both.
I think the issue might be that I'm using Reshade for Vulkan and it's a conflict.

JonMicheelsen
Posts: 33
Joined: Tue, 15. Aug 17, 22:08
xr

Re: [MOD] ShaderMod, Now as cat/dat, no longer needs -prefersinglefiles

Post by JonMicheelsen » Tue, 6. Jun 23, 19:06

I think the issue might be that I'm using Reshade for Vulkan and it's a conflict.
Ah, yeah that could probably go wrong. I've personally never used Reshade, but I could imagine that it would cause trouble. I'm also bit packing some of the render buffers to carry more data than what Egosoft use them for, so if Reshade where to use any of those it would probably break pretty badly without my code unpacking them. I'm curious though, what are you using Reshade for in the game?

Post Reply

Return to “X4: Foundations - Scripts and Modding”