Files
MinecraftConsoles/Minecraft.Client/Common/PostProcesser.h
MrTheShy e2adaa082c Fix split-screen UI wrong positioning on window resize (#989)
* Fix split-screen UI wrong positioning on window resize

In vertical split at window heights below 1080, ComputeTileScale's min-scale clamp (>= 1.0) prevented the SWF from scaling down to fit, cropping the bottom and causing repositionHud to shift HUD elements downward. Chat and Tooltips additionally applied an offset from ComputeSplitContentOffset that only produced correct values at the 1920x1080 design resolution.

Override the scale for vertical split so the SWF fits the full window height when it is shorter than the movie. Remove the broken content offset from Chat and Tooltips -- the tile crop already positions the content correctly.

* Fix gamma post-process in split-screen

The gamma shader sampled the full backbuffer texture (UV 0..1) into each player's viewport, stretching the entire screen into every split region. Extended the shader constant buffer with per-viewport UV offset and scale so each pass samples only its own portion of the backbuffer.

ComputeViewportForPlayer was hardcoded to top/bottom for 2 players, ignoring the vertical split setting. Rewrote it to read each player's m_iScreenSection directly, which already accounts for the split orientation preference.

Secondary players have no Graphics menu and cannot change gamma. CachePlayerGammas now reads the primary player's setting and applies it uniformly to all viewports.
2026-03-08 22:16:58 -05:00

62 lines
1.7 KiB
C++

#pragma once
#include <d3d11.h>
class PostProcesser
{
public:
static PostProcesser& GetInstance()
{
static PostProcesser instance;
return instance;
}
void Init();
void Apply() const;
void SetViewport(const D3D11_VIEWPORT& viewport);
void ResetViewport();
void CopyBackbuffer(); // Copy backbuffer once before multi-pass gamma
void ApplyFromCopied() const; // Apply gamma using already-copied offscreen texture
void Cleanup();
void SetGamma(float gamma);
float GetGamma() const { return m_gamma; }
PostProcesser(const PostProcesser&) = delete;
PostProcesser& operator=(const PostProcesser&) = delete;
private:
PostProcesser();
~PostProcesser();
static bool IsRunningUnderWine();
ID3D11Texture2D* m_pGammaOffscreenTex = nullptr;
ID3D11ShaderResourceView* m_pGammaOffscreenSRV = nullptr;
ID3D11RenderTargetView* m_pGammaOffscreenRTV = nullptr;
ID3D11VertexShader* m_pGammaVS = nullptr;
ID3D11PixelShader* m_pGammaPS = nullptr;
ID3D11Buffer* m_pGammaCB = nullptr;
ID3D11SamplerState* m_pGammaSampler = nullptr;
ID3D11RasterizerState* m_pGammaRastState = nullptr;
ID3D11DepthStencilState* m_pGammaDepthState = nullptr;
ID3D11BlendState* m_pGammaBlendState = nullptr;
bool m_initialized = false;
float m_gamma = 1.0f;
bool m_wineMode = false;
D3D11_VIEWPORT m_customViewport;
bool m_useCustomViewport = false;
UINT m_gammaTexWidth = 0;
UINT m_gammaTexHeight = 0;
struct GammaCBData
{
float gamma;
float pad;
float uvOffsetX, uvOffsetY;
float uvScaleX, uvScaleY;
float pad2[2];
};
static const char* g_gammaVSCode;
static const char* g_gammaPSCode;
};