Unity 5.2 does not render texture on android device
I captured this picture from my test project. The model is rendered very well in unity Editor. But when I built it on my android device most of the models' texture were not rendered. I've tried to set the Texture in inspector as following: Advanced->override for android->Format RGBA Compressed ETC2 4 Bits and ETC2 8 bits. Both of these didn't work. Is there any one else have the same problem? I really appreciate your answers.
Answer by LoungeKatt · May 10, 2017 at 07:26 PM
This is a known issue with Unity. You can find more details at:
https://forum.unity3d.com/threads/rendertexture-not-working-on-ios-and-android-unity-4-2-0f4.192561/
https://forum.unity3d.com/threads/render-texture-not-working-on-device-unity-5-2-1f1.358483/
and a few others where the moderators and staff claim it is fixed in a future release or (with a touch of unnecessary arrogance) that the issue is the user and a bug never existed at all.
BUT
This is going to sound silly, but add an ImageEffect to the main camera. I have made a dummy effect that is attached to my main camera and without any logical explanation, it fixes RenderTexture on mobile.
DummyEffect.cs:
using UnityEngine;
[ExecuteInEditMode]
[AddComponentMenu("Image Effects/Dummy Effect")]
public class DummyEffect : ImageEffectBase {
// Called by camera to apply image effect
void OnRenderImage (RenderTexture source, RenderTexture destination) {
Graphics.Blit (source, destination, material);
}
}
DummyEffect.shader:
Shader "Hidden/Dummy Effect" {
Properties {
_MainTex ("Base (RGB)", RECT) = "white" {}
}
SubShader {
Pass {
ZTest Always Cull Off ZWrite Off
Fog { Mode off }
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"
uniform sampler2D _MainTex;
float4 frag (v2f_img i) : COLOR {
return tex2D(_MainTex, i.uv);
}
ENDCG
}
}
Fallback off
}