Switch on VR mode in runtime

Hello,
I have a problem with oculus DK2. I need to start my game in normal (LCD screen) mode with Occulus connected to the same PC. After some videos and intro presentation of application I need to switch to the VR mode and continue in that mode. Is possible to do this ? How ?

Thanks
M.

By default you should be able to use alt+enter to activate full screen mode which will also start rendering to any HMD you have plugged in. Any method going into full screen mode should do the trick as long as it’s not windowed full screen. (It might still activate on windowed full screen but I’m pretty sure it doesn’t.)

Since you have an intro presentation should I assume you want to start in full screen mode then switch over to HMD? If that’s the case you can try to use the “Execute Console Command” blueprint node and give it the command “stereo on” or “stereo off”. This way you don’t have to also toggle full screen mode.

does this work in Google VR and GearVR?

Here’s a screenshot that will hopefully help. This is my blueprint that I call to change between VR and non-VR for the Rift and Vive. I also throw in a bunch of other console commands that optimize VR rendering (2nd screenshot).

It’s also worth noting that (last time I tested) if you take off the Rift (which pauses the game) and then this blueprint is called, it won’t switch back to non-vr mode until you put the Rift back on (unpausing the game). I wrote some custom code to deal with this in my engine, but there are probably better ways to deal with it. I’ve been using the Vive exclusively for a few months so I’m not sure if it’s still an issue in 4.14

Also haven’t tested on GearVR or GoogleVR since I don’t have a use case for switching on those platforms yet.

well, thank you very very much, i will try your solution and see if i can get it working.

Thank you

Well , it was hard to understand because of the multi page split image but it worked exactly like you said.

But i am unable to move with keyboard and mouse.

If you’re in VR, you shouldn’t be trying to move with the mouse and keyboard, that is unless you’re trying to get yourself sick. However, if you still want to do it, you should make sure the character you’re using in VR contains code to control the inputs and that the camera that’s showing the stereo view is actually part of said character. Else the viewpoint will be static, even though your (invisible) character is actually moving throughout the level from your input.

PS I have a custom HMD setup with the vive that puts the mirror in fullscreen instead of just the middle part of the screen. I added the HMD mirror 4 command manually in the source, so you can safely ignore it.

well the idea was to let people traverse the industrial scene without needing a vive/oculus set. So that i can do with having one build package that does both, in away, they are not meant to move in VR with KB.

I did not have time to research adding keys and movement to a blueprint so instead , i had two separa levels having same geometry but different gamemodes

Ah, gotcha. Well let me share how I do that (since I do exactly the same thing). I use the VR game mode only (which uses our VR character as the default), and then I map some input to switch to the standard walking around character (for me I use F9 as a debug key, but also use an input from our menuing system to call the same code).

Overall it goes like this:
Get input → Spawn the new character of the correct class → Possess that character with the player controller → Destroy the VR character.

After that, you’ve got your brand new character, the world is the same, but now all input is handled by that character blueprint class and all that functionality is uncoupled from the VR class.

One other thing to note, is that if you just spawn the new character based on the transform of the VR character, it may or may not be in the correct position (could be trying to spawn through the floor with an incorrect roll or pitch. Experiment with those inputs to your transform to see what works for you).

Also, as an aside, the character I use for archviz is a derivation of the HAL Toolkit character on the marketplace which gives me some other cool utilities that I didn’t have to create myself.

@anonymous_user_2c73ab68 Abt thanks for the instriuctions. It helped me to switch from vr mode to non-vr mode.
but i cannot move from non-vr mode to vr mode.

Any idea?

after calling “Enable HMD” with the checked box i am executing this console cmd:

Cmd: r.VSync  0
Cmd: hmd  enable
Cmd: STEREO on 
Cmd: hmd mirror 1
Cmd: r.SetRes 1920x1080f

Try taking out the full screen set resolution command. I had issues early on where something like that would undo the stereo on command for some reason.

nope. no luck

Quick, perhaps silly question: What integer do you get for clamping?

Do we need to change the Output mode? Coz the VR resolution is different from the non-VR one? it seems to be crash on re-creating back buffer if not changing the output mode. If calling ChangeOutputMode, do you know where it is suitable place for it as it is a must calling on the rendering thread. I don’t know where the suitable place in UE :frowning: If anyone can help, that’s much appreciated .