Neos-Metaverse / NeosPublic

A public issue/wiki only repository for the NeosVR project
195 stars 9 forks source link

UIX Sprite Providers Flash On Image/Sprite Changes #3421

Open AshtonSparx opened 2 years ago

AshtonSparx commented 2 years ago

Describe the bug?

When changing images in UIX panels, the Sprite flashes empty for a frame before showing the change it made. I've tried several different ways to work around this. From Multiplexing the Sprite Provider, Multiplexing the image in the Sprite Provider, using different components to do it like ValueOptionDescriptionDriver with still no avail.

Relevant issues

Possibly #1749

To Reproduce

Use a UIX template. I created one here for you to use or make one from scratch

Specifically "Template Canvas" neosrec:///U-ashtonsparkie/R-84aae20b-75a1-4df9-ba45-8f3b2a3a8529 -- It's blue.

  1. Create a usual UIX Canvas with an Image
  2. Put a button onto it
  3. Create any form of changing the image with a button press. Usually a checkbox with a ValueDescriptionDriver
  4. Have it switch the Sprite on true/false.

Expected behavior

For the image or sprite to change without flashing.

Log Files

No response

Screenshots

https://i.gyazo.com/ff5c15ff7e4a076d9c5136d74608d7a7.mp4

How often does it happen?

Always

Does the bug persist after restarting Neos?

Yes

Neos Version Number

2021.11.10.1265

What Platforms does this occur on?

Windows, Linux, Android / Quest

Link to Reproduction Item/World

neosrec:///U-ashtonsparkie/R-84aae20b-75a1-4df9-ba45-8f3b2a3a8529

Did this work before?

No

If it worked before, on which build?

No response

Additional context

No response

Reporters

AshtonSparx#5050

kulzae commented 2 years ago

I believe this bug can be seen in the VBLFC pool hangout world on the Green Dawn vending machine

Rellik66 commented 2 years ago

This happens whenever the texture switches. This can be worked around by atlasing UIX sprites. I posted an example in the Tutorials section on the discord

https://user-images.githubusercontent.com/95493408/144656366-d2e9be0b-80cc-457a-9a5c-f619bf2d5560.mp4

The TLDR; The Rect field on SpriteProvider defines what part of the texture to use for the sprite, first x is the starting point from the left, first y is the starting point from the bottom; second x and y defines the span of the image in their respective axis.

Zandario commented 2 years ago

To add on top of this, during my own personal test, here's what I recall on the top of my head:

Prerequisites: Have a Image Component on a RectTransform

(This is in no particular order)

  1. Disabling/Enabling the Image Component.
  2. Disabling/Enabling the Slot containing the Image Component.
  3. Changing the SpriteProvider given to the Image Component, be that a Multiplexer or otherwise.
  4. Changing the Texture given to the SpriteProvider, be that a Multiplexer or otherwise.
  5. Using layouts or the RectTransform to "Squash" the Rect to 0 Height and/or Width.

Only ways to successfully get around it in my experience is to have another Image parented below the main Image and drive the Alpha channel to effectively hide it. The method Rellik66 provided also works as well.

Zandario commented 2 years ago

Also found this comment from Froox, I do believe this is related to the problem.

This is side effect of the UIX canvas rebuilding the material lists when the composition of it changes. When there's no active text, it regenerates the material list to exclude it from the rendering, which causes the brief flicker. I plan on extending the system to better synchronize those changes with renderer and prevent the flickers, but that's a bit long term solution now.

Originally posted by @Frooxius in https://github.com/Neos-Metaverse/NeosPublic/issues/646#issuecomment-639226258