SleepKiller's Shader Patch - v0.8.0

Started by SleepKiller, March 03, 2018, 04:48:48 AM

Previous topic - Next topic
March 03, 2018, 04:48:48 AM Last Edit: August 04, 2018, 01:35:00 AM by SleepKiller
This a mod focusing improving the quality of SWBFII's visuals in subtle ways without interfering with any mod or map's art style. After all a lot of modders spend quite a while making their content look just right and I don't want to come along, ignore all their effort and end up butchering their content.

I want visual improvements that interfere minimally with existing content but are still meaningful. Now let's go on a tour of the features provided by this amazing mod.

First up we have the lovely global per-pixel. Per-pixel lighting is already in the game but modelers must opt into it, this is because back in the day GPUs just weren't up to the task of doing it. However GPUs have gotten alot faster since the game came out and thus we're now able to enable per-pixel lighting across the board.

Notice how on the left the light fades out unevenly and it is hard to even identify where the light is coming from. Compare that to the right where the light interacts with the wall smoothly and correctly from it's centre point.
[spoiler][/spoiler]

Next up we have my attempt at improving the look of the Droideka shield effect ingame. On right you can see how the shield has distortion that helps give the appearance of greater depth and complexity to the shield's surface. (The normal map is also seamless.)
[spoiler][/spoiler]

Moving onto water! You ever notice ingame how the water animation always looks jittery and lowres? This always bugged me and was my reason for getting into editing the game's shaders. It does however potentially interfere with the art of some maps, although I've done my best to avoid it.
[spoiler][/spoiler]

Then we have normal mapping. The game normally uses it's normal maps to modify a light's attenuation to produce a bump mapping effect, this gives a reasonably good result, it's not 2005 anymore, we can do better by using real normal mapping. (The impact of this change is often more noticeable on custom maps that make use of normal maps as opposed to stock maps.)
[spoiler][/spoiler]

Ever gotten bugged by that boxy looking bloom falloff that can sometimes show up? As of v0.6.0 Shader Patch comes with an optional (but on by default) replacement stock bloom effect designed to smooth out the falloff.
[spoiler][/spoiler]

Another new one as of v0.6.0. The game comes with a scene blur effect that some maps use. The stock one has a nasty habit of adding aliasing to the corners of objects, to solve this Shader Patch can now (once again optionally) replace the blur effect with a gaussian blur that doesn't add as much aliasing to the scene and (keeping in line with Shader Patch's goal of respecting a map's artwork) looks similar when blended in. (Minus the aliasing obviously!)
[spoiler][/spoiler]

For a while now SP has had a custom materials system and a fancy pants post-processing system to go along with it. However as I expected there hasn't been any use of it. But one thing I have noted is that people sure to seem to like their post-processing effects. So the effects system used by the materials system has been extended to be perfectly (and easily) usable on it's own. There should be a tutorial on the GitHub wiki either now or in the next couple days for how to use and integrate it with your map.
[spoiler]Please note that I'm not suggesting you color grade a night time map like this, it's just meant to show off what SP's post-processing can do.
[/spoiler]

To use this amazing mod you'll need:

* To understand that it works by hooking into the game using a .dll, if that isn't something you're comfortable with then obviously don't install this :)

* If you want to use the included Installer/Uninstaller .NET Framework 4.6.2 which you can find here if you don't already have it. (You probably do.)

* A Shader Model 3.0 capable GPU, if you don't have this the patch won't work, full stop.

* Windows 7 or higher, because adding XP support would be a serious pain.

Assuming I haven't frightened you off and you're eager to start installing the patch you can find it at the below link on GitHub. The name of the file you're after is shaderpatch.zip.

GitHub Release

If you hit problems have a look at Common Problems & Solutions page, it is possible some simple settings need changing for it to work.

And of course the source code to both the shaders and DirectInput hook can be found on GitHub.

GitHub Source

If you have any thoughts/bug reports or requests then I'm always happy to hear to them. You can reach me here, on GitHub or if you prefer on Discord.

March 03, 2018, 10:12:28 AM #1 Last Edit: March 03, 2018, 10:45:58 AM by Ginev
Amazing!!!And now one day..one day my dream for relef maping for atleast terrain.That will be epic.Or something else.Tell me is it possible to use some of the unused shaders or not working shaders as a empty slot to make new shader effect?I would love to have a shader that can be applyed to a model that will basically work like the water reflection effect where you can see yourself for example in a wall just like a mirror.This effects is added only to water.Is it possible to be put on model like wall?I know that if this work it will eat alot of frames ingame but we can use it for some small objects its really nice.What you think?Personally for me this 2 shader effects can be the best things ever. :)


EDIT:Ok im back here after 10 minutes and i was testing the shaders on this map.For some reason i think i have a problem with the shaders.

http://www.mediafire.com/file/enq40dc3q2u9irv/Clone+Wars+-+Kashyyyk+by+Warlord28.rar

