How can I make the following effects more affordable?

I created the following (

As you can see PG, I achieved the effect I wanted to achieve

  1. the number of textures is randomized to give the effect of flipping through them with a mouse movement.
  2. make it visible only in a certain range Like inside a photo frame

First I tried to make an NME before doing this, but the number of textures is random and I can’t pre-bake them.
When I tried to make it as a node mat by code, I want to combine multiple textures to the right, adjust the uv value, and use the uv offset value to give the same effect as above.
Both of these methods only resulted in the textures being combined into a single texture and did not work as I had hoped.
I also saw a suggestion to use Procedural Textures, but to my understanding this does not work.

The description was too long. The conclusion is the same as the title
I asked if there was a cheaper way to achieve the above effect.

ps The frame is not mine It’s from Pavanpk and I found it while looking for a frame for PG’s effect. Thanks for that

What about using canvas to concatenate random images.

1 Like

using canvas

I don’t know what this means specifically.

I can’t pre-bake them

this mean is it
There are two problems with this

  1. if you put an empty image source
    I think I can fill in a random image later, but the UV percentage is empty when the counts don’t match. I suspect the variability based on the number of images rather than the shape of the images will be a problem for future Calculate.
  2. I have not succeeded in combining the images to the right as described above.

Let me see if I understand correctly, you want to achieve the effect of scrolling between multiple textures, but without using multiple planes/multiple materials? If so I think this would be achievable by using the Dynamic Texture: Dynamic Textures | Babylon.js Documentation (

You could do this in a number of different ways, one would be constructing a big vertical texture with all the individual textures, and the mouse movement would update the UVs shown. Another would be to construct a dynamic texture that’s the size of the frame, and the mouse movement would update which textures are drawn in the dynamic texture. The first method causes less redraw of the texture, but it takes more memory as you will have a bigger texture, while the second uses a smaller texture but has to redraw it. YMMV on what is the more advantageous.


Maybe use textureArray2D.

1 Like

@musk When you say use the canvas, mean Dynamic Textures | Babylon.js Documentation
I saw and understood her response. @carolhmj
You were right on the money. thanks

1 Like

You’ve completely figured it out.
Implemented as I thought

As expected, the you are the ultimate GUI guru :heart_eyes: :crossed_fingers:

One last step remains.
It’s a cropped ratio, not a 1/3 narrowed ratio from the original texture, is it possible to make it narrow from the original ratio?

I’m sure that’s the right answer too.
but I’m not familiar with it so it’s likely to take some time

I’m practicing with the following PG
maybe I feel like I’m about to get it

You want to preserve the aspect ratio of all the textures you use?

1 Like

Yes. Like the ( we created at the beginning.

Oooh right, you can do that with the 5-argument version of drawImage: Babylon.js Playground (



Yes, this is it!
my understanding of arguments were wrong.
Thanks you so much

1 Like