- Home /
Question by
Astromanson · Jul 14, 2019 at 07:18 PM ·
shaderbug
Transerent Shader renders black on android afetr updating unity
Hello, I have a water 2D shader. After updating Unity to 2019.1 it renders black on android
Shader "Custom/Water2D Surface" {
Properties {
_Color("Color", Color) = (1,1,1,1)
_MainTex ("Normalmap", 2D) = "bump" {}
_Magnitude("Magnitude", Range(0,1)) = 0.05
}
Category {
Tags {
"Queue"="Transparent"
"RenderType"="Transparent"
}
SubShader {
// This pass grabs the screen behind the object into a texture.
// We can access the result in the next pass as _BackgroundTex
GrabPass { "_BackgroundTex" }
// Main pass: Take the texture grabbed above and use the bumpmap to perturb it
Pass {
Name "BASE"
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct vertexInput {
float4 vertex : POSITION;
float2 texcoord: TEXCOORD0;
};
struct vertexOutput {
float4 vertex : SV_POSITION;
float4 uvgrab : TEXCOORD0;
float2 uvmain : TEXCOORD2;
UNITY_FOG_COORDS(3)
};
fixed4 _Color;
sampler2D _MainTex;
float4 _MainTex_ST;
float _BumpAmt;
float4 _BumpMap_ST;
float _Magnitude;
vertexOutput vert (vertexInput v)
{
vertexOutput o;
o.vertex = UnityObjectToClipPos(v.vertex);
#if UNITY_UV_STARTS_AT_TOP
float scale = -1.0;
#else
float scale = 1.0;
#endif
o.uvgrab.xy = (float2(o.vertex.x, o.vertex.y*scale) + o.vertex.w) * 0.5;
o.uvgrab.zw = o.vertex.zw;
o.uvmain = TRANSFORM_TEX( v.texcoord, _MainTex );
UNITY_TRANSFER_FOG(o,o.vertex);
return o;
}
sampler2D _BackgroundTex;
float4 _GrabTexture_TexelSize;
sampler2D _BumpMap;
half4 frag (vertexOutput i) : SV_Target
{
// Calculate perturbed coordinates
half4 bump = tex2D(_MainTex, i.uvmain);
half2 distortion = UnpackNormal(bump).rg;
i.uvgrab.xy += distortion * _Magnitude;
// Get pixel in GrabTexture, rendered in previous pass
half4 col = tex2Dproj(_BackgroundTex, UNITY_PROJ_COORD(i.uvgrab));
// Apply color
col *= _Color;
return col;
}
ENDCG
}
}
}
}
Comment
Answer by Astromanson · Jul 15, 2019 at 08:50 AM
Didn't solve the issue, the shader is still renders black on Android.
Your answer
![](https://koobas.hobune.stream/wayback/20220612204858im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Very simple 2D Shader renders black 0 Answers
Shader renders differently in editor and in exported app 0 Answers
Why does fmod(x,1.0) not work in Unity4, but fmod(x,1.0001) does? 0 Answers
Transparent grid shader issue 1 Answer
Textures and shaders broken 2 Answers