Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8629133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:43:26+00:00 2026-06-12T08:43:26+00:00

I’m trying to render to two textures with one pass using C++ directx 11

  • 0

I’m trying to render to two textures with one pass using C++ directx 11 SDK. I want one texture to contain the color of each pixel of the result image (what I normally see on the screen when rendering a 3D scene), and another texture to contain the normal of each pixel and depth (3 float for normal and 1 float for depth). Right now, what I can think of is to create two rendering targets and render the first pass as the colors and the second pass the normals and depth to each rendering target respectively. However, this seems a waste of time because I can get the information of each pixel’s color, normal, and depth in the first pass. So is there a way to somehow output two textures with the pixel shader?

Any help would be appreciated.

P.S. I’m thinking something along the lines of RWTexture2D or RWStructuredBuffer in the pixel shader. A little background: I will need the two images for further processing in the compute shader. Which brings up a side question of synchronization: since the pixel shader (unlike the compute shader) writes each pixel one at a time, how would I know when the pixel shader is finished and tell the compute shader to start image post-processing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T08:43:27+00:00Added an answer on June 12, 2026 at 8:43 am

    You need to use MRT (Multiple Render Targets) to render this in one pass.

    You can bind both targets as output using OMSetRenderTargets

    http://msdn.microsoft.com/en-us/library/windows/desktop/ff476464(v=vs.85).aspx

    There’s an example in http://hieroglyph3.codeplex.com/ (DefferedRendering) which then shows how to write to both textures at once.

    Here is a small sample :

    ID3D11DeviceContext* deviceContext; //Your immediate context
    
    ID3D11RenderTargetView* m_pRenderViews[2]; //Not more than D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT (8)
    m_pRenderViews[0] = pRTV1; //First target
    m_pRenderViews[1] = pRTV2; //second target
    
    deviceContext->OMSetRenderTargets(2, &m_pRenderViews[0], NULL); //NULL means no depth stencil attached
    

    Then your pixel shader will need to output a structure instead of a single color:

    struct PS_OUTPUT
    {
        float4 Color: SV_Target0;
        float4 Normal: SV_Target1;
    };
    
    PS_OUTPUT PS(float4 p: SV_Position, float2 uv : TEXCOORD0)
    {
          PS_OUTPUT output;
          output.Color = //Set first output
          output.Normal= //Set second output
          return output;
    }
    

    Also in DirectX11 you shouldn’t need to write depth to your normal buffer, you can just use the depth buffer.

    For Pixel/Compute shader sync, you can’t run a pixel shader and a compute shader at the same time on the same device, so when your draw calls are finished, the textures are ready to use in compute for dispatch.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:
I'm making a simple page using Google Maps API 3. My first. One marker
I am trying to understand how to use SyndicationItem to display feed which is
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.