Allow CustomMaterial to use UV3 - UV6

CustomMaterial is a good place to start with custom material (as the name suggest) but it rely internally on StandardMaterial which do not pass any vertexData over UV2. CustomMaterial should have an option to pass UV3-UV6 to custom shaders.

I tried without success to hack something out by monkey patching isReadyForSubMesh with no real progress so far. It would be nice if that was included as an option in CustomShader itself directly.

1 Like

ping @sebavan

Actually @nasimiasl is the mastermind behind the custom material. Do you think you could support it ?

1 Like

yes i can check it in some days yes

hi again
plan a : the best way for have more uvs in custom material depend for support that on standard material
because CM is only a cover from SM
plan b: if you explain your idea i think i can make tools for support any number of uvs from only use uv1

** notice to the plan b work on all mobile browsers … and no limitation too


Are you thinking about using UV1’s digit and split them into multiple UVs ?
If yes aren’t you going to hit float precision issues ?
Also for the split, wouldn’t you need to have fixed number of digits for each so you can split evenly?
My idea was to make a PR onto the StandardMaterial, to simply pass on UVx when they are available regardless of usage in the shader, assuming that people using the StandardMaterial dont have any VertexData buffer with any UV > 2 that shouldn’t have any impact on the performance or memory usage?

EDIT: feat: Allow CustomMaterial to use UVs > 2 by azukaar · Pull Request #6970 · BabylonJS/Babylon.js · GitHub


dear @Yann_S

thanks for reply here

first i think we can add UVs to standard material too (that is very simple ) just need attach buffering and define attributes for the webgl but we talk about webgl “master of limitation” that depend to a lot parameter ( GPU + browsers + (GPU company ) + mobile devices , … )
so i recommend plan a ( attach uv2…6 to standard material )

but if you cant be success for that or find any post problem after that i have idea for use multiple uvs use from uv1 channel ( + textures ) for find correct coordinate of uv2 and any others

Hello thanks you !
I added the UVs to the StandardMaterial but I still have an issue ([DO NOT MERGE] feat: Allow CustomMaterial to use UVs > 2 by azukaar · Pull Request #6970 · BabylonJS/Babylon.js · GitHub) before it is completed.

The projected light texture is broken, it happens completely randomly and seems to interfere with the normals. Could it be that something in Babylon was actually using UVsx under the hood ?

Any idea what could go wrong? The code change is super simple so I’m bit puzzled