• Advertisement

DX11 Direct2D but generate background from 3D Model

Recommended Posts

So the application itself is 2D and layered but I want to build the background bitmap from a Blender 3D model.

When I make an appeal to Saint Google there seem to be an awful lot of ways of getting to the desired result.

The process I have in mind is to do the following. Please comment on the practicality or otherwise of this approach.

Use a background thread to:

  • Load the model
  • Create a 3D buffer for rendering into
  • Render into the buffer
  • Copy the 3D buffer to a 2D buffer somewhere

The main loop will

  • Blit? copy the 2D background to the backbuffer of the swap chain
  • Overlay the background with various sprites
  • Swap buffers

Which leads to the following questions.

What is the best option for exporting a Blender model for use by DirectX.

Which API should I use to create a 3D buffer for rendering the model into? As it only gets rendered on scene changes, every 10-20 seconds, am I correct in assuming it shouldn't be part of the swap chain? In managing the background buffer is it best to, or must I, use a "dummy" device of some kind?

How do I turn a 3D buffer into a 2D bitmap for load into the 2D swap chain?

What is the best way to set up the 2D buffer  so asto minimise the cost of the copy for every frame by the main loop?

Edited by timjohnarm
Clarity

Share this post


Link to post
Share on other sites
Advertisement

Hi,

Does the background move ? I'm not familiar with Direct2D. You can always just go full D3D and render quads for the 2D stuff, it will certainly be very fast.

As for loading models from Blender (or any other program) you'll need a loader. It's not that hard to code an .obj loader yourself, otherwise you can probably find some code. It depends on the format your game engines uses so I would just make it myself if I were you, it basically comes down to parsing a text file (for .obj).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Advertisement
  • Advertisement
  • Popular Tags

  • Advertisement
  • Popular Now

  • Similar Content

    • By mister345
      Hi, I'm on Rastertek series 42, soft shadows, which uses a blur shader and runs extremely slow.
      http://www.rastertek.com/dx11tut42.html
      He obnoxiously states that there are many ways to optimize his blur shader, but gives you no idea how to do it.
      The way he does it is :
      1. Project the objects in the scene to a render target using the depth shader.
      2. Draw black and white shadows on another render target using those depth textures.
      3. Blur the black/white shadow texture produced in step 2 by 
      a) rendering it to a smaller texture
      b) vertical / horizontal blurring that texture
      c) rendering it back to a bigger texture again.
      4. Send the blurred shadow texture into the final shader, which samples its black/white values to determine light intensity.
       
      So this uses a ton of render textures, and I just added more than one light, which multiplies the render textures required.
       
      Is there any easy way I can optimize the super expensive blur shader that wouldnt require a whole new complicated system?
      Like combining any of these render textures into one for example?
       
      If you know of any easy way not requiring too many changes, please let me know, as I already had a really hard time
      understanding the way this works, so a super complicated change would be beyond my capacity. Thanks.
       
      *For reference, here is my repo, in which I have simplified his tutorial and added an additional light.
       
      https://github.com/mister51213/DX11Port_SoftShadows/tree/MultiShadows
       
    • By Matt_Aufderheide
      I have never quite been a master of the d3d9 blend modes.. I know the basic stuff, but have been trying for a while to get a multiply/add blending mode... the best I can figure out is mult2x by setting:
      SetRenderState(D3DRS_DESTBLEND, D3DBLEND_SRCCOLOR);
      SetRenderState(D3DRS_SRCBLEND, D3DBLEND_DESTCOLOR);
      //this isn't quite what I want.. basically I wonder if there is a way to like multiply by any color darker than 0.5 and add by any color lighter than that..? I don't know, maybe this system is too limited...
    • By evelyn4you
      hi,
      after implementing skinning with compute shader i want to implement skinning with VertexShader Streamout method to compare performance.
      The following Thread is a discussion about it.
      Here's the recommended setup:
      Use a pass-through geometry shader (point->point), setup the streamout and set topology to point list. Draw the whole buffer with context->Draw(). This gives a 1:1 mapping of the vertices. Later bind the stream out buffer as vertex buffer. Bind the index buffer of the original mesh. draw with DrawIndexed like you would with the original mesh (or whatever draw call you had). I know the reason why a point list as input is used, because when using the normal vertex topology as input the output would be a stream of "each of his own" primitives that would blow up the vertexbuffer. I assume a indexbuffer then would be needless ?
      But how can you transform position and normal in one step when feeding the pseudo Vertex/Geometry Shader with a point list ?
      In my VertexShader i first calculate the resulting transform matrix from bone indexes(4) und weights (4) and transform position and normal with the same resulting transform Matrix.
      Do i have to run 2 passes ? One for transforming position and one for transforming normal ?
      I think it could be done better ?
      thanks for any help
       
    • By derui
      i am new to directx. i just followed some tutorials online and started to program. It had been well till i faced this problem of loading my own 3d models from 3ds max exported as .x which is supported by directx. I am using c++ on visual studio 2010 and directX9. i really tried to find help on the net but i couldn't find which can solve my problem. i don't know where exactly the problem is. i run most of samples and examples all worked well. can anyone give me the hint or solution for my problem ?
      thanks in advance!
  • Advertisement