Forum Discussion
Jepplen
5 years agoExpert Protege
Mip Map Bias workaround for Android (Unity)
Hello,
According to this Oculus blogg guide, setting the texture.MipMapBias to -0.7 is a recommended setting to keep the texture relatively sharp.
Google this: ( I can't post links )
common-rendering-mistakes-how-to-find them-and-how-to-fix-them
But as far as I can make out of the unity documentation, Android builds for such as Oculus GO and Quest, does not support this feature.
I am looking for a work around for Android in Unity.
Does anyone have any ideas?
According to this Oculus blogg guide, setting the texture.MipMapBias to -0.7 is a recommended setting to keep the texture relatively sharp.
Google this: ( I can't post links )
common-rendering-mistakes-how-to-find them-and-how-to-fix-them
But as far as I can make out of the unity documentation, Android builds for such as Oculus GO and Quest, does not support this feature.
I am looking for a work around for Android in Unity.
Does anyone have any ideas?
1 Reply
- JepplenExpert Protege
I found a an excellent solution that works right out of the box.
By Correia55
Unfortunately I can't post links, you can find their Unity Answer by googling the following string:
sprites-and-mip-maps-in-android-vs-iosBasically Android and IOS supports MipMapBias when it goes via a custom shader.
Correia55 added the MipMapBias setting to the default Sprites/Default shader.
With this you simply set the bias you want in the shader properties in the editor.
Very awesome!!
Here is the shader code:Shader "Sprites/Modified"{Properties{[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}_Color ("Tint", Color) = (1,1,1,1)_MainTexBias ("Mip Bias (-1 to 1)", float) = -0.65[MaterialToggle] PixelSnap ("Pixel snap", Float) = 0}SubShader{Tags{"Queue"="Transparent""IgnoreProjector"="True""RenderType"="Transparent""PreviewType"="Plane""CanUseSpriteAtlas"="True"}Cull OffLighting OffZWrite OffBlend One OneMinusSrcAlphaPass{CGPROGRAM#pragma vertex vert#pragma fragment frag#pragma multi_compile _ PIXELSNAP_ON#pragma shader_feature ETC1_EXTERNAL_ALPHA#include "UnityCG.cginc"struct appdata_t{float4 vertex : POSITION;float4 color : COLOR;float2 texcoord : TEXCOORD0;};struct v2f{float4 vertex : SV_POSITION;fixed4 color : COLOR;float2 texcoord : TEXCOORD0;};fixed4 _Color;v2f vert(appdata_t IN){v2f OUT;OUT.vertex = mul(UNITY_MATRIX_MVP, IN.vertex);OUT.texcoord = IN.texcoord;OUT.color = IN.color * _Color;#ifdef PIXELSNAP_ONOUT.vertex = UnityPixelSnap (OUT.vertex);#endifreturn OUT;}sampler2D _MainTex;sampler2D _AlphaTex;half _MainTexBias;fixed4 SampleSpriteTexture (float2 uv){fixed4 color = tex2D (_MainTex, uv);#if ETC1_EXTERNAL_ALPHA// get the color from an external texture (usecase: Alpha support for ETC1 on android)color.a = tex2D (_AlphaTex, uv).r;#endif //ETC1_EXTERNAL_ALPHAreturn color;}fixed4 frag(v2f IN) : SV_Target{fixed4 c = tex2Dbias(_MainTex, half4(IN.texcoord.x, IN.texcoord.y, 0.0, _MainTexBias)) * IN.color;c.rgb *= c.a;return c;}ENDCG}}}
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 8 months ago
- 10 months ago