Hello, i was building a 2d game in 4.2 and i was using a method to only use color near the player, the rest was BW, the method i was using to do this was a spotlight pointed at the player and then using the shader that a user gave here ( http://forum.unity3d.com/threads/126893-Opaque-on-lighted-parts-shader ) to use the color texture, and then i was putting BW on all the rest.
All cool, but now 4.3 is out and i’m remaking the game to use sprites and sprites manager since its easier to do the animations and such, but i can’t create this effect since that script doesn’t work on sprite renderers (everything goes invisible) and I can’t see how the inbuild Sprite/diffuse shader is built so that i can see what’s wrong or try to adapt the script to make what i want, i can only see the compiled one, and that one is a mess :X
anyone knows what is wrong in that shader as far as sprites are concerned?
the shader is
Shader "Custom/GrayscaleToAlpha" {
Properties {
_MainTex ("Texture", 2D) = "white" {}
_Color ("Main Color", Color) = (1,1,1,1)
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf LambertMod
half4 LightingLambertMod (SurfaceOutput s, half3 lightDir, half atten) {
half NdotL = dot (s.Normal, lightDir);
half4 c;
clip(_LightColor0.a - 1);
c.rgb = s.Albedo * _LightColor0.rgb * (NdotL * atten * 2);
c.a = s.Alpha;
return c;
}
struct Input {
float2 uv_MainTex;
};
sampler2D _MainTex;
float4 _Color;
void surf (Input IN, inout SurfaceOutput o) {
half4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
//o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}