Skip to content
This repository has been archived by the owner on Apr 15, 2024. It is now read-only.

Fixing texture bleeding issues #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

stopiccot
Copy link
Contributor

Empty tiles in emoji spritesheet are filled with gray color that can lead to texture bleeding issues.

screenshot 2018-09-11 13 03 44

Copy link
Owner

@iBicha iBicha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optimising clearing the content of the texture

// Fill texture with transparent pixels
for (int x = 0; x < SHEET_SIZE; x++) {
for (int y = 0; y < SHEET_SIZE; y++) {
texture.SetPixel(x, y, new Color(0, 0, 0, 0));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SetPixel is probably slow within the loop. SetPixels32 is probably faster, but I believe the fastest solution is to pass a byte array of zeros to LoadRawTextureData.
Also, all the functions above require Apply to upload data from CPU to GPU. Maybe the final output could look something like:

            var texture = new Texture2D(SHEET_SIZE, SHEET_SIZE, TextureFormat.RGBA32, false);
            texture.LoadRawTextureData(new byte[SHEET_SIZE * SHEET_SIZE * 4]);
            texture.Apply(false, EmojiTexture.CanCopyTextures);

            var spriteAsset = ScriptableObject.CreateInstance<TMP_SpriteAsset>();
            //...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok if you commit your own version to master)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the holdup, currently working on a larger refactor and support for different platforms, so I didn't get the time to do this earlier. I will include this in the next commit :)

@iBicha
Copy link
Owner

iBicha commented Sep 11, 2018

Thank you again for your contribution, that's a valid point (and it should be noticeable as well, even though I didn't notice it before, probably because of screen resolution, maybe)
I have left a little performance tip, might get things to run slightly faster

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants