Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Waifu2X to enlarge background image #412

Merged
merged 11 commits into from
Mar 5, 2024
Merged

Use Waifu2X to enlarge background image #412

merged 11 commits into from
Mar 5, 2024

Conversation

shatyuka
Copy link
Contributor

@shatyuka shatyuka commented Mar 1, 2024

More testing is still needed, especially for old PCs.

Comparison:

cubic waifu2x
cubic_1 waifu2x_1
cubic_2 waifu2x_2

native source code here

Copy link

github-actions bot commented Mar 1, 2024

Qodana for .NET

It seems all right 👌

No new problems were found according to the checks applied

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Contact Qodana team

Contact us at qodana-support@jetbrains.com

@Cryotechnic
Copy link
Collaborator

Just chiming in to give my own 2 cents, but Waifu2X can be resource intensive depending on the image resolution, so I would not recommend using machines that do not have the following specifications:

  • Supported OS (Win10+)
  • Supported GPU, this one is hard to quantify but looking at the page, an AMD R7-1700 and a GTX 1070 worked, so I believe anything that gives around the same level of performance would be acceptable. We would probably need to have some form of exception handling to handle cases where resource usage is too high, in which case, we would terminate the task and simply load the default image.
  • A somewhat recent version of any drivers

I think that covers it?

@bagusnl
Copy link
Member

bagusnl commented Mar 1, 2024

Just chiming in to give my own 2 cents, but Waifu2X can be resource intensive depending on the image resolution, so I would not recommend using machines that do not have the following specifications:

As long as its toggleable between the current implementation (MagicScaler) and w2x I'm fine with it. Especially due to the nature of w2x

As for minimum specs, since the binary used is ncnn it just need Vulkan support, and if you can run hpyo games without any intervention it should be all ok. Tho a proper check if vulkan is available when toggling it on (like invoking vulkaninfo and just looking for the ERRORLEVEL shall do IMO).

Also do note that some AMD iGPU users like me suffers a driver degradation where any ncnn scaler will give a blank 0b output without the ncnn giving out error itself, so you might want to check if the output is a valid image and do a proper fallback when it doesn't

@bagusnl bagusnl added Enhancement New feature or request Area: Runtime Issue labeled for runtime, Hi3Helper.Core and other libraries used by Collapse Area: UI/UX Issue labeled for User Interface/eXperience related issue labels Mar 1, 2024
@shatyuka
Copy link
Contributor Author

shatyuka commented Mar 2, 2024

Just chiming in to give my own 2 cents, but Waifu2X can be resource intensive depending on the image resolution, so I would not recommend using machines that do not have the following specifications:

In fact, Collapse can only run on systems above Windows 10, so in most cases there is no need to consider system version compatibility issues.

For supported GPUs, I think this is already checked in native. For example, the Vulkan Loader (vulkan-1.dll) fails to load, or the Vulkan api returns an error code. This toggle is disabled when native library fails to load.

Also I will add some extra checks for black or corrupted image.

We will not get pixelated image using MagicScaler
Copy link
Member

@bagusnl bagusnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested done internally and works great for both CPU only (might be REALLY slow) and GPU mode :fuhuayatta:
Some inputs ahead~

