4
votes

I'm writing a DirectX 11 overlay for a game. Creating textures is quite simple and I have good knowledge of C/C++.

The problem I am having is in my test window I can print the texture but as soon as I change the camera angle the texture moves with it. That is what most people want.

What I want to know is how do I print something in 2D to always appear on screen whether the camera moves or not?

1
It's impossible to tell what's going wrong without any code. One way is to draw a textured rectangle on the screen. This means that you need an ortographic projection transform and no view or world transform at all. - Nico Schertler
I think that helps thankyou. I will get back to you and let you know. - user2600628
I've disabled the world matrix and it still prints on screen as it should but the view matrix to leave the projection matrix as the only matrix is something different. - user2600628

1 Answers

3
votes

Basically, since you use dx11, you use shaders to render your elements.

So standard 3d objects generally follow this guideline: -Use 3 transforms : world (position object), view (transform in camera space), projection (transform in screen space).

In you vertex shader you multiply all that lot to convert from 3d to 2d.

Since now what you want is to display your elements in 2d (non relative to camera), you can easily create a new shader that doesn't take view/projection into account, so you just don't use those matrices in your vertex shader. (you can still use world for 2d transformation).

That's pretty much the easiest way, if you need pixel precise 2d elements, you need to create a billboard transform/shader. Basically you have your render target resolution, and standard render space is -1 -> 1, so you modify scale/translation to convert between both of those spaces.

When you render you overlay, also ensure that you disable depth completely.

If you need sample let me know I'll make one up quickly, but it should be quite simple.