integrate Oculus SDK Distortion within simple DirectX Engine -


i working time on simple directx11 render engine. today managed setup stereo rendering (rendering scene twice textures) oculus rift integration.

[currently] doing is:

  • i have 1280 x 800 window
  • render whole scene rendertargetviewleft_ (1280 x 800)
  • render content of rendertargetviewleft_ "eyewindow" (like in tutorial) left side of screen (640 x 800)
  • render whole scene rendertargetviewright_ (1280 x 800)
  • render content of rendertargetviewright_ "eyewindow" (like in tutorial) right side of screen (640 x 800)

so of works far, got scene rendered twice seperate textures, ending in splitscreen.

[directx11 render loop]

bool graphicsapi::render() {     bool result;  // [left eye] first pass of our render texture now.  result = rendertotexture(rendertextureleft_); if (!result) {     return false; }  // clear buffers begin scene. beginscene(0.0f, 0.0f, 0.0f, 1.0f);  // turn off z buffer begin 2d rendering. turnzbufferoff();  // render eye window orthogonal screen rendereyewindow(eyewindowleft_, rendertextureleft_);  // turn z buffer on 2d rendering has completed. turnzbufferon();   // [right eye]  ------------------------------------ result = rendertotexture(rendertextureright_); if (!result) {     return false; }  turnzbufferoff();  rendereyewindow(eyewindowright_, rendertextureright_);  turnzbufferon();  // [end] present rendered scene screen. endscene(); // calls present  return true; } 

[what want now] trying achieve barrel distortion oculus sdk. not concerning different virtual camera second image, want achieve barrel distortion now.

i have read developers guide [1] , tried tinyroom demo, don't understand what's necessary achieve distortion sdk in working directx engine.

in developers guide render texture initialization, show how create texture api. guess means, need setup rendertargetviews according api size (render targets sized 1280 x 800) - , change depthstencilview , backbuffer sice aswell guess.

the render-loop then:

ovrhmd_beginframe(hmd, 0); beginscene(0.0f, 0.0f, 0.0f, 1.0f); ... // render loop code above ... ovrhmd_endframe(hmd, headpose, eyetextures); // endscene(); // calls present, not needed on oculus rendering 

i feel something's missing sure don't got right.

[update] so, achieve render scene barrel distortion using oculus api. though polygon of left- , right image far seperated, caused using default 1280 x 800 texture size render targets. camerastream seems aswell not rendered orthogonal screen when moving hmd. gonna further testing ;)

[1] - oculus developers guide: https://developer.oculus.com/documentation/

the key point of 3d hmd support render whole graphics scene twice. once left virtual camera, , once right virtual camera - "eye" distance between them varies, it's approximaetly 65mm.

to store scene, 1 has render graphic scene textures. have rendered scene first using left virtual camera rendertextureleft_, , afterwards have rendered exact same scene right virtual camera rendertextureright_. technique called "render texture". means save image further post processing stuff separate texture instead of rendering directly backbuffer display on monitor.

so well, how can render oculus rift now? it's important set hmd instance , configure correctly first. explained here in official docs [1]: https://developer.oculus.com/documentation/pcsdk/latest/concepts/dg-render/

after both rendertextures (left eye, right eye) rendered textures , oculus device has been configured accordingly, 1 needs supply oculus sdk both of rendered textures print them on hmd's monitor , doing barrel distortion using oculus sdk (not client distortion no longer supported in newer sdk versions).

here showing directx code supplys oculus sdk both of renderetextures , doing barrel distortion:

bool oculushmd::renderdistortion() {     ovrd3d11texture eyetexture[2]; // gather data eye textures      sizei size;     size.w = rift_resolution_width;      size.h = rift_resolution_height;      ovrrecti eyerenderviewport[2];     eyerenderviewport[0].pos = vector2i(0, 0);     eyerenderviewport[0].size = size;     eyerenderviewport[1].pos = vector2i(0, 0);     eyerenderviewport[1].size = size;      eyetexture[0].d3d11.header.api = ovrrenderapi_d3d11;     eyetexture[0].d3d11.header.texturesize = size;     eyetexture[0].d3d11.header.renderviewport = eyerenderviewport[0];     eyetexture[0].d3d11.ptexture = graphicsapi_->rendertextureleft_->rendertargettexture_;     eyetexture[0].d3d11.psrview = graphicsapi_->rendertextureleft_->getshaderresourceview();      eyetexture[1].d3d11.header.api = ovrrenderapi_d3d11;     eyetexture[1].d3d11.header.texturesize = size;     eyetexture[1].d3d11.header.renderviewport = eyerenderviewport[1];     eyetexture[1].d3d11.ptexture = graphicsapi_->rendertextureright_->rendertargettexture_;     eyetexture[1].d3d11.psrview = graphicsapi_->rendertextureright_->getshaderresourceview();      ovrhmd_endframe(hmd_, eyerenderpose_, &eyetexture[0].texture);      return true; } 

the presentation of stereo image including barrel distortion kind of post processing effect done via line:

ovrhmd_endframe(hmd_, eyerenderpose_, &eyetexture[0].texture); 

hopefully code helps 1 or other understand pipeline better.


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -