Hey guys, I made a blending shader that uses a depth mask inbetween two maps on Strumpy, but I would love if someone could help me optimize this by taking out the lighting info, and making it to be only albedo information for iOS. I don’t need specular, gloss, normal map. Just color info and unlit. Any ideas? Perhaps Jesse the shader “hero” is around here?
ps: I have setup the Emission to be the input, I would like diffuse/albedo to be the case.
Here’s the code:
Shader "VertexBlend"
{
Properties
{
//Color("color", 2D = "white" {}
_front("_front", 2D) = "white" {}
_backdepth("_backdepth", 2D) = "white" {}
_blend_hardness("_blend_hardness", Range(0,50) ) = 5
_blend_amount("_blend_amount", Range(0,16) ) = 1
}
SubShader
{
Tags
{
"Queue"="Geometry"
"IgnoreProjector"="False"
"RenderType"="Opaque"
}
Lighting Off
Cull Back
ZWrite On
ZTest LEqual
ColorMask RGBA
Fog{
}
CGPROGRAM
#pragma surface surf BlinnPhongEditor noambient nolightmap vertex:vert
#pragma target 2.0
sampler2D _front;
sampler2D _backdepth;
float _blend_hardness;
float _blend_amount;
struct EditorSurfaceOutput {
half3 Albedo;
half3 Normal;
half3 Emission;
half3 Gloss;
half Specular;
half Alpha;
half4 Custom;
};
inline half4 LightingBlinnPhongEditor_PrePass (EditorSurfaceOutput s, half4 light)
{
half3 spec = light.a * s.Gloss;
half4 c;
c.rgb = (s.Albedo * light.rgb + light.rgb * spec);
c.a = s.Alpha;
return c;
}
inline half4 LightingBlinnPhongEditor (EditorSurfaceOutput s, half3 lightDir, half3 viewDir, half atten)
{
half3 h = normalize (lightDir + viewDir);
half diff = max (0, dot ( lightDir, s.Normal ));
float nh = max (0, dot (s.Normal, h));
float spec = pow (nh, s.Specular*128.0);
half4 res;
res.rgb = _LightColor0.rgb * diff;
res.w = spec * Luminance (_LightColor0.rgb);
res *= atten * 2.0;
return LightingBlinnPhongEditor_PrePass( s, res );
}
struct Input {
float2 uv_front;
float2 uv_backdepth;
float4 color : COLOR;
};
void vert (inout appdata_full v, out Input o) {
float4 VertexOutputMaster0_0_NoInput = float4(0,0,0,0);
float4 VertexOutputMaster0_2_NoInput = float4(0,0,0,0);
float4 VertexOutputMaster0_3_NoInput = float4(0,0,0,0);
v.color = v.color;
}
void surf (Input IN, inout EditorSurfaceOutput o) {
o.Normal = float3(0.0,0.0,1.0);
o.Alpha = 1.0;
o.Albedo = 0.0;
o.Emission = 0.0;
o.Gloss = 0.0;
o.Specular = 0.0;
o.Custom = 0.0;
float4 Tex2D2=tex2D(_front,(IN.uv_front.xyxy).xy);
float4 Tex2D1=tex2D(_backdepth,(IN.uv_backdepth.xyxy).xy);
float4 Splat0=IN.color.w;
float4 Multiply1=Splat0 * Tex2D1.aaaa;
float4 Multiply0=Splat0 * Tex2D1.aaaa;
float4 Multiply2=Multiply0 * _blend_amount.xxxx;
float4 Add0=Multiply1 + Multiply2;
float4 Splat1=IN.color.w;
float4 Add2=Splat1 + float4( 1,1,1,1 );
float4 Multiply3=_blend_hardness.xxxx * Add2;
float4 Add1=Multiply3 + float4( 1,1,1,1 );
float4 Pow0=pow(Add0,Add1);
float4 Clamp0=clamp(Pow0,float4( 0,0,0,0 ),float4( 1,1,1,1 ));
float4 Lerp1=lerp(Tex2D2,Tex2D1,Clamp0);
float4 Master0_0_NoInput = float4(0,0,0,0);
float4 Master0_1_NoInput = float4(0,0,1,1);
float4 Master0_3_NoInput = float4(0,0,0,0);
float4 Master0_4_NoInput = float4(0,0,0,0);
float4 Master0_5_NoInput = float4(1,1,1,1);
float4 Master0_7_NoInput = float4(0,0,0,0);
float4 Master0_6_NoInput = float4(1,1,1,1);
o.Emission = Lerp1;
//o.Normal = normalize(o.Normal);
}
ENDCG
}
Fallback "Diffuse"
}