- Home /
Can not be compiled when running on Android for each texture shader 8 Galaxy Tab
Galaxy Tab shader work that follows. SnapDragon QSD8650 (1GHz) I work on Android, the I do not know why.
Why do not compile? Kindly let me know.
Shader "Unlit/MixTextures" { Properties { _MainTex ("Main Base(RGB) Alpha(A)", 2D) = "white" {} _MainTex2 ("Main2 Base(RGB) Alpha(A)", 2D) = "white" {} _MainTex3 ("Main3 Base(RGB) Alpha(A)", 2D) = "white" {} _MainTex4 ("Main4 Base(RGB) Alpha(A)", 2D) = "white" {} _MainTex5 ("Main5 Base(RGB) Alpha(A)", 2D) = "white" {} _MainTex6 ("Main6 Base(RGB) Alpha(A)", 2D) = "white" {} _MainTex7 ("Main7 Base(RGB) Alpha(A)", 2D) = "white" {} // _MainTex8 ("Main8 Base(RGB) Alpha(A)", 2D) = "white" {}
_TextureOffsetAndSize ("textureOffsetAndSize", Vector) = (0, 0, 0, 0)
_TextureOffsetAndSize2 ("textureOffsetAndSize2", Vector) = (0, 0, 0, 0)
_TextureOffsetAndSize3 ("textureOffsetAndSize3", Vector) = (0, 0, 0, 0)
_TextureOffsetAndSize4 ("textureOffsetAndSize4", Vector) = (0, 0, 0, 0)
_TextureOffsetAndSize5 ("textureOffsetAndSize5", Vector) = (0, 0, 0, 0)
_TextureOffsetAndSize6 ("textureOffsetAndSize6", Vector) = (0, 0, 0, 0)
_TextureOffsetAndSize7 ("textureOffsetAndSize7", Vector) = (0, 0, 0, 0)
// _TextureOffsetAndSize8 ("textureOffsetAndSize8", Vector) = (0, 0, 0, 0)
}
SubShader {
Tags{"Queue"="Transparent"}
Pass{
// 顔ベース
CGPROGRAM
//#pragma only_renderers gles
//#pragma target 3.0
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
sampler2D _MainTex;
sampler2D _MainTex2;
sampler2D _MainTex3;
sampler2D _MainTex4;
sampler2D _MainTex5;
sampler2D _MainTex6;
sampler2D _MainTex7;
sampler2D _MainTex8;
float4 _TextureOffsetAndSize;
float4 _TextureOffsetAndSize2;
float4 _TextureOffsetAndSize3;
float4 _TextureOffsetAndSize4;
float4 _TextureOffsetAndSize5;
float4 _TextureOffsetAndSize6;
float4 _TextureOffsetAndSize7;
float4 _TextureOffsetAndSize8;
struct v2f{
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
};
float4 _MainTex_ST;
v2f vert(appdata_base v)
{
v2f o;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
return o;
}
float4 frag( v2f i ) : COLOR {
float2 defUV = i.uv;
float2 maskUV = defUV;
// 2
maskUV.x += _TextureOffsetAndSize.x;
maskUV.y += _TextureOffsetAndSize.y;
maskUV.x /= _TextureOffsetAndSize.z;
maskUV.y /= _TextureOffsetAndSize.w;
float4 addTex = tex2D(_MainTex2, maskUV);
float4 result = (tex2D(_MainTex, i.uv)*(1-addTex.w) + tex2D(_MainTex2, maskUV)*addTex.w);
// 3
maskUV.x = (defUV.x + _TextureOffsetAndSize2.x)/_TextureOffsetAndSize2.z;
maskUV.y = (defUV.y + _TextureOffsetAndSize2.y)/_TextureOffsetAndSize2.w;
addTex = tex2D(_MainTex3, maskUV);
result = result*(1-addTex.w)+ addTex*addTex.w;
// 4
maskUV.x = (defUV.x + _TextureOffsetAndSize3.x)/_TextureOffsetAndSize3.z;
maskUV.y = (defUV.y + _TextureOffsetAndSize3.y)/_TextureOffsetAndSize3.w;
addTex = tex2D(_MainTex4, maskUV);
result = result*(1-addTex.w)+ addTex*addTex.w;
// 5
maskUV.x = (defUV.x + _TextureOffsetAndSize4.x)/_TextureOffsetAndSize4.z;
maskUV.y = (defUV.y + _TextureOffsetAndSize4.y)/_TextureOffsetAndSize4.w;
addTex = tex2D(_MainTex5, maskUV);
result = result*(1-addTex.w)+ addTex*addTex.w;
// 6
maskUV.x = (defUV.x + _TextureOffsetAndSize5.x)/_TextureOffsetAndSize5.z;
maskUV.y = (defUV.y + _TextureOffsetAndSize5.y)/_TextureOffsetAndSize5.w;
addTex = tex2D(_MainTex6, maskUV);
result = result*(1-addTex.w)+ addTex*addTex.w;
// 7
maskUV.x = (defUV.x + _TextureOffsetAndSize6.x)/_TextureOffsetAndSize6.z;
maskUV.y = (defUV.y + _TextureOffsetAndSize6.y)/_TextureOffsetAndSize6.w;
addTex = tex2D(_MainTex7, maskUV);
result = result*(1-addTex.w)+ addTex*addTex.w;
// 8
maskUV.x = (defUV.x + _TextureOffsetAndSize7.x)/_TextureOffsetAndSize7.z;
maskUV.y = (defUV.y + _TextureOffsetAndSize7.y)/_TextureOffsetAndSize7.w;
addTex = tex2D(_MainTex8, maskUV);
result = result*(1-addTex.w)+ addTex*addTex.w;
return result;
//return (tex2D(_MainTex, i.uv)*(1-addTex.w) + tex2D(_MainTex2, maskUV)*addTex.w);
//
//return half4(_TextureOffsetAndSize.x, _TextureOffsetAndSize.y, _TextureOffsetAndSize.z, 1); // _TextureOffsetAndSize Output
//return half4(i.uv.x, i.uv.y, 0, 1); // uv Output
//return half4(1, 0, 0, 0);
}
ENDCG
}
}
//Fallback "Diffuse"
}
Do you get any kind of error when you try to compile this shader?
Answer by macs_yums · Jul 05, 2011 at 12:26 PM
Has been successfully compiled and turn off the near the end. What will be compiled with Galaxy You can write a little more short shaders? I move that Xperia, which is purple and it appears in the Galaxy. Toka what I have restrictions on the number of fragment length or texture shaders? That's right texture, but it reduces the shader is shorter than think of it.
Shader "MixTextures" { Properties { _MainTex ("Main Base(RGB) Alpha(A)", 2D) = "white" {} _MainTex2 ("Main2 Base(RGB) Alpha(A)", 2D) = "white" {} _MainTex3 ("Main3 Base(RGB) Alpha(A)", 2D) = "white" {} _MainTex4 ("Main4 Base(RGB) Alpha(A)", 2D) = "white" {} _MainTex5 ("Main5 Base(RGB) Alpha(A)", 2D) = "white" {} _MainTex6 ("Main6 Base(RGB) Alpha(A)", 2D) = "white" {} _MainTex7 ("Main7 Base(RGB) Alpha(A)", 2D) = "white" {}
_TextureOffsetAndSize ("textureOffsetAndSize", Vector) = (0, 0, 0, 0) _TextureOffsetAndSize2 ("textureOffsetAndSize2", Vector) = (0, 0, 0, 0) _TextureOffsetAndSize3 ("textureOffsetAndSize3", Vector) = (0, 0, 0, 0) _TextureOffsetAndSize4 ("textureOffsetAndSize4", Vector) = (0, 0, 0, 0) _TextureOffsetAndSize5 ("textureOffsetAndSize5", Vector) = (0, 0, 0, 0) _TextureOffsetAndSize6 ("textureOffsetAndSize6", Vector) = (0, 0, 0, 0) _TextureOffsetAndSize7 ("textureOffsetAndSize7", Vector) = (0, 0, 0, 0) } SubShader { Tags{"Queue"="Transparent"} Pass{ CGPROGRAM //#pragma only_renderers gles //#pragma target 3.0 #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc"
sampler2D _MainTex;
sampler2D _MainTex2;
sampler2D _MainTex3;
sampler2D _MainTex4;
sampler2D _MainTex5;
sampler2D _MainTex6;
sampler2D _MainTex7;
sampler2D _MainTex8;
float4 _TextureOffsetAndSize;
float4 _TextureOffsetAndSize2;
float4 _TextureOffsetAndSize3;
float4 _TextureOffsetAndSize4;
float4 _TextureOffsetAndSize5;
float4 _TextureOffsetAndSize6;
float4 _TextureOffsetAndSize7;
float4 _TextureOffsetAndSize8;
struct v2f{
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
};
float4 _MainTex_ST;
v2f vert(appdata_base v)
{
v2f o;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
return o;
}
float4 frag( v2f i ) : COLOR {
float2 defUV = i.uv;
float2 maskUV = defUV;
// 2
maskUV = (defUV + _TextureOffsetAndSize.xy)/_TextureOffsetAndSize.zw;
float4 addTex = tex2D(_MainTex2, maskUV);
float4 result = (float4(1.0f, 0.84f, 0.72f, 1.0f)*(1-addTex.w) + addTex * addTex.w);
// 3
maskUV = (defUV + _TextureOffsetAndSize2.xy)/_TextureOffsetAndSize2.zw;
addTex = tex2D(_MainTex3, maskUV);
result = result*(1-addTex.w)+ addTex*addTex.w;
// 4
maskUV = (defUV + _TextureOffsetAndSize3.xy)/_TextureOffsetAndSize3.zw;
addTex = tex2D(_MainTex4, maskUV);
result = result*(1-addTex.w)+ addTex*addTex.w;
// 5
maskUV = (defUV + _TextureOffsetAndSize4.xy)/_TextureOffsetAndSize4.zw;
addTex = tex2D(_MainTex5, maskUV);
result = result*(1-addTex.w)+ addTex*addTex.w;
// 6
maskUV = (defUV + _TextureOffsetAndSize5.xy)/_TextureOffsetAndSize5.zw;
addTex = tex2D(_MainTex6, maskUV);
result = result*(1-addTex.w)+ addTex*addTex.w;
// 7
maskUV = (defUV + _TextureOffsetAndSize6.xy)/_TextureOffsetAndSize6.zw;
addTex = tex2D(_MainTex7, maskUV);
result = result*(1-addTex.w)+ addTex*addTex.w;
// 8
// maskUV = (defUV + _TextureOffsetAndSize7.xy)/_TextureOffsetAndSize7.zw; // addTex = tex2D(_MainTex8, maskUV); // result = result*(1-addTex.w)+ addTex*addTex.w; return result; }
ENDCG
}
}
//Fallback "Diffuse"
}
Answer by macs_yums · Jul 05, 2011 at 12:29 PM
Sorry, miss type.
Has been successfully compiled and turn off the near the end. What will be compiled with Galaxy You can write a little more short shaders? Appear normal but that Xperia, which is purple and it appears in the Galaxy. Why not have a limit on the number of fragment length or texture shaders? That's right texture, but it reduces the shader is shorter than think of it.
Answer by macs_yums · Jul 05, 2011 at 03:30 PM
This happened because that is not the first set of eight texture. I think the behavior is different when it happens to fetch a texture that is not set in the Galaxy and the Xperia. Was rude.