Triplanar shader strange behavior when meshs are translated (possible bug)

Hi friends,

i’m working with triplanar mapping (Tri-Planar Mapping Material | Babylon.js Documentation). I just found the material does not work correctly when meshes are translated (any position different from 0,0,0).

I made an example here:

When you add any position to the ground the textures are not correctly mixed.

I think worldNormal calculation, in vertex shader, is not right. Ignoring “world” seems to solve, but i’m not sure if this is a good solution. Any help?

//triplanar vertex shader
#ifdef NORMAL
  //vec3 worldNormal=(world*vec4(normalize(normal),1.0)).xyz;
  vec3 worldNormal=(vec4(normalize(normal),1.0)).xyz; 

I think this is the right fix:

…and welcome aboard (and thanks for the reporting)!

thanks! perfect.