mister345

DX11 Need help with Rastertek tutorial - making a 2D font overlay

Recommended Posts

Hi guys, anyone experienced with DX11 could look at my graphics.cpp class? I got fonts rendering correctly

with painters algorithm - painting over the other 3d stuff each frame, however, whenever I turn the camera left or right,

the fonts get smushed narrower and narrower, then disappear completely.

 

It seems like the fix must be a very small change, untying their rendering from the cam direction,

but I just can't figure out how to do it under all this rendering complexity. Any tips would be helpful, thanks.

https://github.com/mister51213/DirectX11Engine/blob/master/DirectX11Engine/Graphics.cpp

Capture.PNG

Edited by mister345
added screencap

Share this post


Link to post
Share on other sites

When displaying text, you are not suppose to use the viewMatrix. Only the orthoProjection is needed but I think in this tutorial you will also need the basic world Matrix. The problem is that you are storing rotation inside your viewMatrix or any other type of modelMatrix and this cause to rotate your quad containing your text. It produces your bad effects, get narrow ...

Hope it helps

Edited by Thibault Ober

Share this post


Link to post
Share on other sites
On 11/12/2017 at 10:20 PM, Thibault Ober said:

When displaying text, you are not suppose to use the viewMatrix. Only the orthoProjection is needed but I think in this tutorial you will also need the basic world Matrix. The problem is that you are storing rotation inside your viewMatrix or any other type of modelMatrix and this cause to rotate your quad containing your text. It produces your bad effects, get narrow ...

Hope it helps

So you're saying in the following function, dont pass in the view matrix right? What matrix should I pass in instead, just identity?

SetShaderParameters(deviceContext, worldMatrix, identity /*viewMatrix*/, projectionMatrix, texture);

 

 

 

Share this post


Link to post
Share on other sites

I don't know how you handle your mouse. But you should put the resulting rotation somewhere (in a matrix). In order to draw your quad properly (in front) you shouldn't try to use them.

I will recommend to take in to account only the orthoProjection Matrix you have.

SetShaderParameters(deviceContext, identity, identity /*viewMatrix*/, projectionMatrix, texture);

 

projectionMatrix i think is computed with an orthoProjection. Try the code above and tell us your result.

 

good luck

 

Edited by Thibault Ober

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