Weird Shader Effect When Using PBRCustomMaterial On Imported Models

So, I’m playing around with the PBRCustomMaterial, trying to add some effects.
Now, when the material is added to meshes created by BabylonJS itself, it works perfectly. But for some reason the same material has a different effect on models imported.
Take a look at this playground: https://www.babylonjs-playground.com/#LIVRIY#3
The perlin noise effect seems static and scaled on the imported models, but on the ground and sphere, it works as expected. Me being new to all this shader stuff, I have No idea what’s happening here :stuck_out_tongue:
I tried painting vertices, unwrapping, changing normals etc. Anyone having any idea what I’m missing? Something obvious?

Hum…let me check :slight_smile:

Ok this is an issue with the CustomShader.

Pinging @nasimiasl: The problem is that the skull and the bunny force the shader to recompile (because the bunny has bones and because the skull has vertex colors). But when recompiling, they do not receive the time uniform. Do you think you could have a look?

@Raggar: In the meantime, you can force skull.useVertexColors = false and rabbit.skeleton = null
https://www.babylonjs-playground.com/#LIVRIY#5

(I also changed your shader to use world position instead of position)

1 Like

https://www.babylonjs-playground.com/#LIVRIY#10
i try other way and wait complete pbr then load scene but time is not set to obj loading()

https://www.babylonjs-playground.com/#LIVRIY#11
i dont know new instance work but that is a heavy solution

** for see good noise please use vPositionW

2 Likes

Thanks, @Deltakosh! Didn’t take you long :stuck_out_tongue: So the issue was two-fold.

@nasimiasl, you get the Solution tag, as it preserves skeletal animations.
Instead of using vPositionW, I think I might uniform and send worldViewProjection as done in Cyos, as that way, the pixel animations are independent of the position. When you use vPositionW or worldPos as in Deltakosh’ case, even if you don’t animate the noise directly, the effect still takes place when you move an object. When using worldViewProjection in Cyos, the effect is local to the mesh and independent of the position of the mesh/vetices.

2 Likes