Hi I have no clue about shaders, and when I was finally getting to understand them a bit, the system has changed completely (for me) on Unity 5. I have this on a shader: Properties { _Tint ("Tint Color", Color) = (.5, .5, .5, .5) _Blend ("Blend", Range(0.0,1.0)) = 0.5 _FrontTex ("Front (+Z)", 2D) = "white" {} _FrontTex2("2 Front (+Z)", 2D) = "white" {} } SubShader { Tags { "Queue" = "Background" } Cull Off ZTest Less ZWrite Off Fog { Mode Off } Lighting Off Color [_Tint] Pass { SetTexture [_FrontTex] { combine texture } SetTexture [_FrontTex2] { constantColor (0,0,0,[_Blend]) combine texture lerp(constant) previous } SetTexture [_FrontTex2] { combine previous +- primary, previous * primary } } } but Unity5 doesn't like it because it's using SetTexture combine +- How can this be rewritten so that it supports it? I thought it would be a 1 line change but apparently it requires all kind of fancy new things in cg that I have no idea about
Well... the reason for this is apparently due to some functions being removed for 5.0, since FFP is technically outdated... Another reason was the sheer amount of shader emulation code required to do such shaders in DX11 mode. This is due to DX11 being fully shader-based, and requiring the user knows HLSL. By removing those parts, it meant that now there's less code to maintain. Of course, that meant removal of the dot3 operation... sad! But I don't have any idea why a signed add (+-, as you pointed out) would be such an issue that it was removed... Would have to ask Aras that question! EDIT: Also, could you show me at least the whole error log?
What I'm asking is how to rewrite this shader to perform the same. There is no log, it says "SetTexture combine +- is obsolete" and that's about it
The fixed-function pipeline has been removed in Unity 5 if I remember correctly, but the shader you posted is using it. The following code should be doing the same (hopefully) as the code you posted, but using the programmable pipeline, which works with Unity 5: Code (CSharp): Shader "Custom/how to migrate combine new" { Properties { _Tint ("Tint Color", Color) = (.5, .5, .5, .5) _Blend ("Blend", Range(0.0,1.0)) = 0.5 _FrontTex ("Front (+Z)", 2D) = "white" {} _FrontTex2("2 Front (+Z)", 2D) = "white" {} } SubShader { Tags { "Queue" = "Background" } Cull Off ZTest Less ZWrite Off Fog { Mode Off } Lighting Off CGPROGRAM #pragma surface surf Lambert sampler2D _FrontTex; sampler2D _FrontTex2; float _Blend; float4 _Tint; struct Input { float2 uv_FrontTex; }; void surf (Input IN, inout SurfaceOutput o) { half4 c1 = tex2D (_FrontTex, IN.uv_FrontTex); half4 c2 = tex2D (_FrontTex2, IN.uv_FrontTex); // SetTexture [_FrontTex2] { constantColor (0,0,0,[_Blend]) combine texture lerp(constant) previous } // combine src1 lerp (src2) src3: Interpolates between src3 and src1, using the alpha of src2. half4 c = lerp(c1, c2, _Blend); // SetTexture [_FrontTex2] { combine previous +- primary, previous * primary } // combine src1 +- src2: Adds src1 to src2, then subtracts 0.5 (a signed add). c.rgb += _Tint.rgb - 0.5; o.Emission = c.rgb; o.Alpha = c.a; } ENDCG } FallBack "Diffuse" } What each of the commands is doing in the fixed function pipeline is documented here btw.
Thanks Peter77 I have a question though, about this line c.rgb += _Tint.rgb - 0.5; I don't see the Tint used anywhere on the original shader, how do you figure Tint is used there? Just wondering because I'm surprised not to see it on the SetTexture but used on the surface shader
It's this command: Code (CSharp): SetTexture [_FrontTex2] { combine previous +- primary, previous * primary } primary refers to the color from the lighting calculation or the vertex color if it is bound (as stated here), so it should be _Tint, I think, because of this binding: Code (CSharp): Color [_Tint] Hmm not sure what failed exactly means. I did test the original shader code and the one I posted side-by-side on a Plane GameObject in Unity 4.6.3 and it looks identical to me there and the code I posted looks the same in Unity 5.0b20.