I have a quite similar problem where I have a custom shader I created that works perfectly on my PC and also through Link, but when building and installing the apk in the Quest, it doesn’t work anymore.
Unfortunately for me that solution didn’t work.
To be more specific the shader works if I don’t try to use any data coming from the tex2D function as return value for my frag function. Actually I realized I can use the function, but I can’t use any data coming from there in the data that will be returned by frag, even if it works in my desktop and through Link.
The code to the custom shader follows:
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
Shader "Custom/SphericalMaskDissolve1" {
Properties{
_TintColor("Tint Color", Color) = (0.5,0.5,0.5,0.5)
_MainTex("Particle Texture", 2D) = "white" {}
_InvFade("Soft Particles Factor", Range(0.01,3.0)) = 1.0
_Glossiness("Smoothness", Range(0,1)) = 0.5
_Metallic("Metallic", Range(0,1)) = 0.0
[HDR]_Emission("Emission", Color) = (1,1,1,1)
_NoiseSize("Noise size", float) = 1
}
Category{
Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
Blend SrcAlpha One
AlphaTest Greater .01
ColorMask RGB
Cull Off Lighting Off ZWrite Off Fog { Color(0,0,0,0) }
BindChannels {
Bind "Color", color
Bind "Vertex", vertex
Bind "TexCoord", texcoord
}
// ---- Fragment program cards
SubShader {
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma fragmentoption ARB_precision_hint_fastest
#pragma multi_compile_particles
#include "UnityCG.cginc"
sampler2D _MainTex;
fixed4 _TintColor;
half _Glossiness;
half _Metallic;
fixed4 _Emission;
float _NoiseSize;
float3 _GLOBALMaskPosition;
half _GLOBALMaskRadius;
half _GLOBALMaskSoftness;
struct appdata_t {
float4 vertex : POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
float4 position : POSITION;//
};
struct v2f {
float4 vertex : POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
float2 texcoord2 : TEXCOORD0;
float4 worldSpacePos : TEXCOORD1;//
#ifdef SOFTPARTICLES_ON
float4 projPos : TEXCOORD1;
#endif
};
struct Input {
float2 uv_MainTex;
float3 worldPos;
};
float4 _MainTex_ST;
v2f vert(appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
#ifdef SOFTPARTICLES_ON
o.projPos = ComputeScreenPos(o.vertex);
COMPUTE_EYEDEPTH(o.projPos.z);
#endif
o.color = v.color;
o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
o.worldSpacePos = mul(unity_ObjectToWorld, v.position);//
return o;
}
sampler2D _CameraDepthTexture;
float _InvFade;
fixed4 frag(v2f i) : COLOR
{
#ifdef SOFTPARTICLES_ON
float sceneZ = LinearEyeDepth(UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos))));
float partZ = i.projPos.z;
float fade = saturate(_InvFade * (sceneZ - partZ));
i.color.a *= fade;
#endif
half dist = distance(_GLOBALMaskPosition, i.worldSpacePos);//
half sphere = 1 - saturate((dist - _GLOBALMaskRadius) / _GLOBALMaskSoftness);//
//clip(sphere - 0.1);//
float4 textureColor = tex2D(_MainTex, i.texcoord);
return 2.0f * i.color * _TintColor * textureColor;
}
ENDCG
}
}
// ---- Dual texture cards
SubShader {
Pass {
SetTexture[_MainTex] {
constantColor[_TintColor]
combine constant * primary
}
SetTexture[_MainTex] {
combine texture * previous DOUBLE
}
}
}
// ---- Single texture cards (does not do color tint)
SubShader {
Pass {
SetTexture[_MainTex] {
combine texture * primary
}
}
}
}
}
If I don’t use “textureColor” in the return line of frag (even if storing it to a variable) it works the same way on Quest as on PC