# Custom Transparent Material on AR Mesh

**URL:** <https://community.nianticspatial.com/t/custom-transparent-material-on-ar-mesh/3352>\
**Category:** I'm Stuck\
**Created:** [March 9, 2023, 6:33pm UTC](https://community.nianticspatial.com/t/custom-transparent-material-on-ar-mesh/3352 "2023-03-09T18:33:43Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![MadmanSilver](https://sea2.discourse-cdn.com/niantic/user_avatar/community.nianticspatial.com/madmansilver/32/1002_2.png) [@MadmanSilver](https://community.nianticspatial.com/u/MadmanSilver)\
**Post date:** [March 9, 2023, 6:33pm UTC](https://community.nianticspatial.com/t/custom-transparent-material-on-ar-mesh/3352/1 "2023-03-09T18:33:43Z")

</div>

- **Issue category** : Meshing / ARDK Documentation
- **Device type & OS version** : Android / iOS
- **Host machine & OS version** : Windows 10
- **Issue Environment** : Unity Mock
- **ARDK version** : 2.3.1
- **Unity version** : 2021.3.9f1

Description of the issue:

I wish to apply a custom material to the generated meshes that has a texture with transparency. Think something similar to the grid texture that is applied by default to the plane finding in the example scenes.

Unfortunately it seems that no matter what I do or what kind of shader I use, as soon as I apply a texture to a transparent shader material, the mesh goes entirely solid with no sign of the actual texture.

There was another thread created that was a similar problem, but the OP never responded and so it didn’t go anywhere. The documentation link that was posted in the thread also seems to be broken.

My guess is that this mesh is being generated without proper UV mapping, but how am I meant to get around this? It’s especially annoying that I can’t find anything in the documentation that mentions anything about this.

