Attempting to update mesh texture during runtime

Include the following details (edit as applicable):

  • Issue category: Meeshing /
  • Device type & OS version: / iOS /
  • Host machine & OS version: Mac /
  • Issue Environment : / On Device /
  • Xcode version: 13.2.1
  • ARDK version: 1.3.0
  • Unity version: 2021.2.13

Description of the issue:

I am attempting to update the texture of the mesh at runtime using shader graphs material applied to the plane prefab which goes into the ARmesh prefab. Outside of the ARmesh prefab I am able to update the texture of the plane when the particle collision hits the plane prefab. However, the second I put the plane prefab into the ARmesh prefab updating the texture. I know it is possible to update the mesh because example videos have effects happening when GameObjects hit the mesh, but I have been unable to successfully update this. Any insights into the best way to go about doing this would be greatly appreciated. Thank You!

1 Like

Hey AJ, can you elaborate a bit on what you mean by updating the texture? If you mean the shader’s color in MeshChunk, were you unable to change the fresnel colors or other color settings? Or did you try to import your own custom shader?

Hello again! It’s been a while since you’ve responded, if you have any other questions please feel free to open a new thread!

My apologies for the late response to this, it has been a. busy week. We have a custom shader which we applied to plane prefabs which allows us to alter the color of the material during runtime. I have tried applying the shader color to the material provided with Niantics prefab(I believe thats the fresnel one). However, the moment that we put our shader into the prefab for ARMesh, the material will not allow for the alteration of the color.

Hi AJ, were there any error logs when you attempted to build with the custom shader? You should be able to import your custom shader via changing the source of your prefab in MeshChunk, under the Mesh Normal Fresnel component.
If not, are you able to try the sliders in the component to see if any changes are applied? The Edit button also provides a way for you to customize the texture the way you want. Let us know if you are able to apply changes.

We never received any error logs, and we are able to customize the shader and have those changes appear on the material which we switched out for the fresnel component.

I loaded my custom shader and was able to apply to my build successfully using the script here, under “Update our Shader to take a Texture and Transform.” Can you check if your material for your mesh is applied to your custom shader?