1.194.048 | Corner LCD texture size is MASSIVE

Whiplash141 shared this bug 4 years ago
Outdated

Description:

The corner LCD texture size is very large: 2048x512. This makes any text on it SUPER tiny.


For comparison:

Square LCD panel: 512x512

Wide LCD panel: 1024x512


How to Fix:

To get the corner LCDs the same width as a regular square LCD (512px) modify CubeBlocks_LCDPanels.sbc so that:

- Large grid corner LCDs have TextureSize of 128

- Small grid corner LCD slopes have TextureSize of 128

- Small grid corner LCD flats have TextureSize of 256


Also, it is strange that the small slope corners have a aspect ratio of 4:1 while the small slope flats have an aspect ratio of 2:1 even though they have essentially the same screen space visually. A ratio of 3:1 fits much better for both sets of small screens.

I've attached a cubeblocks SBC with fixes to the bottom of this post. Feel free to diff it against what is live right now.


Why it happens:

The code that generates the texture size is pretty dang weird. It swaps between what the texture size defines, the height or the width. And the way that MathHelper.Log2 does things is kind of strange too.


For example:

7:1 aspect ratio becomes 4:1

5:3 aspect ratio becomes 1:1


Thus it is very difficult to tell how wide your screen will be without plugging them into this function to see what it will spit out for the texture size, then dividing 512 by that (which is what I did above).

private static Vector2I GetTextureResolutionForAspectRatio(int width, int height, int textureSize)
{
    if (width == height)
    {
        return new Vector2I(textureSize, textureSize);
    }
    if (width > height)
    {
        int num = MathHelper.Pow2(MathHelper.Floor(MathHelper.Log2(width / height)));
        return new Vector2I(textureSize * num, textureSize);
    }
    int num2 = MathHelper.Pow2(MathHelper.Floor(MathHelper.Log2(height / width)));
    return new Vector2I(textureSize, textureSize * num2);
}


Images:

o6uKZ01


F6jAo8D


TWuWusw


l1L6mFo

Best Answer
photo

After further testing I found better settings for corner LCDs that reduces texture squishing AND makes their max width 512px like most other screens:


Large Grid Corner LCD (All variants)

  • ScreenWidth 7 (same)
  • ScreenHeight 1 (same)
  • TextureSize 128 (new)

Small Grid Corner LCD (Flat variants)

  • ScreenWidth 25 (new)
  • ScreenHeight 10 (new)
  • TextureSize 256 (new)

Small Grid Corner LCD (Sloped variants)

  • ScreenWidth 22 (new)
  • ScreenHeight 7 (new)
  • TextureSize 256 (new)


This makes the width of the TextureSize used by scripts 512px and minimizes distortion!


Examples

I've attached a fixed SBC for the corner LCD sizes. I'm also adding my test script I used to test screen sizes here!

----------------------------------------------------------------------------------------------------------------------------

Related Issue

There is another issue related to font size on corner LCDs. The sizing of text on corner LCDs differs from text entered in ContentType.TEXT_AND_IMAGES mode vs text created with sprites using ContentType.SCRIPT.


I found the culprit in the code:

// MyTextPanelComponent.UpdateRenderTexture()
MySprite item2 = MySprite.CreateText(Text.ToString(), Font.SubtypeName, FontColor, FontSize * (float)Math.Min(m_textureSize.X, m_textureSize.Y) / 512f, Alignment);
In particular this snippit:
FontSize * (float)Math.Min(m_textureSize.X, m_textureSize.Y) / 512

What this is doing is scaling the text size by the minimum dimension of the text panel. This makes the apparent size of text different for different screen sizes. Now in the non-corner LCDs this is not at all apparent because the underlying screen sizes have the minimum dimension as 512px so the text all looks the same across various screens. However, say that you have a corner LCD that is 512x128 for example. Then text with font size of 1 would be 1/4 the size of text that is size 1 on a 512x512 screen that is the same physical width in-game.


Here is a diagram of what I'm talking about:

9NMxaPNm


When you spawn text using a sprite in an in-game script, this is not done. You simply tell it a FontSize and it uses that directly which makes the font size across screens look consistent.

Replies (2)

photo
1

After further testing I found better settings for corner LCDs that reduces texture squishing AND makes their max width 512px like most other screens:


Large Grid Corner LCD (All variants)

  • ScreenWidth 7 (same)
  • ScreenHeight 1 (same)
  • TextureSize 128 (new)

Small Grid Corner LCD (Flat variants)

  • ScreenWidth 25 (new)
  • ScreenHeight 10 (new)
  • TextureSize 256 (new)

Small Grid Corner LCD (Sloped variants)

  • ScreenWidth 22 (new)
  • ScreenHeight 7 (new)
  • TextureSize 256 (new)


This makes the width of the TextureSize used by scripts 512px and minimizes distortion!


Examples

I've attached a fixed SBC for the corner LCD sizes. I'm also adding my test script I used to test screen sizes here!

----------------------------------------------------------------------------------------------------------------------------

Related Issue

There is another issue related to font size on corner LCDs. The sizing of text on corner LCDs differs from text entered in ContentType.TEXT_AND_IMAGES mode vs text created with sprites using ContentType.SCRIPT.


I found the culprit in the code:

// MyTextPanelComponent.UpdateRenderTexture()
MySprite item2 = MySprite.CreateText(Text.ToString(), Font.SubtypeName, FontColor, FontSize * (float)Math.Min(m_textureSize.X, m_textureSize.Y) / 512f, Alignment);
In particular this snippit:
FontSize * (float)Math.Min(m_textureSize.X, m_textureSize.Y) / 512

What this is doing is scaling the text size by the minimum dimension of the text panel. This makes the apparent size of text different for different screen sizes. Now in the non-corner LCDs this is not at all apparent because the underlying screen sizes have the minimum dimension as 512px so the text all looks the same across various screens. However, say that you have a corner LCD that is 512x128 for example. Then text with font size of 1 would be 1/4 the size of text that is size 1 on a 512x512 screen that is the same physical width in-game.


Here is a diagram of what I'm talking about:

9NMxaPNm


When you spawn text using a sprite in an in-game script, this is not done. You simply tell it a FontSize and it uses that directly which makes the font size across screens look consistent.

photo
1

Hi,

thanks for the report, we will check it out.

Leave a Comment
 
Attach a file