[UE4] Fullscreen vr mirror on HTC vive
Step1. 準備原始碼版本的遊戲引擎
Step2. 修改SteamVRHMD.cpp
// ...\Engine\Plugins\Runtime\Steam\SteamVR\Source\SteamVR\Private
int32 val;
if (FParse::Value(Cmd, TEXT("MIRROR"), val))
{
if ((val >= 0) && (val <= 3))
{
WindowMirrorMode = val;
}
else
{
Ar.Logf(TEXT("HMD MIRROR accepts values from 0 though 3"));
}
return true;
}
Step3. 修改SteamVRRender.cpp
// ...\Engine\Plugins\Runtime\Steam\SteamVR\Source\SteamVR\Private
int WindowMirrorMode = FMath::Clamp(CVarMirrorMode->GetValueOnRenderThread(), 0 ,3);
Step2. 修改SteamVRHMD.cpp
// ...\Engine\Plugins\Runtime\Steam\SteamVR\Source\SteamVR\Private
int32 val;
if (FParse::Value(Cmd, TEXT("MIRROR"), val))
{
if ((val >= 0) && (val <= 3))
{
WindowMirrorMode = val;
}
else
{
Ar.Logf(TEXT("HMD MIRROR accepts values from 0 though 3"));
}
return true;
}
Step3. 修改SteamVRRender.cpp
// ...\Engine\Plugins\Runtime\Steam\SteamVR\Source\SteamVR\Private
int WindowMirrorMode = FMath::Clamp(CVarMirrorMode->GetValueOnRenderThread(), 0 ,3);
else if (WindowMirrorMode == 3) {
RendererModule->DrawRectangle(
RHICmdList,
0, 0,
ViewportWidth, ViewportHeight,
0.05f, 0.3f,
0.4f, 0.4f,
FIntPoint(ViewportWidth, ViewportHeight),
FIntPoint(1, 1),
*VertexShader,
EDRF_Default);
}
Step4. 儲存後重新編譯
Step5. 使用命令快速切換 (press '~' key)
hmd mirror 1 (Native mode : single eye)
hmd mirror 2 (Native mode : stereo)
hmd mirror 3 (Self-defined : Horizontal) <---全螢幕無黑邊
// UE4.16 命令修改為 vr.MirrorMode
參考:
圖文教學1
圖文教學2
影片教學
RendererModule->DrawRectangle(
RHICmdList,
0, 0,
ViewportWidth, ViewportHeight,
0.05f, 0.3f,
0.4f, 0.4f,
FIntPoint(ViewportWidth, ViewportHeight),
FIntPoint(1, 1),
*VertexShader,
EDRF_Default);
}
Step4. 儲存後重新編譯
Step5. 使用命令快速切換 (press '~' key)
hmd mirror 1 (Native mode : single eye)
hmd mirror 2 (Native mode : stereo)
hmd mirror 3 (Self-defined : Horizontal) <---全螢幕無黑邊
// UE4.16 命令修改為 vr.MirrorMode
參考:
圖文教學1
圖文教學2
影片教學