If you want download it and test it to see how some stuff look like.
For example the water is kinda bright and the refraction make thins from the side look like crap..in my opinion
If you look beneat the water the trees bark is glowing.I do not know but the shadow for everything is super dark.It will be better to say completely black.The droideka shield effect is really nice.I like it.Better test everything on this map.If you do not have such problems please tell me i will send you screenshots.

March 03, 2018, 12:07:32 PM #2 Last Edit: March 03, 2018, 01:02:15 PM by RepComm
I love the normal mapping! The distort on the deka shield is very sweet too! If we mod a higher rez sphere mesh, that distortion should spread a little better I think.

Theoretically, couldn't we add a displacement shader also? Kind of like tesselation? The only application I can think of would be ice caves (I thought ea swbf had displacement for each frost flake in the hoth caves, but it turns it that it's just a lot of geometry..)

True RepComm.I was thinking the same thing about their caves.But when i opened the mesh i was surprised.Such thing also will work in Battlefront 2 since we have the model-munger tools now and we can load much more detailed models :D

March 03, 2018, 04:32:40 PM #4 Last Edit: March 03, 2018, 10:46:09 PM by SleepKiller
Thanks for the feedback guys!

Quote from: Ginev on March 03, 2018, 10:12:28 AM
If you want download it and test it to see how some stuff look like.
For example the water is kinda bright and the refraction make thins from the side look like crap..in my opinion
If you look beneat the water the trees bark is glowing.I do not know but the shadow for everything is super dark.It will be better to say completely black.The droideka shield effect is really nice.I like it.Better test everything on this map.If you do not have such problems please tell me i will send you screenshots.
The water shader is still very much a work in progress and I definitely agree that it could do with some more work. The overbright reflections mean I am definitely doing something wrong somewhere and I'll have to look into that.

As for the darkened terrain shadows I'll look into what's causing them as well. Be sure to let me know if you spot any other problems.

EDIT: I have fixed the darkened terrain shadows and overbright water reflections. The downloads have been updated.

Quote from: RepComm on March 03, 2018, 12:07:32 PM
Theoretically, couldn't we add a displacement shader also? Kind of like tesselation? The only application I can think of would be ice caves (I thought ea swbf had displacement for each frost flake in the hoth caves, but it turns it that it's just a lot of geometry..)
Quote from: Ginev on March 03, 2018, 10:12:28 AM
Amazing!!!And now one day..one day my dream for relef maping for atleast terrain.That will be epic.Or something else.Tell me is it possible to use some of the unused shaders or not working shaders as a empty slot to make new shader effect?I would love to have a shader that can be applyed to a model that will basically work like the water reflection effect where you can see yourself for example in a wall just like a mirror.This effects is added only to water.Is it possible to be put on model like wall?I know that if this work it will eat alot of frames ingame but we can use it for some small objects its really nice.What you think?Personally for me this 2 shader effects can be the best things ever. :)
I forgot to mention this in the original post but I have some ideas about how to add support for custom materials. I'm absolutely up for implementing if the demand is there. The catch is however if a mod used them it would make Shader Patch a requirement for running it. Leaving modders to make a choice between better visuals, better support or potentially maintaining two versions of their mod, one with Shader Patch and one without.

A proper reflection shader however would require access to the game's scene graph, so unfortunately without the source code to the game there isn't much that can be done in this regard. One thing you can do in some cases is put a reflection region on it's side and that will let you make a mirror, however it will require that the space used for the reflections is unused by the rest of the map, so far from ideal.

Implementing a form displacement mapping should however be extremely doable. We probably won't be able to match a shader that uses real tessellation + displacement mapping but we could still get some nice results going.

Quote from: RepComm on March 03, 2018, 12:07:32 PM
I love the normal mapping! The distort on the deka shield is very sweet too! If we mod a higher rez sphere mesh, that distortion should spread a little better I think.
Yeah, ideally I would love a high resolution smooth shield mesh. However the game either generates it on the fly or stores it in the executable, making it nontrivial to replace.

So here is a quick feedback. I tried with Battlefront Evolved and it erase the droideka shield completely. Secondly the phase 1 clone troopers are way more shiny than expected. -I know that the devs used specular for these models.

Other than that I've seen a few feedback on SWBF3 Legacy's Discord.
"When will you fools learn? No one escapes Commander Fox"
—Fox, after apprehending another criminal

https://media.giphy.com/media/2GjgvS5vA6y08/giphy.gif

In my opinion this new shaders will be best to be used without any other mods that effect the graphic colors in any way.

To expect this to support every mod out there is a little bit overkill - everybody put their own touches on mods and some of those are going to conflict with this because the shader patch did not exist when most were made.
The BOBclan:  A Rich History


Quote from: Unit 33 on November 29, 2014, 03:44:44 AM
'Please, tell me more about the logistics of the design of laser swords being wielded by space wizards' - Some guy on the internet.

Quote from: Cdt Fox on March 08, 2018, 10:20:52 AM
So here is a quick feedback. I tried with Battlefront Evolved and it erase the droideka shield completely. Secondly the phase 1 clone troopers are way more shiny than expected. -I know that the devs used specular for these models.

