I’ve set up a custom shader material exactly like this in regards to UVs: Putting Shader Code Into Babylon.js | Babylon.js Documentation
However the UVs are not coming through. This is on a synty model in particular so the islands are zero-sized points. However it works fine using the build-in materials.
Any ideas as to what might be going on? I’m working on getting it into a PG but it’s not going very well.
Edit: if I use uv2 then the texture shows, so it must be a problem with the first uv channel.
Here’s the PG: https://playground.babylonjs.com/#10QLDT#1
There is an albedoMatrix. UV are transformed by this matrix before sampling the texture. Its value is:
1 0 0 0
0 -1 0 0
0 0 0 0
0 0 0 1
It means uv.x is unchanged but uv.y is inverted. Once doing the same in the same, the texture appears properly:
custom shader test UV Matrix | Babylon.js Playground (babylonjs.com)
I tried adding albedoMatrix as uniform in the shaderMaterial uniforms declaration but it didn’t work. Do you know @Evgeni_Popov how to plug the albedoMatrix in a custom shader?
You have to pass the matrix yourself:
[EDIT] It’s better to do the matrix multiplication in the vertex shader:
That would have been a difficult one to figure out. Thank you guys!