AdvancedDynamicTexture Text block is inverted

Hi!

I tried creating an AdvancedDynamicTexture with a text block on it.
Now I was able to successfully apply it but now the text is inverted.
I tried changing the invertedY value on the constructor but it didn’t seem to work.
Is there something wrong with how I implemented it or did I missed something?

I’ve made a playground with the issue.

Any help on this is greatly appreciated! Thanks!

@Evgeni_Popov, could you have a look at this one ?

Actually you need to use this : https://playground.babylonjs.com/#JJ4R90#16

3 Likes

You spared me an edit. x)
I tried to used the invertY but it wouldn’t affect the scene, the inspector would still show “stored as inverted Y”. Could you explain why this magical line is necessary ?

@VtuberFan if you need to readjust your texture (the screen texture has an offcentered text, for instance), here is an example (line 22-25).

1 Like

:open_mouth: I’ll definitely apply this now and get back in a bit.
Thanks @sebavan and @Faber !

@Faber it is the uvs that are inverted. If you apply a 1-v transformation on the y coordinates you don’t need to add applyYInversionOnUpdate = true:

scene.meshes[1].setVerticesData("uv",
  scene.meshes[1].getVerticesData("uv").map((v, idx) => idx % 2 ? 1 - v : v)
);

A possible noob question here, what does uvs stand for? Is the issue possibly that the mesh itself when it was exported has this issue or something else entirely?

Here is a nice definition of UV mapping UV mapping - Wikipedia

Basically it is mostly the creation of the mesh that defines them and how you would author your models.This might help as well https://all3dp.com/2/blender-uv-mapping-simply-explained/#:~:text=Blender%3A%20UV%20Mapping-,What%20Is%20It%3F,done%20in%20the%20UV%20Editor.

1 Like

Thanks for the insight !

I’m not sure to understand the snippet thought. 1-V is only applied to uneven indexes ?

Yes, because the inversion should only be done on Y coordinates, not on X.

2 Likes

I get it, I didn’t know that vertices data stored Xs and Ys on a flat array, I imagined there was a Vector2 to keep the access through keys. I assume this is a performance matter ? The runtime cost of vertexData looping must be huge.

Thanks for the additional information, I’ll leave the thread alone now. ^^

Hi I have a follow up inquiry.

If I used a dynamic texture instead of advance dynamic texture, will applyYInversionOnUpdate still work is there another way of doing it?

Yes, the update method of the DynamicTexture class takes a invertY boolean as its first parameter.

2 Likes

Thanks @Evgeni_Popov! Last follow up question (Sorry, making sure to cover all bases). How about video texture?

VideoTexture has an invertY parameter to its constructor, so you should be good.

1 Like