-
-
Notifications
You must be signed in to change notification settings - Fork 214
Refactor UI Invert Alpha to slider and migrate config #390
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
Refactor UI Invert Alpha to slider and migrate config #390
Conversation
Changed UI Invert Alpha from a boolean toggle to a float slider (0.01-0.99) for finer control. Added migration logic to handle legacy config values, updated shader and D3D12 blend logic to use the new alpha value, and refactored related code and UI. Also added 2 new options for those without touchpads such as reverbg2 (thanks wdoo2 for this), and improved DPad gesture handling and snapturn logic in VR mod. If needed to split up into two different pull requests I can do that as well
|
Co-pilot structured notes which are more clearly detailed: The pull request Refactor UI Invert Alpha to slider and migrate config introduces a series of significant changes and improvements. Below is a detailed explanation of the changes and their respective results: Overview of Changes
• Previously: The “Invert Alpha” setting was a simple boolean toggle (true or false). • Now: It has been refactored to a float slider ranging from 0.01 to 0.99. This provides finer control over the alpha inversion instead of a binary behavior.
• Added logic to handle existing (legacy) boolean profiles. • These profiles are automatically migrated to the new float slider format.
• Previously: Alpha blending was hardcoded to fully invert or not invert. • Now: Allows partial alpha inversion by using blend factors instead of hardcoded values. The new design permits gradual mixing between straight and inverted alpha by blending via the GPU.
• Introduced new shortcuts for devices lacking touchpads (e.g., Reverb G2, Pico): • Left joystick click combined with right joystick direction. • Right joystick click combined with left joystick direction.
• Improved DPad gesture handling and snapturn mechanics in VR mode.
• Changed from Shader Model 5.0 (ps_5_0) to Shader Model 6.0 code generated with DXC 1.8. • Maintains compatibility with modern Direct3D 11/12 systems (Windows 10/11).
• Previously: The wmic command was used in makecommithash.bat (now deprecated). • Now: It has been replaced with a PowerShell Get-Date invocation to generate commit hash timestamps.
• Verified functionality on several games, including: • Persona 3. • Professional Baseball Spirits 2024-2025. • Games that had invisible or partially visible UI before no longer exhibit such issues. • No detected regressions after testing. Breakdown of Impact and Results
• Before: Only binary behavior for alpha inversion, limited scenarios where it could be useful. • After: The float slider enables precise control, unlocking more nuanced visual effects. Users can fine-tune transparency levels in a flexible manner.
• Before: Profiles saved with the boolean toggle could break or require manual intervention if changes occurred. • After: Seamless migration of existing configurations ensures backward compatibility while introducing new features.
• Before: Alpha blending logic fully inverted the texture or not at all. Required complete re-rendering for modifications. • After: The updated shader introduces smooth transitions with partial alpha inversion, enhancing the visual fidelity. Compatibility remains intact for modern Direct3D environments.
• Before: Relied on older shader models (ps_5_0). • After: Updates to Shader Model 6 provide better optimization for modern hardware and operating systems.
• Before: Devices without touchpads faced functional limitations. • After: New input combinations resolve usability issues, making the VR mod accessible to a broader range of hardware.
• Before: Deprecated tools (wmic) risked failures in the build process on modern systems. • After: Resilient scripting via PowerShell ensures compatibility with current tools and environments.
• Before: UI was sometimes not visible under specific conditions in games. • After: Fixed rendering issues, guaranteeing consistent UI visibility. Results for Users and Developers • Enhanced User Experience: • Precise alpha adjustments with the slider improve customization. • Improved input handling benefits a broader audience. • Performance and Compatibility: • Shader optimizations and migration logic ensure forward-compatibility without breaking backward compatibility. • Developer Productivity: • Streamlined configuration migration and updated tooling reduce maintenance overhead. This PR represents broad improvements in configurability, compatibility, visual fidelity, and user accessibility. It also incorporates strong backward compatibility assurances, ensuring a smooth transition for users of previous versions |










