Make diffuseTexture move over mesh

I’m trying to make a texture move over tube mesh to look like the water is running in tube but it does not work.
here is PG
https://www.babylonjs-playground.com/#YRE7XB#11
image

1 Like

There were a few problems with your PG. First, you were using diffuseTexture with a PBR Material (the copper cloned material), which is incorrect, the correct property is albedoTexture. Second, you were assigning the material to the root node of the imported mesh, when you should assign it to the child mesh: pump animation | Babylon.js Playground (babylonjs-playground.com)

You can read about the differences of PBR Material here: Introduction to Physically Based Rendering | Babylon.js Documentation (babylonjs.com)

1 Like

but the expected result I wanted should look like this

What you want to do is not supported directly because you want to use the albedo texture as a layer over the material and see the underlying material where alpha=0 in the texture.

It’s possible to do what you want with a material plugin:

4 Likes

wow! thanks man

Hi,
Hope you are well on this beginning of a new year.
Aside from the (always) relevant comments above from @carolhmj and @Evgeni_Popov , here is for my contribution.
First things first, if you want to give a believable aspect to your water flowing through a pipe, you should not animate the pipe diffuseTexture (or in case of PBR, albedoTexture). The pipe is solid and even if transparent so you can see the fluid inside, the pipe material does not move. It’s a pipe.
So first thing, if you want to show the fluid inside, your pipe texture should have a level of transparency.
Next, to animate the fluid inside the pipe without the need of creating another mesh, you can trick the eye be using i.e. the lightmapTexture or in some cases the emissiveTexture, the detailMap texture… or a combination of these (but always keeping the difuse or albedo as being the static material of the pipe, without the fluid).
Also, for a good effect of a fluid moving inside a pipe, I tend to use a distorted flare (or an assembly of distorted flares. Obviously when the fluid moves vertically (up or down) in the pipe, all you can eventually see is some bulbs of air when the flow is irregular. So, for me working with flares works best in this case (my opinion only).

Edit: You can see a version where I’m simply using the emissive with a flare to simulate fuel flow to the carburator in my vintage motorcycle project demo. Press kb ‘6’ to toggle open/close the fuel intake and you can (slightly) see the fuel flow going through the semi-transparent tube. Quite basic, you can do much better and complex animation, including with a node material. But it does the job for small parts already. Again, my opinion only.

5 Likes

Amazing example @mawa :smiley:

1 Like