- Home /
Question by
Zeronev · Dec 11, 2015 at 10:46 PM ·
unity 5shadermeshtransparent
Shader making mesh dissappear or greyed out after Unity Update
Hello!
The shader I was using for my game was working correctly in the previous version of Unity (5.2), When I updated it, now I can no longer see it, nor working as intended. Thr shader is a Hologram shader.
(Yes, it's a bit large, If you don't want to read it, then any advice or anything I could look up to would be great)
Thanks in advance!! Here is the shader code:
Properties {
_Color ("Main Color", Color) = (30,70,80,0)
_ColorNoise ("Noise Color", Color) = (30,70,80,0)
_ImageTex ("Main Image", 2D) = "white" {}
_MainTex ("Scanlines", 2D) = "white" {}
_NoiseTex ("Displacement Map", 2D) = "white" {}
_SecondaryTex ("Noise Map", 2D) = "white" {}
_TimeScale ("Motion Speed", Range (0, 10)) = 4
_Displacement("Motion Displacement", Range (0, 1)) = 0.3
_Cutoff("Image Alpha Cutoff", Range (0, 1)) = 0.3
_XScrollSpeed ("X Scanline Speed", Range (-5, 5) ) = 0
_YScrollSpeed ("Y Scanline Speed", Range (-10, 10) ) = 1
}
SubShader {
Cull Off
// Now render front faces
Tags{ "RenderType"="Transparent"}
CGPROGRAM
#pragma surface surf Lambert alpha
float4 _ColorNoise;
sampler2D _SecondaryTex;
float _XScrollSpeed;
float _YScrollSpeed;
float _Cutoff;
float2 uv_MainTex;
sampler2D _ImageTex;
struct Input {
float2 uv_SecondaryTex;
float2 uv_ImageTex;
};
// Green front faces
void surf (Input IN, inout SurfaceOutput o) {
fixed2 scrollUV = IN.uv_SecondaryTex ;
float timeFrac = _Time*24;
fixed xScrollValue = timeFrac * 22;
fixed yScrollValue = timeFrac * 22;
scrollUV += fixed2( xScrollValue, yScrollValue );
half4 c = tex2D(_SecondaryTex, IN.uv_SecondaryTex) * _ColorNoise;
o.Albedo = tex2D(_SecondaryTex , scrollUV ).rgba * _ColorNoise.rgba * tex2D(_ImageTex, IN.uv_ImageTex).rgb;
o.Alpha = 0;
clip(tex2D(_ImageTex, IN.uv_ImageTex).a - _Cutoff - o.Albedo);
c.a = _ColorNoise.a;
}
ENDCG
Cull Off
Tags{ "RenderType"="Transparent"}
CGPROGRAM
#pragma surface surf Lambert vertex:vert alpha
#pragma target 3.0
#include "UnityCG.cginc"
sampler2D _MainTex;
sampler2D _NoiseTex;
sampler2D _ImageTex;
float _XScrollSpeed;
float _YScrollSpeed;
float4 _Color;
float _Displacement;
float _TimeScale;
float _Cutoff;
struct Input {
float2 uv_MainTex;
float2 uv_ImageTex;
INTERNAL_DATA
};
void vert(inout appdata_full v)
{
#if !defined(SHADER_API_OPENGL)
float timeFrac = frac(_Time*_TimeScale);
float2 texCoord = float2(v.texcoord.x + -timeFrac , v.texcoord.y + -timeFrac );
float2 texCoord2 = float2(v.texcoord.x + -timeFrac , v.texcoord.y + -timeFrac );
// average the noise out. This essetially allows any texture to be used as noise.
float4 noise = tex2Dlod(_NoiseTex, float4(texCoord,0,0)).rgba;
float displacement = (((noise.x + noise.z + noise.y)/4 - 0.3) * _Displacement);
v.vertex.xyz = v.vertex.xyz + (normalize(v.normal.xyz) * displacement );
#endif
}
void surf(Input IN, inout SurfaceOutput o)
{
fixed2 scrollUV = IN.uv_MainTex ;
float timeFrac = _Time;
fixed xScrollValue = timeFrac * _XScrollSpeed;
fixed yScrollValue = timeFrac * _YScrollSpeed;
scrollUV += fixed2( xScrollValue, yScrollValue );
half4 c = tex2D( _MainTex, scrollUV) * _Color;
o.Albedo = tex2D(_MainTex , scrollUV ).rgb * _Color.rgba * tex2D(_ImageTex, IN.uv_ImageTex).rgb;
o.Alpha = 0;
clip(tex2D(_ImageTex, IN.uv_ImageTex).a - _Cutoff - o.Albedo);
c.a = _Color.a;
}
ENDCG
}
Fallback "Diffuse"
Comment