Hi I just updated my unity client to 5.6.1f1 today and I am now unable to build to my android device. I also received the following errors:
The following is code is the shader script that the error is occuring on:
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
Shader "Unlit/Texture HSBC" {
Properties
{
//[PerRendererData] _MainTex ("Sprite Texture", 2D) = "black" {}
_MainTex("Base (RGB), Alpha (A)", 2D) = "black" {}
_Hue("Hue", Range(0.0, 1.0)) = 0
_Saturation("Saturation", Range(-1.0, 1.0)) = 0
_Brightness("Brightness", Range(-1.0, 1.0)) = 0
_Contrast("Contrast", Range(-1.0, 1.0)) = 0
_StencilComp ("Stencil Comparison", Float) = 8
_Stencil ("Stencil ID", Float) = 0
_StencilOp ("Stencil Operation", Float) = 0
_StencilWriteMask ("Stencil Write Mask", Float) = 255
_StencilReadMask ("Stencil Read Mask", Float) = 255
_ColorMask ("Color Mask", Float) = 15
//[MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
}
SubShader
{
LOD 100
Tags
{
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
"PreviewType"="Plane"
"CanUseSpriteAtlas"="True"
}
Cull Off
Lighting Off
ZWrite Off
Fog{ Mode Off }
Offset -1, -1
Blend SrcAlpha OneMinusSrcAlpha
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
// Function
inline float3 applyHue(float3 aColor, float aHue)
{
float angle = radians(aHue);
float3 k = float3(0.57735, 0.57735, 0.57735);
float cosAngle = cos(angle);
//Rodrigues' rotation formula
return aColor * cosAngle + cross(k, aColor) * sin(angle) + k * dot(k, aColor) * (1 - cosAngle);
}
inline float4 applyHSBEffect(float4 startColor, fixed4 hsbc)
{
float hue = 360 * hsbc.r;
float saturation = hsbc.g + 1;
float brightness = hsbc.b;
float contrast = hsbc.a + 1;
float4 outputColor = startColor;
outputColor.rgb = applyHue(outputColor.rgb, hue);
outputColor.rgb = (outputColor.rgb - 0.5f) * contrast + 0.5f + brightness;
outputColor.rgb = lerp(Luminance(outputColor.rgb), outputColor.rgb, saturation);
return outputColor;
}
struct appdata_t
{
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
fixed4 color : COLOR;
};
struct v2f
{
float4 vertex : SV_POSITION;
half2 texcoord : TEXCOORD0;
fixed4 hsbc : COLOR;
float alpha : float;
};
sampler2D _MainTex;
fixed _Hue, _Saturation, _Brightness, _Contrast;
v2f vert(appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.texcoord = v.texcoord;
o.hsbc = fixed4(_Hue, _Saturation, _Brightness, _Contrast);
o.alpha = v.color.a;
return o;
}
fixed4 frag(v2f i) : COLOR
{
float4 startColor = tex2D(_MainTex, i.texcoord);
float4 hsbColor = applyHSBEffect(startColor, i.hsbc);
hsbColor.a *= i.alpha;
return hsbColor;
}
ENDCG
} // Pass
} // SubShader
SubShader
{
LOD 100
Tags
{
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
"PreviewType"="Plane"
"CanUseSpriteAtlas"="True"
}
Pass
{
Cull Off
Lighting Off
ZWrite Off
Fog{ Mode Off }
Offset -1, -1
ColorMask RGB
//AlphaTest Greater .01
Blend SrcAlpha OneMinusSrcAlpha
ColorMaterial AmbientAndDiffuse
SetTexture[_MainTex] { Combine Texture * Primary }
} // Pass
} // SubShader
}
EDIT: The offending bit of code is line 77 here, not line 87.
As I’m not a shader programmer I have no idea how to fix this issue correctly. Does anyone know how to resolve this?
Additional Info: The shader was meant to allow my 2D sprite images to use HSB colors instead of Unity’s default HSV/HSL. It also needs to be able to accept any alpha changes to the image
UPDATE:
In other news I’m also getting this error
but this hasn’t caused an issue before as well. This is the line of code in the projects settings that is causing the issue:
I’ve tried changing it to just {fileID: 1} but that only worked temporarily as it eventually just resets itself back to the above
UPDATE 2:
Removing the splash screen image seems to have fixed that error. I still have the shader error preventing me from making a build though.