Hello everyone.

The Mixed Reality Forums here are no longer being used or maintained.

There are a few other places we would like to direct you to for support, both from Microsoft and from the community.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.

If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.

And always feel free to hit us up on Twitter @MxdRealityDev.

DirectX: rendering via two RenderTargetViews

EgorboEgorbo
edited August 2016 in Questions And Answers

Hello, the official doc says:

If you want to render without using stereo instancing, you will need to create two non-array RenderTargetViews (one for each eye) that references the two slices in the Texture2DArray provided to the app from the system (this is not recommended as it is typically significantly slower than using instancing).

Is there any example of how to achieve it?
I mean in my code I do
device->CreateRenderTargetView(backbufferTexture, 0, &defaultRenderTargetView);
where backbuffer is obtained from the Holoframe and it all works fine but renders only to the left eye. Can you please help me how to render to the right one?
I suspect I should configure D3D11_RENDER_TARGET_VIEW_DESC but I can't find working parameters :disappointed:

Tagged:

Best Answer

Answers

  • edited August 2016

    Hi @Egorbo,

    Basically what the documentation is saying that you shouldn't do this for performance reasons, but if you must...

    After re-reading, I edited my post. You basically have to draw twice. You'll need to draw to the first render target or basically Render(), then again with the next view. For each view it needs to have it's view ports set appropiately.

    Another thing you could do if you do want to use instanced drawing, is modify your shaders to duplicate your rendering to both views. You can do this using your geometry shader and tell it to alternate between 0 and 1 for your Render target array.

    For your Shader in instanced drawing check this post?

    Dwight Goins
    CAO & Founder| Independent Architect | Trainer and Consultant | Sr. Enterprise Architect
    MVP | MCT | MCSD | MCPD | SharePoint TS | MS Virtual TS |Windows 8 App Store Developer | Linux Gentoo Geek | Raspberry Pi Owner | Micro .Net Developer | Kinect For Windows Device Developer
    http://dgoins.wordpress.com

  • EgorboEgorbo
    edited August 2016

    @Dwight_Goins_EE_MVP Thanks, but unfortunately instanced drawing won't work for my game engine/scene. I want to try that "draw twice" solution first but I can't figure out how to create a viewport for the right eye.

  • This is good to hear. Glad to see you have it working!

    Dwight Goins
    CAO & Founder| Independent Architect | Trainer and Consultant | Sr. Enterprise Architect
    MVP | MCT | MCSD | MCPD | SharePoint TS | MS Virtual TS |Windows 8 App Store Developer | Linux Gentoo Geek | Raspberry Pi Owner | Micro .Net Developer | Kinect For Windows Device Developer
    http://dgoins.wordpress.com

  • @Egorbo said:
    Fixed. Found how to render to the right eye:

    D3D11_RENDER_TARGET_VIEW_DESC desc;
    memset(&desc, 0, sizeof desc);
    desc.Format = DXGI_FORMAT_UNKNOWN;// textureDesc.Format;
    desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
    desc.Texture2DArray.ArraySize = 1;
    desc.Texture2DArray.FirstArraySlice = 1;
    

    @Egorbo I am also Trying to do similar. Can You Please share complete sample.

Sign In or Register to comment.