Anyone interested in having native ReShade support?

Need help editing the game? Check for help here!

Moderators: Darksaber, General_Trageton, Forceflow

Anyone interested in having native ReShade support?

blue_max
Ensign
XWAU Member
Posts: 324
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Tue May 07, 2019 2:13 am

I could never get ReShade and XWAU to work together. However, after working on the VR mod for XWA I now have some understanding of how the game is rendered. So I was thinking I could perhaps convert some of the ReShade shaders and call them when needed from the game itself (instead of having ReShade inject the shaders forcefully at run-time).

Anyway, would anyone find this interesting? If so, which shaders would you like to see? I'm thinking maybe Ambient Occlusion, Bloom, and maybe Cinematic coloring? Any other suggestions?

User avatar
DTM
Lieutenant Commander
XWAU Member
Posts: 1308
Joined: Tue Apr 22, 2003 11:01 pm
Contact:

Post by DTM » Tue May 07, 2019 4:01 pm

Reshade is used by many XWA players but there is no support or tutorial to make it playable by everyone. It would be nice to have soneone who thakes a look on it and creates a mod for XWA.

MTD industries
WIPs: REBCP version 2

User avatar
Trevor
Cadet 1st Class
Posts: 188
Joined: Thu Dec 04, 2014 7:11 pm

Post by Trevor » Tue May 07, 2019 9:40 pm

Ah, read my mind, I just posted about this in the VR thread

Trev

Bman
Lieutenant JG
Posts: 703
Joined: Mon Apr 05, 2004 11:01 pm

Post by Bman » Wed May 08, 2019 2:15 am

That would be great. I haven't messed with Reshade for a few years, haven't had time (yet) to use latest version. I saved an older version Alpha1.2 which did work on WinXP Pro 32-bit and Windows10 x64. What I did was rename the dxgi.dll file to d3d9.dll and put it inside the main root XWA folder with the file called ReShade.fx and of course the ReShade folder itself. I might have tweaked a few config files inside Reshade folder based on what other people (Kampher etc.) posted in the related threads. The only other thing is to check your in-game video settings menu when at the concourse screen (ESC) key, and you might also need Jeremy's patches and/or Reimar's ddraw.dll and you may have to edit the ddraw.cfg to change some settings if necessary.
W-I-P: ISD-II, XQ-1 Platform1, (Imp) Escort Carrier, Misc, & TFTC.

blue_max
Ensign
XWAU Member
Posts: 324
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Wed May 08, 2019 5:01 pm

That's exactly what I'm talking about, Bman: setting up ReShade is painful. Wouldn't it be nice if the effects from ReShade worked "out of the box" and all you had to worry about is having a DirectX 11-compatible video card? That's what I'd like to tackle next...

Bman
Lieutenant JG
Posts: 703
Joined: Mon Apr 05, 2004 11:01 pm

Post by Bman » Thu May 09, 2019 12:23 am

Agree. Thanks
W-I-P: ISD-II, XQ-1 Platform1, (Imp) Escort Carrier, Misc, & TFTC.

llemon
Recruit
Posts: 4
Joined: Sun Mar 31, 2019 2:16 pm

Post by llemon » Fri May 10, 2019 11:18 pm

The new version of MXAO is great and should be used for AO

blue_max
Ensign
XWAU Member
Posts: 324
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Sat May 11, 2019 4:42 am

Thanks llemon, I'll use that version then.

blue_max
Ensign
XWAU Member
Posts: 324
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Tue Jul 09, 2019 5:36 am

Just implemented an early version of the bloom shader. It's running natively from XWA -- not through ReShade:
bloom-sample-1.jpg
bloom-sample-2.jpg
bloom-sample-3.jpg
It still has some issues, though (for instance, white surfaces have a lot of bloom, like the surface of Star Destroyers); but it will happen.
You do not have the required permissions to view the files attached to this post.

blue_max
Ensign
XWAU Member
Posts: 324
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Tue Jul 09, 2019 5:44 am

Another issue is that I can only see bloom on lasers if the effect is exaggerated:
bloom-sample-5.jpg
bloom-sample-4.jpg
This is just the first iteration, though.
You do not have the required permissions to view the files attached to this post.

blue_max
Ensign
XWAU Member
Posts: 324
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Tue Jul 09, 2019 5:46 am

And to be completely honest, we also get the following, which isn't great:
bloom-sample-6.jpg
You do not have the required permissions to view the files attached to this post.

User avatar
Phoenix Leader
Ensign
Rebel Alliance
Posts: 306
Joined: Wed Aug 08, 2018 2:20 pm

Post by Phoenix Leader » Tue Jul 09, 2019 6:33 am

This might be a trivial observation, but have you tried to change these Video Options: Local Light Source (All/Off/Some) and Diffuse Lightning (On/Off)?
In case you have, did you get the same result you posted in your last screenshot for all the available settings?

User avatar
Trevor
Cadet 1st Class
Posts: 188
Joined: Thu Dec 04, 2014 7:11 pm

Post by Trevor » Wed Jul 10, 2019 9:28 pm

