HEY EVERY!!! Please help me with pixelization from game resolution on windowed mode!!
i making FREE plugin for 2d pixel games, who pixelate image on your screen, technically i made it year ago - Pixel Tools(PixelTools | Fab). I want update it and add window mode support
So wat the matter? I DONT KNOW WHY BUT THAT DOESNT WORKING!!
In fact to force work pixelation on window i need just change
GEngine->GetGameUserSettings()->GetDesktopResolution() to
GEngine->GameViewport->GetGameViewport()->GetSizeXY()
And It seems to be working but not on all window sizes + resolution sizes. I mean we have pixelization but with pixel distortion on the screen
(Open image in new folder to see how pixelation really works )
Code: I will show you the published version and my practices for window mode so that you can understand where I started.
Project settings:
Settings->DefaultManualScreenPercentage = 100;
Settings->DefaultScreenPercentageDesktopMode = EScreenPercentageMode::BasedOnDisplayResolution;
Settings->DefaultScreenPercentageMobileMode = EScreenPercentageMode::BasedOnDisplayResolution;
Settings->DefaultFeatureAntiAliasing = AAM_None;
Settings->MobileAntiAliasing = EMobileAntiAliasingMethod::None;
Settings->bDefaultFeatureMotionBlur = false;
Settings->DynamicGlobalIllumination = EDynamicGlobalIlluminationMethod::None; Settings->bDefaultFeatureAutoExposure = false;
Settings->DefaultFeatureAutoExposureBias = 0;
Settings->Reflections = EReflectionMethod::None;
Settings->ShadowMapMethod = EShadowMapMethod::ShadowMaps;
Settings->bDefaultFeatureBloom = false;
Settings->SaveConfig();
Camera Component initial
(Constructor)
SetConstraintAspectRatio(false);
PostProcessSettings.AutoExposureMinBrightness = 0; PostProcessSettings.AutoExposureMaxBrightness = 0; PostProcessSettings.HistogramLogMin = 0;
PostProcessSettings.HistogramLogMax = 0;
PostProcessSettings.VignetteIntensity = 0;
PostProcessSettings.ExpandGamut = 0;
PostProcessSettings.ToneCurveAmount = 0;
(Camera component Post init)
SetProjectionMode(ECameraProjectionMode::Orthographic);
Resolution Calculating Desktop only version -
const int CurScale = GEngine->GameUserSettings->GetDesktopResolution().X / Resolution.X;
if(CurScale + Scale > 0 && CurScale + Scale < 40)
{
const int OutputResX = GEngine->GameUserSettings->GetDesktopResolution().X / (CurScale + Scale);
const int OutputResY = GEngine->GameUserSettings->GetDesktopResolution().Y / (CurScale + Scale);
return(FIntPoint(OutputResX, OutputResY));
}
else { return FIntPoint(0, 0); }
Window mode version -
FIntPoint WindowResolution = GEngine->GameViewport->GetGameViewport()->GetSizeXY();
int32 Garbage;
int32 DesktopX;
int32 DesktopY;
GEngine->GameViewport->GetWindow()->GetNativeWindow()->GetFullScreenInfo(Garbage, Garbage, DesktopX, DesktopY);
const int CurScale = DesktopX / Resolution.X; const int WinScale = DesktopX / WindowResolution.X;
if(CurScale + Scale != 0)
{
const int OutputResX = (WindowResolution.X * WinScale) / (CurScale + Scale);
const int OutputResY = (WindowResolution.Y * WinScale) / (CurScale + Scale);
return(FIntPoint(OutputResX, OutputResY)); } else { return FIntPoint(0, 0);
}
Applying resolution -
Desktop only version -
float DesctopResX = GEngine->GetGameUserSettings()->GetDesktopResolution().X;
float TimlessResX = Resolution.X;
GEngine->GetGameUserSettings()->SetResolutionScaleValueEx((TimlessResX / DesctopResX) * 100);
GEngine->GetGameUserSettings()->ApplyResolutionSettings(false);
GEngine->GetGameUserSettings()->ApplyNonResolutionSettings(); SetPerfectOrthoWidth();
Window mode version -
if (UGameUserSettings* Settings = GEngine->GetGameUserSettings())
{
float DesctopResX = Settings->GetDesktopResolution().X;
float TimlessResX = Resolution.X;
const int WinScale = DesctopResX / GEngine->GameViewport->GetGameViewport()->GetSizeXY().X;
float Percentage = (TimlessResX / DesctopResX) * 100;
Settings->SetResolutionScaleValueEx(Percentage * WinScale);
Settings->ApplySettings(false); GEngine->Exec(GetWorld(), FString::Printf(TEXT(“r.ScreenPercentage %f”), Percentage WinScale)); SetPerfectOrthoWidth();
}
SetPerfectOthoWidth:
OrthoWidth = Resolution.X / PixelPerUnit;
So.. what’s wrong?? Why in native window size pixels looking good, and on half size window we can see pixel distortion??