Other than that I've seen a few feedback on SWBF3 Legacy's Discord.
Thanks for the feedback. I'll try to look into the Droideka's shield not rendering when I have the time.

Be warned, more information than you probably wanted in response now follows.

As for the specular being different this is regrettably a case of "it just has to be that way". This is one of the two key differences that my shader toolkit (which is a HLSL recreation of the game's stock shaders) has. The details are here but basically the game's original method of specular lighting couldn't be implemented in HLSL, thus I replaced it with a well respected classic of the game's industry.

Unfortunately the specular exponent (or decay) has to be fixed, because despite SWBF exposing such a parameter to artists I could never find where or how is was being passed in to the shader.

If someone can supply me with two models, with two different specular exponents, that when rendered by the game's original shaders look visibly different I am happy to give it another search.

Quote from: Dark_Phantom on March 08, 2018, 04:08:24 PM
To expect this to support every mod out there is a little bit overkill - everybody put their own touches on mods and some of those are going to conflict with this because the shader patch did not exist when most were made.
I'd agree, but in all except edge cases I still want to aim for it improving the visuals without changing the art style. It is a bit of a hard ask and their are times (like above) were there is simply no other option than to make a breaking change, but it is what I'd like to aim for.

March 08, 2018, 10:41:46 PM #9 Last Edit: March 08, 2018, 10:44:38 PM by Cdt Fox
Quote from: SleepKiller on March 08, 2018, 04:23:12 PM
Unfortunately the specular exponent (or decay) has to be fixed, because despite SWBF exposing such a parameter to artists I could never find where or how is was being passed in to the shader.

Hum, of course I can play with the specular decay within XSI etc. However most of the time I create an alpha channel within my diffuse texture and this is were I setup the intensity of the light/brightness (the brighter the texture contained in the alpha channel is, the brighter the surface will get ingame). - I find that method much more effective than playing with the decay tbh.
I don't know how Battlefront Evolved dev team setup their brightness, with decay? Or with an alpha channel?

Here are 3 players models with various specular decay applied on:

4 - the specular decay used by the DarkTrooper mesh both in Swbf1 & 2
50 - stock specular decay for most models created by Pandemic
100 - specular decay used for bigmodel/hugemodel by Pandemic like the frigates and cruisers's parts in space. I could be wrong thought. It's either 50 or 100 so.

http://www.mediafire.com/file/k46n8g9x9ggme86/Sleepkiller+phase+1+Clone+Trooper.rar

I also included a texture with an alpha channel, if you want to try, just replace rep_inf_trooper.tga. I'd be more than happy to provide various textures (darker or brighter) to see if the specular map has a real impact on the intensity.
"When will you fools learn? No one escapes Commander Fox"
—Fox, after apprehending another criminal

https://media.giphy.com/media/2GjgvS5vA6y08/giphy.gif

Ah yes but allow me to point out the critical wording I used.

Quote from: SleepKiller... that when rendered by the game's original shaders look visibly different ...

Here are what the three models you sent me look like when rendered side by side, using the game's stock shaders.

[spoiler][/spoiler]

Aside from the difference in the angle of the highlights from the camera they're identical. If the decay/exponent was being used in the rendering of this we would expect significant (or at least some) differences between each of these models, due to great range being used.

Unfortunately you've been lied to by a lot of information out there but in SWBFII (by default, it is possible their is some combination of material flags that trigger use of the exponent) the specular exponent is ignored and unused.

This why I used the wording I did, I've tested different specular exponents before. I've just never seen a difference in the constants passed to the shaders or in the rendered results.

All that said I do really appreciate your offer of help in the matter. If you do ever encounter two identical models save the specular exponent and they do look different I would be very interested to look at them.

I'm hopeless at maintaining release topics.

For any who hasn't been following this through other channels a lot has changed since the last release I posted about here. The short list is as follows.


  • SP now has a flexible custom materials system and supporting set of mungers. Out of the box it comes with a set of PBR materials.
  • SP now has a post-processing system that a map can activate and customize at its discretion. Includes things like a new Bloom effect, color grading and dithering.
  • More improvements to things like water, the game's stock bloom, specular lighting, etc

** Now follows the actual release post I used for the most recent version. **

I've posted a new release with quite a few changes. I've also posted some new screenshots in the original post showing off some of these. The most important change in my mind is that the Effects system now plays nicely with just about any map and is easier to use and package up with maps. I've got a rough tutorial on how this works over https://github.com/SleepKiller/swbfii-shaderpatch/wiki/Using-Effects-System-With-Integrating-Tools.

Since I've made a lot of "risky" (changed water, shield, stock bloom, etc) changes in this version I'd love to hear feedback from anyone using this. Especially if you integrate the Effects system with your map (which remember doesn't stop people who don't have SP from using your map). Since a lot of people seem to drawn to use Discord as their communication platform of choice (I'm not sure I really understand it, but I'd like to make it easy for people to give feedback) I've tossed one up for this and any of my other SWBF related stuff. Please feel free to use it, this site or GitHub to give feedback, make requests or whatever! Discord Link