- Home /
This is not working!
This is my outline shader, which i am using, it doesnt seem to work in android after building it.
the shader: Shader "Hidden/OutlineEffect" { Properties { _MainTex ("Base (RGB)", 2D) = "white" {} _LineColor ("Line Color", Color) = (1,1,1,.5)
}
SubShader
{
Pass
{
Tags { "RenderType"="Opaque" }
LOD 200
ZTest Always
ZWrite Off
Cull Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 3.0
#include "UnityCG.cginc"
sampler2D _MainTex;
sampler2D _OutlineSource;
struct v2f {
float4 position : SV_POSITION;
float2 uv : TEXCOORD0;
};
v2f vert(appdata_img v)
{
v2f o;
o.position = mul(UNITY_MATRIX_MVP, v.vertex);
o.uv = v.texcoord;
return o;
}
float _LineThicknessX;
float _LineThicknessY;
float _LineIntensity;
half4 _LineColor1;
half4 _LineColor2;
half4 _LineColor3;
int _FlipY;
int _Dark;
uniform float4 _MainTex_TexelSize;
half4 frag (v2f input) : COLOR
{
float2 uv = input.uv;
if (_FlipY == 1)
uv.y = 1 - uv.y;
half4 originalPixel = tex2D(_MainTex,input.uv);
half4 outlineSource = tex2D(_OutlineSource, uv);
float h = .95f;
half4 outline = 0;
bool hasOutline = false;
half4 sample1 = tex2D(_OutlineSource, uv + float2(_LineThicknessX,0.0) * _MainTex_TexelSize.x * 1000.0f);
half4 sample2 = tex2D(_OutlineSource, uv + float2(-_LineThicknessX,0.0) * _MainTex_TexelSize.x * 1000.0f);
half4 sample3 = tex2D(_OutlineSource, uv + float2(.0,_LineThicknessY) * _MainTex_TexelSize.y * 1000.0f);
half4 sample4 = tex2D(_OutlineSource, uv + float2(.0,-_LineThicknessY) * _MainTex_TexelSize.y * 1000.0f);
if(outlineSource.a < h)
{
if (sample1.r > h || sample2.r > h || sample3.r > h || sample4.r > h)
{
outline = _LineColor1 * _LineIntensity * _LineColor1.a;
if (_Dark)
originalPixel *= 1 - _LineColor1.a;
hasOutline = true;
}
else if (sample1.g > h || sample2.g > h || sample3.g > h || sample4.g > h)
{
outline = _LineColor2 * _LineIntensity * _LineColor2.a;
if(_Dark)
originalPixel *= 1 - _LineColor2.a;
hasOutline = true;
}
else if (sample1.b > h || sample2.b > h || sample3.b > h || sample4.b > h)
{
outline = _LineColor3 * _LineIntensity * _LineColor3.a;
if (_Dark)
originalPixel *= 1 - _LineColor3.a;
hasOutline = true;
}
}
//return outlineSource;
if (_Dark)
{
if (hasOutline)
return originalPixel + outline;
else
return originalPixel;
}
else
{
if(hasOutline)
return originalPixel + outline * _LineColor1.a;
else
return originalPixel;
}
}
ENDCG
}
}
FallBack "Diffuse"
}
Answer by Sackstand · Dec 08, 2016 at 04:12 PM
i think Shader Language 3 is not supported on Android.
$$anonymous$$aybe, I have two android tablets one with android 6.0, and 5.0, both failed to help me with shading outlines. However when I tried it on my Nexus 5, it worked just as in my editor. Is there in anyway, I could use it on my tabs, I really need to make my shaders compatible for all devices. What'dya suggest? $$anonymous$$aybe is there a way to ensure or convert the following shader code into supported shader language ?
Your answer
![](https://koobas.hobune.stream/wayback/20220612102306im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Combine Shaders 0 Answers
Shader Edit Help: 2D Outline Coloring 2 Answers
Invert background in shadergraph 0 Answers
Culling part of a sprite in Sprite Manager 2 1 Answer
Silhouette Toon Shader 0 Answers