Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3D Text scale & translation issues when not fullscreen or billboard #314

Closed
phr00t opened this issue Jan 7, 2019 · 6 comments
Closed

3D Text scale & translation issues when not fullscreen or billboard #314

phr00t opened this issue Jan 7, 2019 · 6 comments

Comments

@phr00t
Copy link
Contributor

@phr00t phr00t commented Jan 7, 2019

Release Type: Official Release & Github

Version: 3.1 beta

Platform(s): Windows 10 x64

Describe the bug
Adding a UI element to the scene, with a TextBlock that is not a fullscreen billboard, doesn't get scaled & translated correctly. It will deform, stretch and rotate with the camera in unexpected ways.

To Reproduce
Steps to reproduce the behavior:

  1. Add a UI element to the scene
  2. Make the UI element use a page with just a TextBlock, type "Hello World" into it
  3. Uncheck the "fullscreen" & "billboard" features of the UI
  4. Move and rotate the camera around & observe the TextBlock

Expected behavior
The TextBlock should continue to point in a certain direction at an expected size.

@phr00t

This comment has been minimized.

Copy link
Contributor Author

@phr00t phr00t commented Jan 13, 2019

How is this related to #106, if at all? There was a request for UI text outlines, and changing text rendering to use materials & shaders as a solution. If that is done (which it should), would this issue be made moot due to a different text rendering method (and we shouldn't spend too much time on this)?

@phr00t

This comment has been minimized.

Copy link
Contributor Author

@phr00t phr00t commented Jan 13, 2019

Suspecting the bug is around here somewhere:

https://github.com/xenko3d/xenko/blob/master/sources/engine/Xenko.Graphics/UIBatch.cs#L437

Unsure where the "fullscreen" boolean is handled -- since TextBlock works when it is fullscreen... so we don't want behavior to change if fullscreen is selected.

@phr00t

This comment has been minimized.

Copy link
Contributor Author

@phr00t phr00t commented Jan 15, 2019

Forcing drawCommand.RealVirtualResolutionRatio = Vector2.One; significantly improves this, but doesn't solve it alone. If I force it to Vector2.One when going into InternalUIDraw, the text scale seems correct in 3D. It may also solve the flickering. However, it still gets translated incorrectly -- the text rotates almost as if in the inverse direction it should be (guess)...

@phr00t

This comment has been minimized.

Copy link
Contributor Author

@phr00t phr00t commented Jan 31, 2019

I highly suspect I've discovered the problem!

There are two types of text rendering functions: SpriteBatch.DrawString & UIBatch.DrawString. It looks like TextBlocks do not use SpriteBatch.DrawString when in 3D "world space" like they should -- they always use UIBatch.DrawString and assume it is a 2D overlay.

I haven't confirmed this, because TextBlocks setup a SpriteFont.InternalUIDrawCommand for its UIBatch to draw... when a SpriteFont.InternalDrawCommand is needed for a SpriteBatch to handle (but I can't find a SpriteBatch reference in a TextBlock...).

Basically, it looks like a TextBlock (and all other UI or 3D texts) need a UIBatch & SpriteBatch, and use the right type whether it is in 3D (e.g. not a billboard) or 2D (billboard/fullscreen overlay).

@phr00t

This comment has been minimized.

Copy link
Contributor Author

@phr00t phr00t commented Jan 31, 2019

Maybe not... SpriteBatch only takes in a Vector2 as a position, so definitely not 3D....

@phr00t

This comment has been minimized.

Copy link
Contributor Author

@phr00t phr00t commented Oct 22, 2019

Testing commits made by xen2 (on my fork, so please confirm bug on master) show they work on left justified/aligned 3d text, but not for center or right aligned/justified. Center or right justified text slides horizontally.

phr00t added a commit to phr00t/FocusEngine that referenced this issue Oct 23, 2019
…atio depending on actual requestedFontSize (fixes xenko3d#314) (fixes xenko3d#364)
@xen2 xen2 closed this in eafa92f Oct 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.