Ah, yeah, this is why we need to be able to tell "lights" from "diffuse reflection" apart.
if you could tell lasers from everything else, could you bloom them separately?

Otherwise, apart from the ISD, the bloom is working good.

I did note before that ideally (and you implemented something similar for text in VR) all xwa's lighting needs to be compressed into a 32-224 range with only lights and specular reflections exceeding 224 and hence blooming.

I attempted this with reshade - however obviously, the lights also got darkened and when I brightened them, the ISD got brighter too... :(
that's why I had my reshade settings on 0.99 so that only the absolute white would bloom.

Trev

blue_max
Ensign
XWAU Member
Posts: 324
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Wed Jul 10, 2019 11:48 pm

Hello guys

I haven't tried what you're saying, Phoenix -- thanks for the idea. I'll try it out and see what happens.

I can tell when the lasers are being rendered because I can recognize the texture. I think I also found the draw call that renders the engine glow and cockpit "glass" so that can be separated from the rest of the surfaces... Maybe I can tweak the engine to dim surfaces selectively so that only lasers and engine glow gets the bloom; but the downside would be that there would be no bloom in windows, cockpit buttons, etc. I wonder how the game renders "lights" embedded in the textures...

Another way to frame this question is: when I'm creating the textures for a craft and I want to make sections of this texture behave like "lights", what do I have to do? Is there a special color index that tells the engine: "Hey! This is supposed to be a light"?

Bman
Lieutenant JG
Posts: 703
Joined: Mon Apr 05, 2004 11:01 pm

Post by Bman » Thu Jul 11, 2019 12:21 am

Nice. Yes, it's illumination feature. I've been wanting to get some of the lights on the cockpit dashboard flashing/flickering. I think that could be achieved with the xwa_hook_pilot mesh rotation hook (any mesh) by moving a texture map on a flat square face from behind the cockpit's dashboard and barely moves forward to the player to give an illusion of flickering. The transformation vectors have to be setup correctly with the mesh to get it to oscillate back and forth. I digress but just throwing that out there, again.
Last edited by Bman on Fri Jul 12, 2019 11:02 pm, edited 1 time in total.
W-I-P: ISD-II, XQ-1 Platform1, (Imp) Escort Carrier, Misc, & TFTC.

blue_max
Ensign
XWAU Member
Posts: 324
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Thu Jul 11, 2019 4:38 am

Flickering lights, eh? If you mean flickering bloom, then I think I can do that without too much trouble. Thanks for the suggestion Bman, I'll try to implement that.

blue_max
Ensign
XWAU Member
Posts: 324
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Thu Jul 11, 2019 6:24 am

Phoenix Leader wrote:
Tue Jul 09, 2019 6:33 am
This might be a trivial observation, but have you tried to change these Video Options: Local Light Source (All/Off/Some) and Diffuse Lightning (On/Off)?
This is *very* interesting. Nothing happens at all if I change the Local Light Source options; but if I disable diffuse lighting, then I still get bloom on the lights while the Star Destroyer stays gray (so it doesn't bloom). That gives me some ideas on how to fix this... maybe. Thanks for the suggestion!

User avatar
Trevor
Cadet 1st Class
Posts: 188
Joined: Thu Dec 04, 2014 7:11 pm

Post by Trevor » Thu Jul 11, 2019 9:58 pm

Local Light sources include:
Stars/planets
Lasers
Explosions

if you disable lights in XWA, everything renders in flat Ambient light (i.e. no directional light)

Lights should be enabled unless you are re-writing the lighting engine too.

I guess this option would be the more flexible since you can start with a dull image and light it using dx11 HDR settings instead of relying on dx6

Trev
Last edited by Trevor on Fri Jul 12, 2019 5:12 pm, edited 1 time in total.

blue_max
Ensign
XWAU Member
Posts: 324
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Fri Jul 12, 2019 1:42 am

Yeah, I knew about ambient lighting; but the interesting bit was that even with ambient light only, I got bloom in the right spots: windows, engines, etc, while the hull of the ISD remained dull gray -- as it should be. So that means that the textures already provide just about enough information (?) to do bloom before the diffuse lighting is applied. What I was thinking is that maybe the bloom mask can be retrieved in the pixel shader before the diffuse component is applied -- maybe render to two images while doing this: the regular image and the mask. Anyway, just an idea; but it might just work.

XWA already computes diffuse (and specular?) lighting in the CPU (?) and it sends that information to ddraw. The main problem I see with writing a new lighting system is that I don't know how the player's craft is oriented while inside ddraw. The player's craft orientation can be seen from a Hook, though. I *believe* that there's probably a way to access XWA's heap from ddraw so that pitch/yaw/roll can be read directly from the player's data struct... Or a hackier way would be to read the information from a hook and place it in shared memory where ddraw can read it. Anyway, with the pitch/yaw/roll, the lighting system probably can be rewritten in ddraw and we could add even more effects, like bump mapping; but that's probably a longer-term project anyway.

User avatar
Trevor
Cadet 1st Class
Posts: 188
Joined: Thu Dec 04, 2014 7:11 pm

Post by Trevor » Fri Jul 12, 2019 5:11 pm

Ah, ok, I see where your going, yeah, Illumination textures don't care about am.... Ohhh wait... but ambient is like 1.0 so any white on a texture will = a light while if the texture was in shadow ONLY the lights would glow...
ok, can you set ambient to 0?

then you would effectively get a "light mask" for bloom, then you could allow XWA to do its own diffuse and then finally add your own ambient (or better yet use vertex based ambient occlusion with the average from 4 raytraces)

yeah, specular I have wondered about for some time and it seems it only works in original game in software mode (for glass on cockpits, you see the "dot" moving depending on your view (the dot is itself "view independent" and calculated on the brightest light source))
Since we are modifying ddraw, I would love to be able to apply Environment Maps to objects to give a semi-glossy sheen to ships

Trev

blue_max
Ensign
XWAU Member
Posts: 324
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Fri Jul 12, 2019 10:52 pm

Hey Trevor!

I'm not sure I followed you here 100%, so please bear with me because I don't want to miss anything.

Yes, any white on a texture *before the diffuse component is applied* will probably be a signal to "apply bloom here". At the level of the pixel shader, it's very easy to see when the texture is being sampled and when it's being "modulated" by the diffuse component to make it darker or brighter. So yes, it may be possible to make a good bloom mask by sampling the texture before the diffuse component is applied. Are we saying the same thing here? Just wanted to make sure.

I don't think specular highlights are possible in hardware-accelerated ddraw right now. I believe we have per-vertex illumination and for specular highlights/bump mapping we need per-pixel illumination. Unfortunately, I checked the 3D structures quickly and I didn't see any information regarding normals in there (I may be wrong here -- and I hope I am!). Maybe we can recover the normals from the depth buffer by taking its derivative first...

Ambient occlusion should be possible, though -- and it might need a pre-pass to compute the per-pixel normals too anyway... Hmmm...

blue_max
Ensign
XWAU Member
Posts: 324
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Fri Jul 12, 2019 11:00 pm

Forgot to say: Environment Maps should be possible once we get the per-pixel normals.

Seems like a lot of things depend on getting those normals :)

Bman
Lieutenant JG
Posts: 703
Joined: Mon Apr 05, 2004 11:01 pm

Post by Bman » Fri Jul 12, 2019 11:15 pm

blue_max wrote:
Thu Jul 11, 2019 4:38 am
Flickering lights, eh? If you mean flickering bloom, then I think I can do that without too much trouble. Thanks for the suggestion Bman, I'll try to implement that.
Hi Blue, no I'm literally talking about something else. If you seen my posts, I think it was in the Assault Gunboat and/or Lambda Shuttle threads, I got landing lights actually flickering on the outside hull of crafts. It's just a sphere mesh imploding and then returning to size with a 0,0,0 transformation vectors. Proof of concept, but I'll try to experiment with it using a different geometric shapes in near future for the interior of cockpits. Then the bloom effects and so forth would be a topic after the fact.
W-I-P: ISD-II, XQ-1 Platform1, (Imp) Escort Carrier, Misc, & TFTC.

blue_max
Ensign
XWAU Member
Posts: 324
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Sun Jul 14, 2019 10:04 pm

Bman wrote:
Fri Jul 12, 2019 11:15 pm
Hi Blue, no I'm literally talking about something else. If you seen my posts, I think it was in the Assault Gunboat and/or Lambda Shuttle threads, I got landing lights actually flickering on the outside hull of crafts. It's just a sphere mesh imploding and then returning to size with a 0,0,0 transformation vectors. Proof of concept, but I'll try to experiment with it using a different geometric shapes in near future for the interior of cockpits. Then the bloom effects and so forth would be a topic after the fact.
I did a quick search of your posts and I couldn't find those topics; but I think I know what you mean now: the cockpit lights would be on their own mesh. Then this mesh would be scaled to 0 to "turn the lights out" and then back to its original size to "turn them on". I don't know how you would achieve that (a hook, I guess?); but that would work. It would need some rework of the cockpit too. Also, have you considered just modifying the textures? When XWA runs in high-res mode it will use two textures for the cockpit: the regular diffuse texture and an additional transparent overlay for the lights:

https://www.dropbox.com/s/q25f62e8ln3i5 ... 9.png?dl=0
https://www.dropbox.com/s/7e4zn95pgfb28 ... 0.png?dl=0

You'd have to erase the lights on the diffuse textures (image 9 in the example above) and then turn the overlay (image 10 above) on and off; but it's probably easier to do?

In fact, now that I think about it... I think I can do that without too much trouble...

blue_max
Ensign
XWAU Member
Posts: 324
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Mon Jul 15, 2019 2:25 am

... I just realized that the game splits the textures at run-time. So there are really no "transparent overlay" and "diffuse" versions of the textures: the game creates these textures after loading them. Nevermind; I still think this can be done within ddraw without touching any meshes.

Post Reply