Skip to content

[MOD] Sharpening filter, BGEE1.3-like look and more via shaders

2»

Comments

  • Allanon81Allanon81 Member Posts: 342
    Very happy to see this cooking!
  • drunktieflingdrunktiefling Member Posts: 39
    edited September 2023
    @Parys I can't reproduce your issue, but. I've managed to scrap a heuristic method that matches the bottom and right corners of object tiles.

    Rare false positives exist, but they are never grouped in the same place, so they shouldn't affect the general impression. Here is the code that avoids going out of "probable border" - I will push it to the repo if it makes the change. The new code is on the repo, so please test version 0.2.4.

    Could you please test it (rename as fpdraw.glsl and put in override)?

    Anyone who experiences issues similar to @Parys is welcome to participate in this test too.

    EDIT: no attachment is needed anymore. I was able to get similar errors with some spell animations, and the new code is definitely worth pushing, as it resolves that set of issues. It very well might address your issues as well.
    Post edited by drunktiefling on
  • drunktieflingdrunktiefling Member Posts: 39
    edited September 2023
    The new release introduces movies support as well. They are pixelated and use dithering, so they can't be exactly made "smooth" - but they look better too!

    I was able to test fpyuv.glsl, but not fpyuvgry.glsl - it contains some interesting logic, so I would have to test it if I were to rewrite it. But I have no clue where is it used by the game. Do any of you recall a scenario where a game intentionally presents a movie in monotone?

    @argent77, you've described it as being "Used for grayscaled video output.". Could you perhaps point me to some case when it happens?
  • argent77argent77 Member Posts: 3,476
    I was able to test fpyuv.glsl, but not fpyuvgry.glsl - it contains some interesting logic, so I would have to test it if I were to rewrite it. But I have no clue where is it used by the game. Do any of you recall a scenario where a game intentionally presents a movie in monotone?

    @argent77, you've described it as being "Used for grayscaled video output.". Could you perhaps point me to some case when it happens?

    Some maps use WBM video files for background animations, special effects or tileset overlays. Especially SoD makes heavy use of it. For example, the water effects of the Coastway Crossing or Boareskyr Bridge maps are overlaid by video animations. Another example is the "shimmering heat" effect over the big chasm on the very first SoD opening dungeon map which is played back as a looped animation.

    If you enable the graphics option "Grayscale on Pause" then fpyuvgry.glsl is used for the effect. The time stop effect is most likely using it as well.
  • drunktieflingdrunktiefling Member Posts: 39
    @argent77 thanks! Testing it more on SoD should be beneficial too. I wouldn't have guessed that animations used there are movies rather than BAM sequences. But I guess that it makes some sense for large area and decent frame rate.
  • xiaoleiwenxiaoleiwen Member Posts: 195
    edited September 2023
    deleted
    Post edited by xiaoleiwen on
  • ParysParys Member Posts: 205
    I tested the latest version of the mod (version 0.2.5)
    I noticed that the sprites and paperdolls are jagged and not as smooth as before (version 0.2.3)
    The selection circles and movement maker also changed and became thicker, fuzzier.
    In the screenshot (version 0.2.5) you may notice a black line border of GUI buttons.
    The small colored lines on the hearth animation at the harpists' headquarters are gone (version 0.2.5)
    But, they randomly appear on luminous sphere animations in the tomb of gaxx in dock district (version 0.2.5)
    Could you tell me how to get a smooth look for the character sprites, paperdoll etc. in version 0.2.5?
    I am currently using 0.2.3 version.

    Regards
  • drunktieflingdrunktiefling Member Posts: 39
    edited September 2023
    Thanks for the feedback @Parys, I will look into this.

    For sprites, you can use fpsprite/fpselect from 0.2.3. I might restore that shaders to previous version, as the new features are mostly for fpdraw. I will push such a release soon.

    I will look into the issues with 0.2.5 you have listed. I will address the glitches, it can't be left like this - I can't reproduce them on any of my testing environments, so the new code was introduced in the release. However, some "fuzzier" behavior is due to false positives of the border detection heuristics. It might end up being a glitch against a glitch - if so, I will make it optional, but that would be a form of giving up, which I will try to avoid. Surrounding data for C-R or sharpen/blur can't be used blindly, yet the boundaries are provided only for fpseam (maps).

    And the concern above covers everything rendered with fpdraw shader: UI, whole inventory screen including paperdolls, object tiles, also selection circles.

    Sprites have their own shader, so might regain 0.2.3-like behavior easily. However, I have seen some lines in big sprites (dragons, demons) - so it might need further tinkering of similar sort too.

    Do you have similar issues when you disable C-R and sharpening in fpdraw (with notepad)?
  • ParysParys Member Posts: 205
    edited September 2023
    @drunktiefling
    Once again, I would like to thank you for devoting your free time to writing logic for the catmull-rom interpolation.
    However, I have seen some lines in big sprites (dragons, demons) - so it might need further tinkering of similar sort too.
    Hey, drunktiefling, this black lines bugs will be addressed in future fixpack
    take a look at it, please:
    https://www.gibberlings3.net/mods/fixes/eefp/
    https://www.gibberlings3.net/gallery/image/822-issues-with-large-creature-animations-i/
    https://www.gibberlings3.net/forums/topic/35063-bug-multi-part-area-bam-animations-show-visible-lines/#comment-323417
    https://www.gibberlings3.net/forums/topic/35260-area-dooranimation-graphic-black-lineseam-issues/#comment-309151




  • drunktieflingdrunktiefling Member Posts: 39
    @Parys wow, that's VERY useful. Especially since I've already spent some time debugging only to realize that the problem was in the data rather than my code (especially in BGGOEET - I love it and will use it regardless, but it's not free from errors).
  • drunktieflingdrunktiefling Member Posts: 39
    edited September 2023
    @Parys please try 0.2.6.1. Aside from all the glitches, I am interested in your opinion of "fuzziness". Sprites should be outright ok (I mean, besides the way how the big sprites are usually broken in EE). With fpdraw content, including paperdolls... it's a compromise.

    Harsh as it is, I would prefer no C-R and no glitches than extra lines in the wrong color caused by my shaders. I'm working on something in between - to eliminate glitches and reduce the non-C-R areas. This release is my new attempt to get better than 0.2.5 at both. It won't, however, return to 0.2.3-like completely optimistic C-R, as there would be no way to fight glitches with that approach.

    If you disagree, you can set NEEDS_HEURISTIC_BORDER to 0 in fpdraw.glsl.
    Post edited by drunktiefling on
  • ParysParys Member Posts: 205
    edited September 2023
    Hello @drunktiefling
    I have tested the mod with NEEDS_HEURISTIC_BORDER set to 1 and noticed that the details on the gui button are destroyed.

    NEEDS_HEURISTIC_BORDER set to 1:
    ytuqwkn1t0ft.png
    Also, a mage paperdoll have this glitch on his shoe:
    p7c9n35y65wc.png

    NEEDS_HEURISTIC_BORDER set to 0:
    nx7wvb1u06ld.png
    hpabevpk5c74.png

    It seems that this is true to every gui graphic component.

    Did you notice the black line on tooltips when you hover mouse cursor over NPC and then slightly move around the parchment tooltip? (It is very noticeable on parchement tooltip - default gui interface) This black horizontal line on parchment tooltips appears on every version I've tested.

    As far as black lines on animated object concerned, it seems to me that they appear less frequently, but they appear at random times. They are triggered sometimes by a casting spellI, initiation of conversation with npc, when i walked past luminous sphere animations in the tomb of gaxx. I had to restart the game to make the lines disappear. But when i only reload the save game the lines were still there. this happens regardless of whether you set the NEEDS_HEURISTIC_BORDER to 1 or 0.
    I wonder why these lines do not appear regularly.

    Have a nice day!
  • drunktieflingdrunktiefling Member Posts: 39
    edited October 2023
    @Parys you have an eye for details, thanks!

    You've convinced me that I can't afford to lose that much details. So I've simplified the logic, also reducing the most crazy attempts to fix the issues that are there in the original game shaders as well. It was possible to reduce them, but - especially with your examples in mind - I have to admit that the cost was too high.

    So, a new release just dropped. I've cleaned up the code, rewritten great portion of the stuff, so the code is somewhat shorter and easier to manage. Organization in the mod files is also simplified to avoid repetitions.

    And I've discovered something interesting. The original texture samplers are shifted (by half a pixel, in inconsistent directions) - I was able to reverse-engineer the proper values. And with this, I was able to attempt to imitate the original texture sampler based on texels, which usually gives exactly the same result, but - not in the case of memory errors! With this, I get some neat extra conditions for glitch detection, with many times less false positives. With this method and new approach, it shouldn't hit mage's boot anymore. Spell and effect icons are not damaged anymore either. And lines... should appear less often. I tried anything that glitched previously, and what I get is:
    - Smooth object tiles (as in Harpers' stove),
    - No extra lines near spell animations with transparency (e.g. Globe of Invulnerability),
    - Some lines with blended tiles such as near Kangaxx's tomb. But I get them with original game shaders too.

    And glitches like this are not systematic, but depend on the contents of GPU memory in the uninitialized regions. Getting them at random times is to be expected.

    Anyways, my next attempt dropped. I'm keenly interested in your feedback!
    Post edited by drunktiefling on
  • ParysParys Member Posts: 205
    edited October 2023
    Hi, @drunktiefling

    I am getting a black screen when launching the game. Only mouse cursor is display properly. There is no GUI element and subtitles. When I managed to load the savegame. Everething but area map background is missing. No sprites, gui, animation, etc. :(
    I tried to set "const bool uhCatmullRom" (game-header) to "true" and "false", but it didn't bring any improvement :(

    I would like to ask you, would it be possible to make character selection circles and movement maker (thickness) the same as it is in version 2.3? It has bgee1/2 patch 1.3 (catmull-rom renderer) feeling/vibe.
    Currently, I use version 2.3 because of it. I really like the way they are displayed (sprites and character selection circles etc.)

    In version 3.0, you mentioned that you were able to fix many bugs ( Smooth object tiles (as in Harpers' stove), no extra lines near spell animations with transparency (e.g. Globe of Invulnerability), some lines with blended tiles such as near Kangaxx's tomb.) Would it be possible to incorporate those fixes in version 2.3 and retain sprites and character circles rendering? Version 2.3 on my PC configuration is visually perfect for my eyes and I play this version all the time. I thank you very much for it :)
    And it will be my pleasure to test future versions of the mod.

    Best Regards,
  • drunktieflingdrunktiefling Member Posts: 39
    @Parys black screen means that game/GPU was unable to run the shader. Which is sorta bad, as I have two setups that act differently in this regard, and both work. I will prepare one more to check it.

    Also, were the selection circles still broken in 0.2.6.1? I will take some screenshots to confirm. In general, there was nothing special in 0.2.3. It just mostly ignored glitches related to probing data outside the implicit tile borders. Anyways, 0.3.x is supposed to get stuff like selection circles perfectly similar to the original game, due to the offsets I wrote about.
  • drunktieflingdrunktiefling Member Posts: 39
    Oh, and if you recall or can check, @Parys - does the intro movie display properly with 0.3.0?
  • drunktieflingdrunktiefling Member Posts: 39
    @Parys. on
    I would like to ask you, would it be possible to make character selection circles and movement maker (thickness) the same as it is in version 2.3? It has bgee1/2 patch 1.3 (catmull-rom renderer) feeling/vibe.
    Currently, I use version 2.3 because of it. I really like the way they are displayed (sprites and character selection circles etc.)

    I've managed to find the reason. It was not an attempt to get BGEE1.3-like look, but a failed experiment at something unrelated (like glitch near the Talos temple - change to selection circles was a side effect). Essentially, a bug. It caused issues, including unidentified items being barely visible as such. There is no straightforward way to separate one thing from another. However, I can look into it, and make it an option. I don't like some of the results, but none of them is game-breaking, so why not.

    Bad news is that I remain blind with regards to why would it be broken. Information about the movies might help. Regardless, I should push a new release in a moment (I have some faint ideas on what to try). If it remains broken, would you have a while to run like 10-15 versions of the shader and check which one is broken? If nothing else works, that would narrow it down to one function rather than being broken "somewhere" among the 450 lines of code.
  • drunktieflingdrunktiefling Member Posts: 39
    edited October 2023
    And here it goes, 0.3.1.

    With a new feature to "Make sprite selection circles thinner and object selection highlight more transparent", which restores the 0.2.3 "bug" for selection circles. It tries not to affect much else, but, according to the name, there are some effects that share exactly the same context from the shader perspective.
  • ParysParys Member Posts: 205
    edited October 2023
    Hello, @drunktiefling
    Thank you for the explanation!
    And here it goes, 0.3.1.

    With a new feature to "Make sprite selection circles thinner and object selection highlight more transparent", which restores the 0.2.3 "bug" for selection circles. It tries not to affect much else, but, according to the name, there are some effects that share exactly the same context from the shader perspective.

    Ha, "That's not a bug, that's a feature!" I would say :)
    I'm glad there is an option to do this as an optional component.

    Ok, When I put all these files from version 0.3 or 0.3.1 in to override directory, I have a black screen. No movies are playing. This happens regardless of whether I set const bool uhCatmullRom option to true or false. Only mouse cursor is display properly (Probably because Hardware mouse cursor option is enable)


    If it remains broken, would you have a while to run like 10-15 versions of the shader and check which one is broken? If nothing else works, that would narrow it down to one function rather than being broken "somewhere" among the 450 lines of code.

    Of course, I am eagerly awaiting these files. I would like to help to resolve this black screen issue and enjoy the new versions of your mod.
  • drunktieflingdrunktiefling Member Posts: 39
    @Parys if you can clarify... you are installing it with WeiDU, right?
  • ParysParys Member Posts: 205
    @drunktiefling
    no, i grab them from: drunkshaders-0.3.1.zip\drunkshaders\glsl
  • drunktieflingdrunktiefling Member Posts: 39
    edited October 2023
    Oh, that info really helps! So I could debug your black screen as long as I want to.

    Starting from 0.3, you should use WeiDU. 85% of the code is shared by 6 shaders, so I've made the installer compose code from multiple parts. Perhaps I should rename them in the mod files not to make an impression they are supposed to be copied like that. They are incomplete by design.
  • ParysParys Member Posts: 205
    Starting from 0.3, you should use WeiDU.
    ok, got it!
  • ParysParys Member Posts: 205
    edited October 2023
    @drunktiefling
    Your mod works!! It's just that I didn't install it properly
    I have installed shaders via Weidu installer and it's ok!
    But my game slow down much. i chose pre-defined selection 1, 2 and 9, but the game keeps slowing down. (in area map, in inventory window, everywhere)
    I even tried set the #define NEEDS_HEURISTIC_BORDER in fpdraw.glsl to 0
    but it did not bring any improvement.

    I'm sorry I wasted your time on unnecessary debugging process.
  • drunktieflingdrunktiefling Member Posts: 39
    @Parys ok, that's something I will look into. It's structurally simpler than previous versions, but there is some room for improvement, if I were to seriously avoid every unnecessary instruction. Or be actually serious and do benchmarks. Nice that you've checked with that flag too! That would be literally the first thing I would check in different setups.
  • drunktieflingdrunktiefling Member Posts: 39
    @Parys perhaps 0.3.2 would fix it? I didn't get any serious benchmark tools, and the game typically has a limit at 90FPS... but with this version, this 90 is smooth in my setup. Which is a change, as 0.3.1 peaked at 55.
  • ParysParys Member Posts: 205
    Hello @drunktiefling
    Yes, version 0.3.2 fixed the slow down issue. But when i pick any item up from inventory screen and move the mouse quickly then item does not keeping up with these movemement. You get the feeling that the item moves slower than the cursor.
    But other than that, performance has returned to normal.
    I prefer to play without the NEEDS_HEURISTIC_BORDER option enabled. The Heuristic option sharpens the animated object (torches, and the like), spells, and sprites. etc. I prefer more smoothed look, just like in bgee 1.3. I noticed that the lines on parchement tooltips are thinner with NEEDS_HEURISTIC_BORDER set to 1, almost invisible. But there are still on spells like fireshield (flame animation).
    Great job, there are a lot of predefined selection from which everyone can choose something for themselves.
    Would you like to tell me how to activate thinner sprite circles? I chose component number 1 (c-r everywhere).

    Have a nice day!
  • drunktieflingdrunktiefling Member Posts: 39
    @Parys great review! I will look into "items moving slower than the cursor". Perhaps hardware cursor which you have mentioned has something to do with it.

    Your notes on NEEDS_HEURISTIC_BORDER are interesting. Sharpening, huh? I guess some of the pixels included in the side effect can be called that. I don't think I can reduce it without adding glitches. Perhaps I will break the "heuristic" features into more flags and add installer options for them.

    And you can get your thick border by manual component selection and picking "1" in the last question, or changing uhSelectionGamma to 2.0 in fpdraw.glsl (after installation). You can play with this value, but in general, for thinner circles you want more than 1.0.
  • drunktieflingdrunktiefling Member Posts: 39
    edited October 2023
    New release (0.3.3) just dropped. Added a preset dedicated to @Parys (I hope I've deducted it right from your reviews), fixed sharpening, potentially fixed thin sprite outlines mode (my checks were too strict and it had no effect sometimes) - that would be minor changes.

    Major change is about performance. I've played with glslopt tool, and I made sure that my shaders behave well after being processed by it. Replaced most (and after optimization - all) the conditional statements with different methods. Which is very much relevant, as this release comes with glslopt that can be applied after all the previous components!

    If you want to play with notepad, you should install everything else, edit the values, and then install the glslopt component. It's separate from the quick menu presets, so you don't need to rethink your choices and risk the loss of manual changes to do this. You can uninstall it to play with notepad again and then reapply it at any time. Because of this, it is recommended to leave it very late in the install order (definitely after stuff like EET_end).

    Of course, if you play with notepad a lot, you can leave it uninstalled. It makes things faster, but your GPU driver should optimize the shaders somewhat anyways.

    Also thanks to @argent77 for a7_tools.tpa library. It made distribution and calling external binaries for multiple platforms perfectly straightforward!
  • drunktieflingdrunktiefling Member Posts: 39
    Release 0.3.4 is there. I have rewritten the outlines to actually understand the context between pixels (it actually approximates the sprite shape, rather than follow its pixels).

    Also readme got heavily updated. And I've made the main post of this thread somewhat concise and clear.
Sign In or Register to comment.