Hard Light Productions Forums
Modding, Mission Design, and Coding => The Modding Workshop => Topic started by: qazwsx on July 17, 2021, 03:27:52 pm
-
Link: https://fsnebula.org/mod/qaz_1 (https://fsnebula.org/mod/qaz_1)
CHANGELOG
2021-09-14: Anti-glitter shader tweak has been accepted by the SCP, the next release of FSO will include it by default
Version 0.2.0
Added new shader designed to reduce specular glinting/shimmering on distant ships.
This is based off a 2015 GDC talk by valve (slides here (http://media.steampowered.com/apps/valve/2015/Alex_Vlachos_Advanced_VR_Rendering_GDC2015.pdf), page 43/44). Surfaces are made to have a lower glossiness value if the normal buffer's gradient is too high.
As this modifies a different shader to the previous tonemapping work, it can be used in combination with any one of the tonemapping options
Version 0.1.0
- Updated exposure correction factors to be equal across tonemappers, this means the same colours/intensities are going into all of the shaders, making comparisons much easier.
Apologies to anyone using this mod, you'll have to play with your lighting settings again.
Version 0.0.3
- Fixed edge case in PPC tonemappers, intensities brighter than the maximum defined by shoulder strength no longer render as black.
Version 0.0.2
Added 2 1/2 new tonemappers:
- Cineon - AKA Hejl/Burgess-Dawson tonemapping. Less aggressive toe than ACES but still a very nice effect. From http://filmicworlds.com/blog/filmic-tonemapping-operators/
- Piecewise Power Curves - as proposed by John Hable of UC2 fame here: http://filmicworlds.com/blog/filmic-tonemapping-with-piecewise-power-curves/
- Piecewise Power Curves RGB - same as above, but operates on the channels separately, probably the better choice
Piecewise Power Curves are quite nice as the tweakable parameters are all quite sensible and not too difficult to understand, please play around with the values in the shader! There's 5 parameters to tune that really capture most of what you want out of a filmic curve, you can even eliminate the toe entirely.
Visualise tuning the parameters here: https://www.desmos.com/calculator/tb8hf94h28
Original Post
Hi all,
There's been some discussion on Discord about the way the shaders in FSO work. Right now I believe there's a disconnect between the material and tonemapping models used in the tools people are creating textures in, (e.g Substance Painter, Armorpaint) and those being used in FSO. This introduces an issue where models won't look the same when creating them and when viewing them in game, leading to repeated tweaking and potential frustration.
Luckily FSO has the ability to load external shaders, overriding the ones built in to the executable. Because of this, I've started working on a small mod to test out different potential material models and tonemapping operators. Right now, it consists of a small core package that enables external shader loading, and several optional packages that implement different tonemapping operators. The tonemapping operators are as follows:
- Uncharted 2 - The tonemapper used by Uncharted 2 and currently the default for FSO, as described by original author John Hable here (http://filmicworlds.com/blog/filmic-tonemapping-operators/)
- ACES - ACES (Academy Color Encoding System) tonemapping operator, default in Unreal Engine 4.
- ACES Approximation - An approximation of ACES tonemapping, developed by Krzysztof Narkowicz. Oversaturates bright colours. Faster.
- Reinhard
- Reinhard-Jodie - Operates on luminance rather than RGB as brightness is perceived differently for each channel.
- Linear - Not recommended
Please enable ONLY ONE of the optional packages.
This mod can be tacked-on to any other existing mod/TC if you know how. Feel free to try it out with Warmachine, Solaris etc. I'd love to see some screenshots :D.
The code for all of these tonemappers has been cribbed from https://64.github.io/tonemapping/ (https://64.github.io/tonemapping/), many thanks to wookiejedi for the initial work on implementing these shaders.
Future work:
- Tease out the default material models used in popular engines/tools, port them to FSO's shader system
- Use Renderdoc and a camera script to generate HDRI environment maps so you can load Freespace environments into your texturing tool of choice.
-
Oh yeah, I'm running on a 3070 here, there shouldn't be any issues with older openGL versions as everything here is pretty simple. But, if you're having issues, post
hog log.
-
Excellent. This is one of those things that I've thought about poking at but never gotten around to, I'm glad you've gotten this ball rolling
-
Glad the little package I threw together was useful, excellent write up too!
-
Some shots from EatThePath testing out ACES Approximation:
(https://cdn.discordapp.com/attachments/223511363807346691/866907011047751740/screen1096.png)
(https://cdn.discordapp.com/attachments/223511363807346691/866910885490720778/screen1118.png)
(https://cdn.discordapp.com/attachments/223511363807346691/866910907657224192/screen1119.png)
(https://cdn.discordapp.com/attachments/223511363807346691/866911259068596234/screen1129.png)
(https://cdn.discordapp.com/attachments/223511363807346691/866911290240663582/screen1120.png)
Some more thoughts:
The built-in "Uncharted 2" tonemapper has a habit of bumping up the brightness of dark parts. This isn't present in the ACES tonemapper, so scenes will seem a lot darker.
Default tonemapping
(https://cdn.discordapp.com/attachments/223511363807346691/866957328947609600/unknown.png)
Post processing off
(https://cdn.discordapp.com/attachments/223511363807346691/866957488247275570/unknown.png)
There's a lot of detail being lost in the shadows here, which the UC2 tonemapper tries to recover - to the detriment of specular highlights. The ACES tonemapper does a better job at preserving these details, but right now needs to be balanced with a higher ambient factor to preserve the standard "look".
There's a tradeoff between the tonemappers. With ACES, the backgrounds end up having blacks crushed heavily and a lot of the subtle nebula detail is lost. On the other hand, the images above are a great example of the issues with the black-boosting of UC2. The gradient on the planet's atmosphere is blown out and makes the whole thing look like a fuzzy ball.
There's a fundamental difference between background creation and ship creation, and applying tonemapping to backgrounds is always going to give results that look different to the 2D originals. The toe and shoulder curves of whatever tonemapping operator you use are going to interfere with what the original background artist settled on. Unfortunately I really don't know how to square that circle beyond big rendering engine rewrites.
Edit: Can someone explain how skyboxes are rendered? Might be possible to avoid a load of hell here if we just brighten the skyboxes so they're shifted into the linear region of the tonemappers.
-
My stuff last night was very very dark lighting settings, so I tried some tonight with no lighting flags and aces approx
(https://i.imgur.com/XRlZdzK.png)
(https://i.imgur.com/nlnQIYN.png)
Then some with reinhard_jodie and the same lighting
(https://i.imgur.com/GMmKdd1.png)
(https://i.imgur.com/DD6D9CV.png)
Then at Nyx's request some with reinhard_jodie and tanked ambient light, which might be my favorite so far
(https://i.imgur.com/53IcqcY.png)
(https://i.imgur.com/5jxlsJM.png)
(https://i.imgur.com/GRISsa5.png)
-
These shaders work fine with FS2 MVPS and installed FS2 mods. But when I try to use any shader with The Babylon Project -3.7.6 I get a gray screen. I can see the HUD but nothing else. Any thoughts what is wrong?
[attachment deleted to save space]
-
These shaders work fine with FS2 MVPS and installed FS2 mods. But when I try to use any shader with The Babylon Project -3.7.6 I get a gray screen. I can see the HUD but nothing else. Any thoughts what is wrong?
Which engine version is this running on? These shaders work by replacing some of the internal engine files and there's no guarantee of compatibility between versions.
-
I'm run it on fs2_open_21_0_0_x64_AVX, fs2_open_21_2_0_x64_AVX and Nightly fs2_open_21_3_0_20210718_5318fba07_x64_SSE2
-
I don't have time to give this a try myself, but I very much appreciate all efforts put into this thing :yes:
-
I'm run it on fs2_open_21_0_0_x64_AVX, fs2_open_21_2_0_x64_AVX and Nightly fs2_open_21_3_0_20210718_5318fba07_x64_SSE2
I'm chatting to some people on discord. TBP uses custom shaders, so there's a good chance there's a shader conflict causing this to mess up. My guess it's effects/post-f.sdr that's causing the issue, but it's late here, so I'll have to investigate tomorrow
-
There shined a shiny demon! (and also some molochs)
This really makes the age of the textures on the tev destroyers all the more painful, though...
-
I'm chatting to some people on discord. TBP uses custom shaders, so there's a good chance there's a shader conflict causing this to mess up. My guess it's effects/post-f.sdr that's causing the issue, but it's late here, so I'll have to investigate tomorrow
Custom shaders, I forgot about them. Removed post-f.sdr and now everything works. Thanks for the help.
-
Updated with 2 1/2 new Tonemapping Operators, see OP for details
-
Version 0.1.0
Updated exposure correction factors to be equal across tonemappers, this means the same colours/intensities are going into all of the shaders, making comparisons much easier.
-
It's really hard for me to pick between things like this, and comparing simlar but not identical scenes makes it harder. So today I spent something like tn hours on and off whittling at the code until I made my FSO spit out a set of screenshots, one for each mapper, whenever I hit the printscreen. I'll probably take more, but here's a selection of my output so far.
First person of spray and pray Achilles lighting up a Deimos' hull (https://imgur.com/a/jmSn614)
Subspace portals and beams (https://imgur.com/a/aj8T1hP)
Orange Ravana in the dark (https://imgur.com/a/P1IH9bl)
Hecate and Deimos in decent light (https://imgur.com/a/gmNDoEP)
Hecate shadowy underbelly over neptune. (https://imgur.com/a/vzYKG1M)
Background destroyers, beams, and 'splosions, midground achiles wing. (https://imgur.com/a/bDHIkHZ)
Foreground achilles, background orange ravana lit by beamfire (https://imgur.com/a/BObYEmB)
Moloch gonna **** you up. (https://imgur.com/a/odCjSci)
Each link is to an imgur gallery of seven variations on each scene.
...Now if I could just pick a consistent favorite across them...
-
Ah these are very helpful, awesome work!
-
Oh yeah, if anyone code inclined wants to mess with that capability, the code is at https://github.com/EatThePath/fs2open.github.com/tree/multishot.
-
Lest this look like a dead end for passers by, a little status roundup.
As I dug deeper and deeper into this and learned more about PBR, tonemappers, and how FSO handles them both, I became increasingly convinced that a mods using custom shaders or a switch to the engines' defaults would both be inadequate, and that if we're going to finally put the matter of FSO tonemapping to bed we have to go a lot harder.
Where this effort has gone, then, is to a plan to introduce a new table to FSO that allows mods to take control of their choice of tonemapper and various currently fixed settings. My hope is for this to take over entirely for the lighting flags that are currently standard, and overcome some of their limitations as well. There are a lot of things that look not quite right (or at least, not always what you want) in the current rendering pipeline that I think can probably be cleaned up in the course of adding everything to this that needs to be in that table.
Right now that project is on the shelf, but it's at the front of the shelf and as soon as WM R2 is out it's moving up the list.
-
Added new shader, designed to reduce specular glinting/shimmering on distant ships. See original post for details and video