Author Topic: PBR/BNAO  (Read 1754 times)

0 Members and 1 Guest are viewing this topic.

Hello, here is a set of shaders to toy around with PBR lighting model, ambient occlusion using bent normals and soft bloom threshold.

The difference in PBR is that it no longer uses specular colors from the texture, but instead just roughness and metallicity. It's still not perfect and probably quite hacky, at the moment the metallicity is red channel in reflect texture, while roughness is alpha channel as before ( stored as inverse/smoothness, meaning bright pixel is smooth and black pixel is rough )

Please excuse the non-artist art,  PBR texture generated with materialize:



And example how this helps to make dynamic lighting a bit less rubbery:



Bent normals are explained here:
https://dev.epicgames.com/documentation/en-us/unreal-engine/bent-normal-maps?application_version=4.27

Basically it's another form of precomputed occlusion in addition to AO.
It's used as -misc texture in the same format as normal maps.

Example:
https://imgsli.com/Mjg3NjYz

Here are the shaders ( note that you need to enable loading shaders in your -mod file
Code: [Select]
#GRAPHICS SETTINGS
$Enable External Shaders: YES
https://mega.nz/file/9BZlRTTB#cpvi5SS9Tow8bnRgsrmDz4z6ZWu1qmw_4wC2mrRbUag
And here is the medusa example ( note that the normal, diffuse/albedo and glowmap are mvps originals, included just because the game prefers -shine textures, so I had to change the name, model is also mvps original with just changed texture name )
https://mega.nz/file/gYo3hBbC#YLH0rkETlJiAuMxngyUhOSs9OItGwfDCYCv531egelw

Take note that this is all quite hacky, team color functionality is hijacked completely, and most existing models will see some regression, because they will have wrong metallicity set. Low lighting settings are likely broken and not sure how well the forward rendering works.

If you want to bake your own bent normal map, try following this https://blender.stackexchange.com/questions/157079/how-do-i-bake-a-bent-normal-map-in-blender
It's a bit vague, but it's the only free software solution I've found.

I've used pof-tools for importing pof models in the blender, for baking you may want to remove everything outside of the solid mesh from detail0 and assign the material with the script to it. Then bake it using cycles normals baking option.
« Last Edit: August 14, 2024, 03:06:09 pm by Subspace Anomaly »

 

Offline EatThePath

  • 28
  • Laser Lich
    • Twitter
Very interesting work. I think bent normals is something that was tossed around a bit during the last overhaul, and we've definitely talked about bloom changes, so I'm curious to see what you've got there.

One quibble I have: Unless I'm very much mistaken the engine's current specular+gloss method is a fully valid PBR method which allows everything a metal+rough approach does and a little bit more. As I understand it metal+rough infers if it should use the color texture for diffuse color or specular color, whereas having separate specular and diffuse textures lets you specify explicitly.

Given that a lot of the textures these days are probably made in Substance with a metal+rough workflow and converted on export it's probably possible to faithfully convert the majority of assets to metal+rough maps without losing significant information, but using the diffuse map alone as color is going to lose a lot of information on ships that were made with metallic regions, producing much darker metals then they should have.
« Last Edit: August 14, 2024, 03:50:39 pm by EatThePath »
Name your damn turrets and sounds! Numbers alone aren't helpful!
"if disco is dead then I am the laser lich"
"...[Warmachine] keeps changing as fast as EatThePath can force the engine to do [her] dark bidding..."

 

Offline qazwsx

  • POST DRUNK GET TITLE
  • 29
This is wonderful work! I think me and EatThePath were very much keen on integrating bent normals, but never really got the time. It shouldn't be too much difficulty to add another map type and support them code-side. Regarding bloom: I have an old PR in draft for the mipmap-pyramid bloom used in Unreal/Unity here: https://github.com/scp-fs2open/fs2open.github.com/pull/5431 , but once again didn't have the time to determine sensible defaults and get it over the line. You're welcome to take a look!
<Achillion> I mean, it's not like he's shoving the brain-goo in a usb slot and praying to kurzweil to bring the singularity

<dsockwell> idk about you guys but the reason i follow God's law is so I can get my rocks off in the afterlife

 
Right, this is mostly POC for fun and learning so I surely might be wrong. And looking at https://physicallybased.info/ indeed some materials do have specular specified, so I suppose that the more robust model that would support old assets as well as more workflows would be needed.

And yeah, that bloom looks interesting, will build it when I get the time. If it goes  well, might as well drop in the BN stuff in a PR., the lengthy part is baking the normals anyway.
The current double pass box filter however was pretty decent, it's mostly the lack of parametrization in the pass filter that prevents it from being visually appealing. I can imagine it's not the fastest, with all the buffers it creates.

 

Offline EatThePath

  • 28
  • Laser Lich
    • Twitter
In my perfect, ideal, dream version of FSO, the engine would probably accept both types and convert them to a single internal format on launch, with the option of making the engine spit out the converted files to speed up future loading. That's a bit of a pipe dream, but we probably don't want multiple extra shader variants if we can help it.
And between the two options, color+metalness vs diffuse+specular colors, I prefer latter as an internal representation. As I see it, every possible metalness workflow material can be made with a specular workflow, but not every specular workflow texture can be made with metalness, and I really like the idea of having those niche and potentially rule-breaking visuals even if I haven't made anything(released anyway) that leverages it.
Name your damn turrets and sounds! Numbers alone aren't helpful!
"if disco is dead then I am the laser lich"
"...[Warmachine] keeps changing as fast as EatThePath can force the engine to do [her] dark bidding..."

 
After playing around with bunch of tools, I must say that maybe none of this is even required, it takes just few minutes to setup chaiNNer to convert metal to specular so none of this is even as important as I thought it is.

On the positive side, outside of DXT5nm compression and it's unpacking ( which I am not sure how much it improves on quality or space and even then it feels a bit wrong to do it runtime in shader, even though it should be pretty fast math ) the bent normals do seem to work quite well.

As for the converting pre-PBR textures, the major hurdle seems to be sins of the past, mostly having lights and shadows in the diffuse maps.
In this example I've basically butchered all the colors when I tried  to level it up with curves.

 

Offline EatThePath

  • 28
  • Laser Lich
    • Twitter
Regarding old textures, yeah, a wide slice of the community textures have AO bakes rolled into their diffuse textures. It was a great idea at the time(I always hated it a little because of the inherent flaws but it did have merit). And before that, just manually highlighting areas to imply curves the polycounts didn't support and so forth. Some ships have source files floating around without the AO layer flattened around, if you ask the original artist/projects or other artists they might have passed them around to. I even have had limited luck doing new AO bakes and then obscene things with blender nodes to try to undo the bake in the texture files, but only on a handful of ships with few nooks and fairly bright base hull textures. Trying to do it to the MVPs Sathanas effectively made me stop doing 3d art for about six months  :banghead:

And yeah on the DXT5nm packing not necessarily being worthwhile anymore. With BC7 dds compression being the current recommendation for high end assets, I don't think the packing would be worth implementing today if we were starting form scratch. Dropping a channel maybe, but not shuffling them. We're a bit stuck with it, though.
Name your damn turrets and sounds! Numbers alone aren't helpful!
"if disco is dead then I am the laser lich"
"...[Warmachine] keeps changing as fast as EatThePath can force the engine to do [her] dark bidding..."