Hello,
i am trying to add custom vertex attributes to my CustomMaterial
, but only existing attributes are being sent to the vertex shader.
Here is my PG . I’m just copying uv
coordinates to uv6
and try to use them in the shader, however they are not sent.
material.getEffect().getAttributesNames() = ["position", "normal", "uv"]
.
Is there any way how to add them? Or should i use ShaderMaterial
and copy StandardMaterial
s vertex and fragment shaders and modify them?
Thanks
L
1 Like
Pinging @nasimiasl who is the author of the CustomMaterial
You can’t currently do it, but this PR should help:
BabylonJS:master
← Popov72:custommaterial-addatribute
opened 04:02PM - 17 Mar 20 UTC
3 Likes
Looks exactly like what i was looking for
I have updated my PG .
Works nicely, thanks.
1 Like
Hi, all! I was looking into adding an attribute as well, and I noticed that ludevik’s excellent example works for Babylon 4.2 but not for 5.0.
I’m attempting to troubleshoot my way through the materials and shaders to see why this might be the case, but I haven’t hit gold quite yet.
Any insight into what might be preventing the PG example from working with 5.0?
Thanks all,
Dacoda
1 Like
Check this post by @Evgeni_Popov :
uv1-uv6 are standard attributes, if they are provided on the mesh geometry they are automatically declared in the shaders (I think before 5.0.0 it was only uv1/uv2 that were automatically declared), so one should not redeclare them (see line 90):
https://playground.babylonjs.com/#2LX5WU#18
Just remove the declaration of uv6
, i’ve updated the PG for you .
3 Likes
Brilliant! Thank you for your quick response
1 Like