Solid color transparency working fine.  
 ![image](https://us1.discourse-cdn.com/niantic/original/2X/a/aa635de941bea7e6aa62b1c1e88040452610c760.png)

Transparent texture not even showing.  
 ![image](https://us1.discourse-cdn.com/niantic/original/2X/0/0b78ca33650108e28e6ea064a2202235c0e0bf79.png)

Even a normal, non-transparent texture doesn’t show.  
 ![image](https://us1.discourse-cdn.com/niantic/original/2X/1/1b6d61376e5b4ce665f07f703a5a55a537168c6d.png)

---

<div class="post-metadata">

**Author:** ![Maverick\_Niantic](https://avatars.discourse-cdn.com/v4/letter/m/8edcca/32.png) [@Maverick\_Niantic](https://community.nianticspatial.com/u/Maverick_Niantic)\
**Post date:** [March 9, 2023, 7:19pm UTC](https://community.nianticspatial.com/t/custom-transparent-material-on-ar-mesh/3352/2 "2023-03-09T19:19:29Z")

</div>

Hi Sean,

Thank you for reaching out to Lightship Support! If I understand correctly, you want to overlay the “sky” mask with a transparent texture but aren’t seeing the expected result. You also mentioned that there was another thread on the forums with a similar issue that was unfortunately left with a cliffhanger. Could you please send me the shader code, the texture you’re trying to apply, and the link to the thread you’re referring to? If you would prefer to keep your content private, feel free to DM me instead. In the meantime, I will try to reproduce your issue to the best of my ability.

Thanks,

Maverick L.

---

<div class="post-metadata">

**Author:** ![MadmanSilver](https://sea2.discourse-cdn.com/niantic/user_avatar/community.nianticspatial.com/madmansilver/32/1002_2.png) [@MadmanSilver](https://community.nianticspatial.com/u/MadmanSilver)\
**Post date:** [March 10, 2023, 5:10pm UTC](https://community.nianticspatial.com/t/custom-transparent-material-on-ar-mesh/3352/3 "2023-03-10T17:10:45Z")

</div>

No, not the sky mask. The mesh generated by your real time meshing scripts. I never once mentioned anything about the sky.

---

<div class="post-metadata">

**Author:** ![MadmanSilver](https://sea2.discourse-cdn.com/niantic/user_avatar/community.nianticspatial.com/madmansilver/32/1002_2.png) [@MadmanSilver](https://community.nianticspatial.com/u/MadmanSilver)\
**Post date:** [March 10, 2023, 5:14pm UTC](https://community.nianticspatial.com/t/custom-transparent-material-on-ar-mesh/3352/4 "2023-03-10T17:14:37Z")

</div>

Here’s the other thread

> [@Trouble adding custom materials/shaders to AR Mesh](https://community.nianticspatial.com/t/trouble-adding-custom-materials-shaders-to-ar-mesh/2669):
>
> Device type & OS version: iOS Host machine & OS version: Mac Issue Environment: Unity Mock / On Device ARDK version: 2.0.0 Unity version: 2020.3.28f1 Description of the issue: I’d like to use a custom shader with an animated material that shows waves across a mesh with alpha in between to simulate a scanning animation across the room. I’ve created the shader and it works with primitive shapes and other meshes like planes, but for some reason, I can’t seem to get any custom materials to …

As for the shader and texture, that isn’t necessary. I tried every shader that comes packaged with Unity and every combination of import settings for multiple different kinds of texture files.

---

<div class="post-metadata">

**Author:** ![Maverick\_Niantic](https://avatars.discourse-cdn.com/v4/letter/m/8edcca/32.png) [@Maverick\_Niantic](https://community.nianticspatial.com/u/Maverick_Niantic)\
**Post date:** [March 10, 2023, 6:39pm UTC](https://community.nianticspatial.com/t/custom-transparent-material-on-ar-mesh/3352/5 "2023-03-10T18:39:44Z")

</div>

Thank you for the clarification! Now that we’re on the same page, I can find a solution for you.

---

<div class="post-metadata">

**Author:** ![Maverick\_Niantic](https://avatars.discourse-cdn.com/v4/letter/m/8edcca/32.png) [@Maverick\_Niantic](https://community.nianticspatial.com/u/Maverick_Niantic)\
**Post date:** [March 10, 2023, 9:57pm UTC](https://community.nianticspatial.com/t/custom-transparent-material-on-ar-mesh/3352/6 "2023-03-10T21:57:33Z")

</div>

Once again I want to thank you for bearing with me here. I have excellent news! I was able to find a solution! Due to the mesh chunking, you can’t just apply the material to each chunk and expect the result you’re anticipating. You have to write a shader that draws your texture based on world space coordinates so you get something that covers the entire mesh. I’ve written a sample shader that accomplishes this and supports tiling and the alpha channel. You can use this as a reference for your own.

In my testing, my goal was to overlay a transparent texture of a basketball over the mesh.

 ![Screenshot 2023-03-10 at 2.23.21 PM](https://us1.discourse-cdn.com/niantic/original/2X/d/db82dbfc7e5848afb262a6df56d796f905abe443.jpeg)

```auto
Shader "Worldspace Shader" {
    Properties {
        _Color ("Main Color", Color) = (1,1,1,1)
        _MainTex ("Base (RGB)", 2D) = "white" {}
        _Scale ("Texture Scale", Float) = 1.0
    }

    SubShader {
        Tags { "RenderType"="Opaque" "Queue"="AlphaTest" }
        LOD 200

        Cull Off ZWrite On ZTest LEqual Blend One Zero

    CGPROGRAM
    #pragma surface surf Lambert alpha
    sampler2D _MainTex;
    fixed4 _Color;
    float _Scale;

    struct Input
    {
        float3 worldNormal;
        float3 worldPos;
    };

    void surf(Input IN, inout SurfaceOutput o)
    {
        float2 UV;
        fixed4 c;

        if (abs(IN.worldNormal.x) > 0.5)
        {
            UV = IN.worldPos.yz; // side
            c = tex2D(_MainTex, UV * _Scale);
        }
        else if(abs(IN.worldNormal.z) > 0.5)
        {
            UV = IN.worldPos.xy; // front
            c = tex2D(_MainTex, UV * _Scale);
        }
        else
        {
            UV = IN.worldPos.xz; // top
            c = tex2D(_MainTex, UV * _Scale);
        }

        o.Albedo = c.rgb * _Color;
        o.Alpha = tex2D(_MainTex, UV).a;
    }

    ENDCG
    }

Fallback "VertexLit"
}

```

---

<div class="post-metadata">

**Author:** ![Maverick\_Niantic](https://avatars.discourse-cdn.com/v4/letter/m/8edcca/32.png) [@Maverick\_Niantic](https://community.nianticspatial.com/u/Maverick_Niantic)\
**Post date:** [March 24, 2023, 6:30pm UTC](https://community.nianticspatial.com/t/custom-transparent-material-on-ar-mesh/3352/7 "2023-03-24T18:30:41Z")

</div>

Hi Sean,

Just checking in. Were you able to achieve what you were looking for with the aid of that sample? Do you have any further questions or concerns?

Best,  
Maverick L.

---

<div class="post-metadata">

**Author:** ![Maverick\_Niantic](https://avatars.discourse-cdn.com/v4/letter/m/8edcca/32.png) [@Maverick\_Niantic](https://community.nianticspatial.com/u/Maverick_Niantic)\
**Post date:** [March 5, 2026, 11:44pm UTC](https://community.nianticspatial.com/t/custom-transparent-material-on-ar-mesh/3352/8 "2026-03-05T23:44:49Z")

</div>

Closed on March 5, 2026, 11:44pm UTC

Age
