- Home /
Shader worked in Unity 4.5, now Unity 5 kills it.
Good day everyone.
The shader that I constructed in Unity 4 worked perfectly and as I upgraded to Unity 5 it only gives me that ugly pink/purple color in game and debugs the error "Material doesn't have a float or range property "_T"".
Now what google has told me is that this error is just some bug if there is something else wrong with the shader. First it said that it was missing semantics at line 48, so I changed the name to v2f which gave me the material missing property error. The float value is not the problem, does someone spot anything else?
Anyone have any clue about what has changed in Unity 5 - shader wise? Does this have anything to do with DirectX11 or something like that?
Best regards.
Shader "Custom/Ottar_VertexBasic" {
//Texture : ShadowPlane_Tex_01
Properties
{
_MainTex ("Particle Texture", 2D) = "white" {}
_T("Transparency", Range(0,1)) = 1
}
SubShader {
Tags
{
"Queue" = "Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
}
Blend SrcAlpha OneMinusSrcAlpha
ColorMask RGB
Alphatest Greater 0
Lighting Off
ZWrite Off
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_builtin
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"
#pragma target 5.0
float _T;
uniform sampler2D _MainTex;
uniform float4 _MainTex_ST;
struct a2v
{
float4 vertex : POSITION;
float4 texcoord : TEXCOORD0;
float4 color : COLOR;
};
struct v2f
{
float4 pos : SV_POSITION;
float4 tex : TEXCOORD0;
float4 color;
};
v2f vert(a2v v){
v2f o;
o.color = float4(v.color.rgb, v.color.a);
if(o.color.b == 1)
{
o.pos = 0;
o.color.a = 0;
}
else
{
o.color.a =o.color.b;
o.tex = v.texcoord;
o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
}
return o;
}
float4 frag(v2f i) : COLOR
{
half4 texcol = tex2D(_MainTex, i.tex.xy);
return texcol*i.color*_T;
}
ENDCG
}
}
}
If you rename _T, does it work? Silly question, but if it does why not just rename it?
No it does not. It is a know bug according to other users that the debug manager does not really say what is wrong.
It added #pragma exclude renderer_ps3_d3d11 so I think it has something to do with that. But even if I disable d11 and change to d9 it still does not work.
Answer by otg2 · Apr 11, 2015 at 03:17 PM
I found out! What a happy feeling to start a Saturday!
So - when I upgraded to unity 5 this was added to my cd code
// Upgrade NOTE: excluded shader from DX11 and Xbox360; has structs without semantics (struct v2f members color)
//#pragma exclude_renderers d3d11 xbox360
and in my v2f structure it was
struct v2f
{
float4 pos : SV_POSITION;
float4 tex : TEXCOORD0;
float4 color;
};
So changing the last line to float4 color : COLOR0;
Fixed it. It was just missing a extra input which Unit 4 somehow allowed. Case closed
Your answer
Follow this Question
Related Questions
Shader Forge can't work in Unity2017 0 Answers
Unlit Transparent Shader 0 Answers
Game Perfect in Unity 5 but not in Android Device 0 Answers
Animating y only on an object resembling a bomb 0 Answers
Unity 5's xCode build..... SUCKS? 1 Answer