Unity DrawMeshInstanced not working on Quest — Oculus
IMPORTANT:

All Oculus Quest developers MUST PASS the concept review prior to gaining publishing access to the Quest Store and additional resources. Submit a concept document for review as early in your Quest application development cycle as possible: https://developer.oculus.com/quest-pitch/

For additional information and context, please see "Submitting Your App to the Oculus Quest Store".
Welcome to the Oculus Developer Forums!

Your participation on the forum is subject to the Oculus Code of Conduct.

In general, please be respectful and kind. If you violate the Oculus Code of Conduct, your access to the developer forums may be revoked at the discretion of Oculus staff.

Unity DrawMeshInstanced not working on Quest

For some reason DrawMeshInstanced doesn't work for me on Quest.
I tried both Graphics.DrawMeshInstanced and CommandBuffer.DrawMeshInstanced  and they both don't work.
DrawMesh does work with no problem.
DrawMeshInstanced works on PC running in the Editor or in a build on Rift.
The shader that I'm using is placed in a resources folder so it should be included in the build, but to make sure I also tried placing it in the mush include shaders list and even to place an object in the scene with a material that uses it. All of this didn't help.
I also checked the SystemInfo.supportsInstancing and it returns true on the Quest.
Here is the shader that I'm using:
Shader "Unlit_Mesh_Instance" {
    Properties {
        _Color ("Color", Color) = (1,1,1,1)
    }

    SubShader {
        Tags {
            "Queue"="Overlay"
			"RenderType"="Opaque"
        }

        Pass {
            Name "FORWARD"
            Tags {
                "LightMode"="ForwardBase"
            }
            Blend SrcAlpha OneMinusSrcAlpha
            ZTest Always
			//Offset -100, -100
			Cull Off

            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
			//#define UNITY_PASS_FORWARDBASE
            #include "UnityCG.cginc"
            #include "AutoLight.cginc"
			#pragma multi_compile_fwdbase
			#pragma multi_compile_instancing
            #pragma only_renderers d3d9 d3d11 glcore gles gles3 metal 
            #pragma target 3.0
            
            UNITY_INSTANCING_BUFFER_START(Props)
                UNITY_DEFINE_INSTANCED_PROP(float4, _Color)
            UNITY_INSTANCING_BUFFER_END(Props)
            
			struct VertexInput {
                float4 vertex : POSITION;
				UNITY_VERTEX_INPUT_INSTANCE_ID
            };
            
			struct VertexOutput {
                float4 pos : SV_POSITION;
				UNITY_VERTEX_INPUT_INSTANCE_ID
				UNITY_VERTEX_OUTPUT_STEREO
            };
            
			VertexOutput vert (VertexInput v) {
                VertexOutput o = (VertexOutput)0;
				UNITY_SETUP_INSTANCE_ID(v);
				UNITY_TRANSFER_INSTANCE_ID(v, o);
				UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
				o.pos = UnityObjectToClipPos(v.vertex); 
                return o;
            }
            
			float4 frag(VertexOutput i) : COLOR {
                UNITY_SETUP_INSTANCE_ID(i);
				UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
                return UNITY_ACCESS_INSTANCED_PROP(Props, _Color);
            }
            ENDCG
        }
    }
}
Am I missing something here?

Comments

  • tzmtntzmtn Posts: 2
    NerveGear
    Found a solution,
    Turns out it doesn't work when you dynamically create the material and set it to support instancing by code. If you create the material in advance and place it in your resources folder, everything works. Probably a bug, but I can work around that.
Sign In or Register to comment.