[MOD] Sharpening filter, BGEE1.3-like look and more via shaders
drunktiefling
Member Posts: 39
GitHub: https://github.com/dtiefling/dshaders. Project readme there is an actual mod readme too, with detailed illustrations, which I wholeheartedly recommend.
Download: https://github.com/dtiefling/dshaders/releases.
Inspired by @argent77's Shader Pack, I have started researching what else can be done with shaders, and discovered more potential.
With this mod, I present rewritten shaders that go much further with extra features and available settings. That includes:
It should work on any PC platform (tested on Linux and Windows).
How does it look? Well, you can trace most of the options in the mod readme, but here is an idea:
BGEE 1.3 (top) vs mod preset that is intended to imitate the feel:
Game without this mod (top) vs setup I use (includes Catmull-Rom, moderate color adjustment and sharpening):
Download: https://github.com/dtiefling/dshaders/releases.
Inspired by @argent77's Shader Pack, I have started researching what else can be done with shaders, and discovered more potential.
With this mod, I present rewritten shaders that go much further with extra features and available settings. That includes:
- Catmull-Rom interpolation (i.e. better scaling),
- Changes to the outlines, including disabling them via shaders, for BGEE 1.3-like look,
- Color operations in linear RGB space,
- Changes to color parameters: brightness, contrast, gamma, hue, saturation,
- Sharpening (or Gaussian blur),
- Improved text readability,
- Multitude of setup options,
- Support for personal fine-tuning of parameters with notepad,
- Automatic shader optimization via GLSL optimizer,
- and honestly, more. Many of the ideas come from the community.
It should work on any PC platform (tested on Linux and Windows).
How does it look? Well, you can trace most of the options in the mod readme, but here is an idea:
BGEE 1.3 (top) vs mod preset that is intended to imitate the feel:
Game without this mod (top) vs setup I use (includes Catmull-Rom, moderate color adjustment and sharpening):
Post edited by drunktiefling on
0
Comments
Unfortunately the shaders don't seem to work correctly on my games. EET and SoD just show a black screen. BG2EE shows garbled graphics (greenish misaligned textures).
Perhaps. It just interpolates colors in this application, not shapes, right? If so, it would need finding the centers of surrounding 4x4 (or just 4x1 and 1x4) pixels and doing some arithmetic that is barely more difficult than convolution via kernel.
I see that the previous BGEE releases made people love this exact method? When I get the technical stuff somewhat-together, I should give it a try.
Still, need to grab some Windows (not easy!) and figure out what's wrong with my shaders there. Or different GPU. Which is much, much worse stuff than algorithms themselves.
Don’t know if one’s better or more sophisticated than another.
Here’s some other docs, maybe you’ve seen or not:
http://www.mvps.org/directx/articles/catmull/
https://stackoverflow.com/questions/19752513/how-performing-fast-catmull-rom-texture-tiltering-by-linear-interpolations#19884005
However, the textures are 2d bitmaps in this application. I don't get to decide where the pixel centers are, it's just a property of the input data. So anything but "Uniform" Catmull-Rom would be needlessly blurry. It's better to do this properly - and if someone actually wanted blur, add it to the output (which my code can already do - negative sharpening means Gaussian Blur with radius 1).
I would prefer non-blurry. No anti-aliasing. Super sharp. I like pixels.
Be careful what you ask for. I can implement nearest neighbor for the sole purpose of pre-scale sharpening (the sane thing my code does now is doing it post-scale). It would be sharper than what the game normally does with nn setting.
But I believe we are looking for "smooth despite not losing information" (so "not blurry") as opposed to "impractically sharp".
Mod setup: Catmull-Rom interpolation + disabled outlines. Attempt to be like BGEE 1.3. Interestingly, the output is less blurry - did the original method miss the pixel centers?
Would you like to tell what parameters i have to change to achive this look? Or would you like to send me your configuration files? Your linux configuration files from drunkshaders-0alpha2 is flawless in my hardware configuration.
Which would mean that you might want to (in all files):
Please recall that the legacy games had brightness and contrast sliders, so playing with it (and gamma) wouldn't break the tradition either.
EDIT: I also read that as a feature request to make some presets to pick from in the installer. Also I guess I should get my arse together to put it on GitHub + readme on githubpages, so it's easier to review before downloading the archive.
If i disable Catmull-Rom, i have unnatural pixelated, jagged background areas.
Do you know a way to fix this issue? I would like to use Catmull-Rom interpolation.
I didn't get this exact set of errors, but I was reworking this shader regardless. Some of the original (as in: introduced with EE by Beamdog) code was... strange, full of assumptions. I'm rewriting it to keep roughly similar logic, but make the implementation way more consistent, also slightly faster. I will try to identify what could have produced such lines, to make sure it is fixed in the next update, which will be pushed soon.
May I assume that you are getting this with the version from the post (0alpha4)?
That's correct
I play with active Scaling user interface (PC-win10, intel 10850, geforce 660 gtx)
I should push something new in 1-2 days. For now, I identified an interesting set of malicious cases (when I fix some of them, the others start glitching). The Beamdog code is messy, as it forces the least appealing linear sRGB mixing possible (no matter of the game settings) using the shader code rather than sampler. So I really dislike it and I want to rewrite it. Also, the rewrite is necessary to get C-R for maps at all.
@Parys , I would be interested if it fixes your issue.
@Allanon81 preferably, also in terms of performance. Of course AI scaling would be better than just denoising and then scaling, but... We would need to have a simple-enough pretrained model (perhaps as GLSL function? or with layers implemented as such?).
Collecting data for training a model exactly for this need would be mostly impossible, since the 3D data on the models is known to be unavailable even to Beamdog. Unless you have funds to employ a crowd of artists to create a training set by hand.
I am impressed that the previously pixelated animations of torches, mephit portals in irenicus dungeons level 2, and many many others, are now smoothed out, as in version 1.3. I played with catmullrom interpolation enabled in every glsl file.
The backgrounds are no longe jagged. There is no graphical artifacts on the backgrounds.
I've encountered a few minor glitch on animated objects, though:
In BG1 i have no found any such distortions or graphic artifacts yet.
My Pc specs: Win10, Intel i9-10850k, GTX660, Dispaly 1080x1200, Scale User interface option is turned on.
Nevertheless, this mod is a must-have addition to the game for me. These small inconveniences are faded away in the advantages your mod provides.
Your mod is no longer drunk. It becames more sober with each successive version
Kind regards.
I really like the choice of glitches you identified, as they seem mutually different (perhaps a tile with an object, then just a memory-broken tile, and finally - a non-rectangle edge rendered wrong! I hope I will manage to reproduce each case). Is that Aran's place, second floor of Harpers' place, and obvious front of Talos temple, did I get this right?
But getting maps with C-R and no glitches should be possible. I'm working on it, and that's thanks to your report!
In general, it's a regression that we can't use different color settings for UI and maps, but that's how the engine works. At least now we are aware of that.
I really, really liked my item stack count fonts to have lower gamma. Especially since I use Infinity UI++, which doesn't use the squarish bitmaps of the original releases. So one of the options is just a a dirty fix for that exact scenario.
I noticed that the rendering of graphics has been improved. The selection circles and movement maker have become sharper. And rendering of sprites get better! I did not think it could be improved. Hats off to you.
Only the small colored lines on the hearth animation at the harpists' headquarters remain.
If fixing this minor bug would cause deteriorate of the sprites, selection circles and background rendering, please don't fix it
Have a nice day!
And the bottom border of object tiles is tricky, as I can't reproduce the effect from your screenshots. Sometimes I can observe some thin lines (way less than would be one pixel before scaling), but interestingly, they are there with a clean install as well. I will pray to Tymora and trace how is could be logically possible. I guess that if you removed fpdraw.glsl from your override directory, you would get pixelated objects, but no broken lines?