forked from kleinerm/Psychtoolbox-3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VR support: Add OculusVRToolbox and associated basic enablement.
Psychtoolbox/PsychHardware/OculusVRToolbox/ contains M-Files with functions for use of Oculus VR hardware. Currently the basic high-level support driver PsychOculusVR() which itself uses the PsychOculusVRCore mex file. A new pair of vertex- and fragment shaders OculusRiftCorrectionShader.frag.txt and OculusRiftCorrectionShader.vert.txt provides plugins for Screens imaging pipeline to do the necessary client distortion rendering to correct for the Rifts lens distortion, chromatic aberration and vignetting. PsychImaging supports a new task 'UseOculusVRHMD' to setup an onscreen window for display on the Oculus Rift. It does necessary stereo setup, panel fitter setup, imaging pipeline setup, and then calls into helper functions in PsychOculusVR.m to do the work of setting up shaders, display lists etc. for configuring the post-processing in PTB's imaging pipeline. OculusVRDemo.m is the start of a very hacky demo, used for testing and debugging during development. -> All of these will change substantially. This is just a backup commit to prevent loss of the current working state in case of mistakes or disasters. -> Currently we can display a basic properly undistorted 2D stereo view on the Rift DK2 under Linux. However proper scaling is not yet worked out and highly hacky. This needs work. Actual 3D rendering is missing.
- Loading branch information
Showing
5 changed files
with
557 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
function OculusVRDemo | ||
% OculusVRDemo - A very basic demo for the Oculus VR Rift DK2 | ||
|
||
% History: | ||
% 05-Sep-2015 mk Written. | ||
|
||
% For debugging only: | ||
%PsychDebugWindowConfiguration; | ||
|
||
% Setup unified keymapping and unit color range: | ||
PsychDefaultSetup(2); | ||
|
||
% Select screen with highest id as Oculus output display: | ||
screenid = max(Screen('Screens')); | ||
|
||
% Check if at least one Oculus HMD is connected and available: | ||
if PsychOculusVR('GetCount') > 0 | ||
% Yes. Open and initialize connection to first detected HMD: | ||
fprintf('Opening the first connected Oculus VR headset.\n'); | ||
oculus = PsychOculusVR('Open', 0); | ||
else | ||
% No. Open an emulated/simulated HMD for basic testing and debugging: | ||
fprintf('No HMD detected. Opening a simulated HMD.\n'); | ||
oculus = PsychOculusVR('Open', -1); | ||
end | ||
|
||
% Setup default rendering parameters: | ||
PsychOculusVR('SetupRenderingParameters', oculus); | ||
|
||
% Open our fullscreen onscreen window with black background clear color: | ||
PsychImaging('PrepareConfiguration'); | ||
PsychImaging('AddTask', 'General', 'UseOculusVRHMD', oculus); | ||
[win, rect] = PsychImaging('OpenWindow', screenid, 0, [1680, 0, 1680+1080, 1920]) | ||
|
||
for eye = 0:1 | ||
Screen('SelectStereoDrawBuffer', win, eye); | ||
Screen('FillRect', win, [0 0 1]); | ||
Screen('FrameRect', win, [1 1 0], [], 20); | ||
Screen('FillOval', win, [1 1 1]); | ||
Screen('TextSize', win, 200); | ||
DrawFormattedText(win, sprintf('HELLO\nWORLD!\n%i', eye), 'center', 'center', [0 1 0]); | ||
%Screen('FillOval', win, [0 1 0 1]); | ||
end | ||
|
||
Screen('Flip', win); | ||
|
||
KbStrokeWait; | ||
sca; | ||
|
||
% Close HMD, shutdown OculusVR driver: | ||
PsychOculusVR('Close'); | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.