Changed UI Invert Alpha from a boolean toggle to a float slider (0.01-0.99) for finer control. Added migration logic to handle legacy config values, updated shader and D3D12 blend logic to use the new alpha value, and refactored related code and UI. Handles existing profiles if still boolean, and migrates to float once injected/updates profile with float value.
Also added 2 new options for those without touchpads such as reverbg2 and pico (thanks wdoo2), which is left joystick click + right joystick direction and right joystick click left joystick direction. a little improved DPad gesture handling and snapturn logic in VR mod. Finally, fixed the hash commit make from failing due to deprecation of wmic
If needed to split up into two different pull requests I can do that as well. tested on multiple games such as Persona 3 and Professional Baseball Spirits 2024-2025 which before the UI was not visible in certain scenes or at all. Have not noticed any regressions yet. Open to suggestions or changes.
Changes:
makecommithash.bat:
Replaced the deprecated wmic call with a PowerShell Get-Date invocation so MakeCommitHash.bat can still capture the current timestamp when generating CommitHash.autogenerated.
src/mods/vr/D3D12Component.cpp
Rather than a boolean “invert alpha” toggle, the code pulls a float “invert amount” from OverlayComponent, clears the UI texture to that alpha, and uses render_srv_to_rtv with custom blend factors/tints so partial inversion (0.01–0.99) is possible; the alpha-inversion blend state now uses blend factors instead of hardcoded one/zero so the GPU can mix between straight and inverted alpha.
src/mods/vr/OverlayComponent.cpp
Replaces the legacy boolean UI_InvertAlpha config load/save with slider-aware logic: it clamps defaults, attempts to migrate floats/strings/booleans, reserializes when conversions occur, and draws the new slider without the extra SameLine. Added parsing helpers so legacy boolean or string UI invert alpha values are trimmed, normalized, and migrated into the clamped slider range, ensuring existing profiles surface the numeric control without crashing during load.
src/mods/vr/OverlayComponent.hpp
now exposes get_ui_invert_alpha() returning a clamped float, tracks when/if a previous/existing profile is used in true/false manner and requires reserialization, and swaps the ModToggle for a ModSlider spanning 0.01–0.99.
src/mods/vr/d3d12/DirectXTK.cpp and DirectXTK.hpp
All render_srv_to_rtv overloads accept optional blend factors and tint colors, applying them via OMSetBlendFactor/SpriteBatch::Draw so callers such as D3D12Component can blend UI alpha without copying textures.
src/mods/vr/shaders/alpha_luminance_sprite_ps.fx
The pixel shader now lerps between the original and inverted alpha based on the color.a tint parameter (driven by the imgui slider after injection, or before injection by defining value), preserving RGB multiplication with the tint color; before, always fully inverted alpha (or fully did not) and multiplied the entire float4 by color.
src/mods/vr/shaders/Compiled/alpha_luminance_sprite_ps_SpritePixelShader.inc
Corresponding compiled shader blob has been regenerated with DXC 1.8, reflecting the new lerp logic and color.a usage, whereas previously, it still contained the legacy ps_5_0 disassembly guarded by #if 0
More on the shader refactoring:
The new shader shipped in this is DXIL/Shader Model 6.0 code generated by dxc v1.8.2505.1, as shown by the metadata at the top of alpha_luminance_sprite_ps_SpritePixelShader.inc (target triple = "dxil-ms-dx" and dx.shaderModel = !"ps", i32 6, i32 0). previously, it was shader model 5 ps_5_0 MS Shader disassembly.
In regards to compatibility using this vs previous shader model 5:
Direct3D 11 on modern Windows 10/11 builds has been able to load DXIL shaders since the Fall Creators Update (1709) provided that the graphics driver advertises Shader Model 6 support, so every DX11 game running on a supported OS/GPU stack will accept this blob just like the old FXC-compiled DXBC version.
Because the input/output signatures and resource bindings are unchanged (still COLOR+TEXCOORD inputs, SV_Target output, Texture/Sampler bindings) the engine sees exactly the same interface and won’t need any code changes beyond shipping the new bytecode. The only difference is the alpha math inside the shader, which is a legal instruction sequence for both D3D11 and D3D12 drivers.
The only time you’d see problems is if someone tried to run on an older Windows 7/8-era DX11 stack or a very old GPU driver that never picked up DXIL support; those environments can only consume DXBC blobs, so they would fail to create the shader. On the OS/GPU targets UEVR already requires (Windows 10+ with reasonably recent drivers), the DXIL blob is fully supported, so DX11/D3D11 games should keep working normally, and has been in my testing