CollapseLauncher/Assets/Models/scale2.0x_model.bin Outdated Show resolved Hide resolved
{
try
{
_context = waifu2x_create(gpuId, ttaMode, numThreads);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per discussion internally, please add debug/info log around when w2x is invoked as it can take a bit of time, so the user that seeing the console can understand that its actually doing it instead of the image failed to load.

@bagusnl
Copy link
Member

bagusnl commented Mar 5, 2024

Can I get the source for the OpenMP? I need the license file to be added manually as its not from NuGet

@shatyuka
Copy link
Contributor Author

shatyuka commented Mar 5, 2024

Can I get the source for the OpenMP? I need the license file to be added manually as its not from NuGet

https://github.com/llvm/llvm-project/blob/main/openmp/LICENSE.TXT

libomp binary file is copied from vcredist

@bagusnl
Copy link
Member

bagusnl commented Mar 5, 2024

Tested and works great!

image

As per internal discussion, we can merge this PR now~
Thank you for your work

@bagusnl bagusnl merged commit 7b3108b into main Mar 5, 2024
4 checks passed
@shatyuka shatyuka deleted the waifu2x branch March 7, 2024 19:48
bagusnl added a commit that referenced this pull request Mar 9, 2024
* [skip ci] Update README.md

* Clamp column width if there is no space left

This to fix the DataTable component causing a crash due to negative value if small window mode is used.

* Enable Rich Presence only after the activated region is set

might fix #402

* Fix blurry console icon

Also, get the icon from exe rather than a separate ico file

* (CodeQA) Theme xaml

* Move RPC dispose

Adjusted to be in the same file where it is initialized (448ff77)

* Change default value displayed for ```Download Threads``` to match the real default value

* Auto resize DataTable column width using star

L.CRC and R.CRC are hidden in small window mode before this commit.

* [skip ci] Update LICENSE and its references

* [skip ci] Update SECURITY.md
- Added @shatyuka and @gablm to the active maintainers list
- Update supported version section

* [skip ci] Sync translation Translate en_US.json in zh_CN

100% reviewed source file: 'en_US.json'
on 'zh_CN'.

* HI3 Senadina Game Settings Adjustments (#417)

* (GSP) HI3: Adjust to new version

* [skip ci] Add more abbreviation list

* Use ShouldComputeInputPris on build
To try mitigate resource not found error

* (GSP) More Hi3 Senadina backend changes

* (GSP) Force GraphicsGrade to 6 on Save

* (GSP) Docs

* (GSP) Senadina frontends

and localization

* (GSP) Disable preset

* CodeQA stuff

* Fix crash due to value not exist for ``GraphicsReflectionQuality``

* Move and change Physics toggle to ``ToggleSwitch``

* review adjustments

* Review adjustment
- Use comparedTo instead of TypeExtensions for Equals() in PhysicsSimulation.cs
- Adjustment on comparedTo in GraphicsGrade.cs
- Remove unnecessary int declaration in Honkai\RegistryClass\Enums.cs

---------

Co-authored-by: Kemal Setya Adhi <dev.kemalsetyaa@gmail.com>
Co-authored-by: Ron Friedman <cryogen65@gmail.com>

* Add delay for GameBoost

Adding 10 seconds before changing the priority to allow for the process to initialize.
Also move to its own method to avoid error mixed up with main game launching method error(s).
Also also, fix some code QA problems on the changed section because might as well :ahuehue:

* Update WindowsAppSDK to 1.5.0

Related #418

* (DiscordRPC) Reset `_firstTimeConnect` for new client

* Use Waifu2X to enlarge background image (#412)

* Use Waifu2X to enlarge background image

* More checks

* Resize to window size

We will not get pixelated image using MagicScaler

* Code cleanup

* Rename models folder name

* Add some useful logs

* Auto detect GPU

discrete > integrated > others

* Enable OpenMP for speed

* [skip ci] Add WAIFU2X.LICENSE and OPENMP.LICENSE

* Minor fixes

---------

Co-authored-by: Bagus Nur Listiyono <dzakibagus@gmail.com>

* [skip ci] Use ex variable on GameBoost_Invoke

oops...

* (CodeQA) SettingsPage

- Change copyright year
- Sync maintainers
- Suppress null scans (take it ReSharper!)
- Suppress unrelated Xaml warnings

* Stop "open -p" from starting a game when not updated

* (Waifu2X) Fix failed test log

* [skip ci] Sync translation Translate en_US.json in es_419

100% reviewed source file: 'en_US.json'
on 'es_419'.

* [skip ci] Sync translation Translate en_US.json in ja_JP

100% reviewed source file: 'en_US.json'
on 'ja_JP'.

* (Waifu2X) Fix crash on exit

* [skip ci] Sync translation Translate en_US.json in zh_CN

100% reviewed source file: 'en_US.json'
on 'zh_CN'.

* Fix CustomBG checkbox logic

:derp:

* Fix Level of Detail setting order for Hi3

* Read the cache reference from stream for Hi3

* Keyboard Shortcut improvements (#416)

* Revamp how shortcuts are saved and fix UI margins

* Convert old shortcut list

* Minor refactor + Fix KbShortcut related flyout crash

* Allow localization of VirtualKeyModifiers

* Remove invalid shortcuts and save if the dictionary is altered

* Qodana

* Parse kbshortcuts .ini only when enabling the shortcuts

* Turn DefaultShortcutList into a readonly field

* (KbShortcuts) Get GameCount and MaxRegions from Metadata

* Remove Equals/HashCode and directly compare values

* Update KeyboardShortcuts.cs

* No possible multiple enumerations while loading shortcuts

* Fix validity check for new shortcut combinations

* (KeyboardShortcut) CodeQA

- Suppress null warnings
- Wrap long lines
- Remove unnecessary statement

* (KeyboardShortcut) CodeQA part 2

Bc no save :(

* (Keyboard Shortcut) Fix opacity animation

---------

Co-authored-by: Bagus Nur Listiyono <dzakibagus@gmail.com>

* [skip ci] Sync translation Translate en_US.json in es_419

100% reviewed source file: 'en_US.json'
on 'es_419'.

* [skip ci] Sync translation Translate en_US.json in ja_JP

100% reviewed source file: 'en_US.json'
on 'ja_JP'.

* [skip ci] Sync translation Translate en_US.json in zh_CN

100% reviewed source file: 'en_US.json'
on 'zh_CN'.

* [skip ci] Bump version

* Add function to launch game in alt (legacy Collapse) launch mode

* Update NuGet(s)
- MagicScaler 0.14.0 -> 0.14.2
https://github.com/saucecontrol/PhotoSauce/releases/tag/v0.14.1
https://github.com/saucecontrol/PhotoSauce/releases/tag/v0.14.2

- BuildSDK

* Small refactor on HomePage.StartGame
- Avoid multiple call on the same parameter
- Avoid unnecessary call on unused parameter
- Use async overload when disposing ResizableWindowHookToken
- Avoid NRE if WatchOutputLog is unexpectedly cancelled before the time
- Suppress some NRE

---------

Co-authored-by: Ron Friedman <9833218+Cryotechnic@users.noreply.github.com>
Co-authored-by: Kemal Setya Adhi <dev.kemalsetyaa@gmail.com>
Co-authored-by: Gabriel Lima <44784408+gablm@users.noreply.github.com>
Co-authored-by: Shatyuka <958182453@qq.com>
Co-authored-by: transifex-integration[bot] <43880903+transifex-integration[bot]@users.noreply.github.com>
Co-authored-by: Ron Friedman <cryogen65@gmail.com>
bagusnl added a commit that referenced this pull request Mar 9, 2024
* [skip ci] Update README.md

* Clamp column width if there is no space left

This to fix the DataTable component causing a crash due to negative value if small window mode is used.

* Enable Rich Presence only after the activated region is set

might fix #402

* Fix blurry console icon

Also, get the icon from exe rather than a separate ico file

* (CodeQA) Theme xaml

* Move RPC dispose

Adjusted to be in the same file where it is initialized (448ff77)

* Change default value displayed for ```Download Threads``` to match the real default value

* Auto resize DataTable column width using star

L.CRC and R.CRC are hidden in small window mode before this commit.

* [skip ci] Update LICENSE and its references

* [skip ci] Update SECURITY.md
- Added @shatyuka and @gablm to the active maintainers list
- Update supported version section

* [skip ci] Sync translation Translate en_US.json in zh_CN

100% reviewed source file: 'en_US.json'
on 'zh_CN'.

* HI3 Senadina Game Settings Adjustments (#417)

* (GSP) HI3: Adjust to new version

* [skip ci] Add more abbreviation list

* Use ShouldComputeInputPris on build
To try mitigate resource not found error

* (GSP) More Hi3 Senadina backend changes

* (GSP) Force GraphicsGrade to 6 on Save

* (GSP) Docs

* (GSP) Senadina frontends

and localization

* (GSP) Disable preset

* CodeQA stuff

* Fix crash due to value not exist for ``GraphicsReflectionQuality``

* Move and change Physics toggle to ``ToggleSwitch``

* review adjustments

* Review adjustment
- Use comparedTo instead of TypeExtensions for Equals() in PhysicsSimulation.cs
- Adjustment on comparedTo in GraphicsGrade.cs
- Remove unnecessary int declaration in Honkai\RegistryClass\Enums.cs

---------

Co-authored-by: Kemal Setya Adhi <dev.kemalsetyaa@gmail.com>
Co-authored-by: Ron Friedman <cryogen65@gmail.com>

* Add delay for GameBoost

Adding 10 seconds before changing the priority to allow for the process to initialize.
Also move to its own method to avoid error mixed up with main game launching method error(s).
Also also, fix some code QA problems on the changed section because might as well :ahuehue:

* Update WindowsAppSDK to 1.5.0

Related #418

* (DiscordRPC) Reset `_firstTimeConnect` for new client

* Use Waifu2X to enlarge background image (#412)

* Use Waifu2X to enlarge background image

* More checks

* Resize to window size

We will not get pixelated image using MagicScaler

* Code cleanup

* Rename models folder name

* Add some useful logs

* Auto detect GPU

discrete > integrated > others

* Enable OpenMP for speed

* [skip ci] Add WAIFU2X.LICENSE and OPENMP.LICENSE

* Minor fixes

---------

Co-authored-by: Bagus Nur Listiyono <dzakibagus@gmail.com>

* [skip ci] Use ex variable on GameBoost_Invoke

oops...

* (CodeQA) SettingsPage

- Change copyright year
- Sync maintainers
- Suppress null scans (take it ReSharper!)
- Suppress unrelated Xaml warnings

* Stop "open -p" from starting a game when not updated

* (Waifu2X) Fix failed test log

* [skip ci] Sync translation Translate en_US.json in es_419

100% reviewed source file: 'en_US.json'
on 'es_419'.

* [skip ci] Sync translation Translate en_US.json in ja_JP

100% reviewed source file: 'en_US.json'
on 'ja_JP'.

* (Waifu2X) Fix crash on exit

* [skip ci] Sync translation Translate en_US.json in zh_CN

100% reviewed source file: 'en_US.json'
on 'zh_CN'.

* Fix CustomBG checkbox logic

:derp:

* Fix Level of Detail setting order for Hi3

* Read the cache reference from stream for Hi3

* Keyboard Shortcut improvements (#416)

* Revamp how shortcuts are saved and fix UI margins

* Convert old shortcut list

* Minor refactor + Fix KbShortcut related flyout crash

* Allow localization of VirtualKeyModifiers

* Remove invalid shortcuts and save if the dictionary is altered

* Qodana

* Parse kbshortcuts .ini only when enabling the shortcuts

* Turn DefaultShortcutList into a readonly field

* (KbShortcuts) Get GameCount and MaxRegions from Metadata

* Remove Equals/HashCode and directly compare values

* Update KeyboardShortcuts.cs

* No possible multiple enumerations while loading shortcuts

* Fix validity check for new shortcut combinations

* (KeyboardShortcut) CodeQA

- Suppress null warnings
- Wrap long lines
- Remove unnecessary statement

* (KeyboardShortcut) CodeQA part 2

Bc no save :(

* (Keyboard Shortcut) Fix opacity animation

---------

Co-authored-by: Bagus Nur Listiyono <dzakibagus@gmail.com>

* [skip ci] Sync translation Translate en_US.json in es_419

100% reviewed source file: 'en_US.json'
on 'es_419'.

* [skip ci] Sync translation Translate en_US.json in ja_JP

100% reviewed source file: 'en_US.json'
on 'ja_JP'.

* [skip ci] Sync translation Translate en_US.json in zh_CN

100% reviewed source file: 'en_US.json'
on 'zh_CN'.

* [skip ci] Bump version

* Add function to launch game in alt (legacy Collapse) launch mode

* Update NuGet(s)
- MagicScaler 0.14.0 -> 0.14.2
https://github.com/saucecontrol/PhotoSauce/releases/tag/v0.14.1
https://github.com/saucecontrol/PhotoSauce/releases/tag/v0.14.2

- BuildSDK

* Small refactor on HomePage.StartGame
- Avoid multiple call on the same parameter
- Avoid unnecessary call on unused parameter
- Use async overload when disposing ResizableWindowHookToken
- Avoid NRE if WatchOutputLog is unexpectedly cancelled before the time
- Suppress some NRE

---------

Co-authored-by: Ron Friedman <9833218+Cryotechnic@users.noreply.github.com>
Co-authored-by: Kemal Setya Adhi <dev.kemalsetyaa@gmail.com>
Co-authored-by: Gabriel Lima <44784408+gablm@users.noreply.github.com>
Co-authored-by: Shatyuka <958182453@qq.com>
Co-authored-by: transifex-integration[bot] <43880903+transifex-integration[bot]@users.noreply.github.com>
Co-authored-by: Ron Friedman <cryogen65@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Runtime Issue labeled for runtime, Hi3Helper.Core and other libraries used by Collapse Area: UI/UX Issue labeled for User Interface/eXperience related issue Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants